|
|
@@ -1,19 +1,36 @@
|
|
|
// useIntercom contains all the utility methods related to the Intercom chat widget
|
|
|
-export const useIntercom = () => {
|
|
|
- const showIntercomWithMessageAfterDelay = (message: string, delaySeconds: number) => {
|
|
|
- const func = () => {
|
|
|
- if (typeof window.Intercom === 'function') {
|
|
|
- window.Intercom('showNewMessage', message);
|
|
|
- }
|
|
|
- }
|
|
|
- setTimeout(func, delaySeconds * 1000);
|
|
|
- }
|
|
|
+export const useIntercom = (): {
|
|
|
+ showIntercomWithMessage: ({
|
|
|
+ message,
|
|
|
+ delaySeconds,
|
|
|
+ }: {
|
|
|
+ message: string;
|
|
|
+ delaySeconds?: number | undefined;
|
|
|
+ }) => void;
|
|
|
+} => {
|
|
|
+ const showIntercomWithMessageAfterDelay = (
|
|
|
+ message: string,
|
|
|
+ delaySeconds: number
|
|
|
+ ): void => {
|
|
|
+ const func = (): void => {
|
|
|
+ if (typeof window.Intercom === "function") {
|
|
|
+ window.Intercom("showNewMessage", message);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ setTimeout(func, delaySeconds * 1000);
|
|
|
+ };
|
|
|
|
|
|
- const showIntercomWithMessage = ({ message, delaySeconds = 3 }: { message: string, delaySeconds?: number }) => {
|
|
|
- showIntercomWithMessageAfterDelay(message, delaySeconds);
|
|
|
- }
|
|
|
+ const showIntercomWithMessage = ({
|
|
|
+ message,
|
|
|
+ delaySeconds = 3,
|
|
|
+ }: {
|
|
|
+ message: string;
|
|
|
+ delaySeconds?: number;
|
|
|
+ }): void => {
|
|
|
+ showIntercomWithMessageAfterDelay(message, delaySeconds);
|
|
|
+ };
|
|
|
|
|
|
- return {
|
|
|
- showIntercomWithMessage,
|
|
|
- }
|
|
|
-}
|
|
|
+ return {
|
|
|
+ showIntercomWithMessage,
|
|
|
+ };
|
|
|
+};
|