diff --git a/src/chatwoot.ts b/src/chatwoot.ts index cac0aabc..2b6af0b3 100644 --- a/src/chatwoot.ts +++ b/src/chatwoot.ts @@ -1,6 +1,21 @@ +import { createEffect, onMount } from "solid-js"; + import { config } from "./config"; import { usePayContext } from "./context/Pay"; -import { createEffect, onMount } from "solid-js"; + +declare global { + interface Window { + chatwootSettings: { + darkMode: string; + }; + chatwootSDK: { + run: (config: { websiteToken: string; baseUrl: string }) => void; + }; + $chatwoot: { + setCustomAttributes: (attributes: { swapId: string }) => void; + }; + } +} export default function Chatwoot() { onMount(() => { @@ -14,13 +29,13 @@ export default function Chatwoot() { script.defer = true; script.async = true; parent.parentNode.insertBefore(script, parent); - script.onload = function() { + script.onload = function () { window.chatwootSettings = { - darkMode: "auto" + darkMode: "auto", }; window.chatwootSDK.run({ websiteToken: token, - baseUrl: url + baseUrl: url, }); }; } @@ -31,10 +46,10 @@ export default function Chatwoot() { createEffect(() => { if (swap() !== null) { window.$chatwoot.setCustomAttributes({ - swapId: swap().id + swapId: swap().id, }); } }); return ""; -} \ No newline at end of file +} diff --git a/src/index.tsx b/src/index.tsx index 5498e417..ff78e3a4 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,6 +7,7 @@ import log from "loglevel"; import { Match, Show, Switch, createSignal, onMount } from "solid-js"; import { render } from "solid-js/web"; +import Chatwoot from "./chatwoot"; import Footer from "./components/Footer"; import Nav from "./components/Nav"; import Notification from "./components/Notification"; @@ -27,7 +28,6 @@ import RefundEvm from "./pages/RefundEvm"; import RefundStep from "./pages/RefundStep"; import "./style/index.scss"; import "./utils/patches"; -import Chatwoot from "./chatwoot"; if ("serviceWorker" in navigator) { void navigator.serviceWorker diff --git a/src/pages/Pay.tsx b/src/pages/Pay.tsx old mode 100644 new mode 100755 index 1d3568e6..8bedd40c --- a/src/pages/Pay.tsx +++ b/src/pages/Pay.tsx @@ -1,6 +1,6 @@ import { useParams } from "@solidjs/router"; import log from "loglevel"; -import { Match, Show, Switch, createResource, onCleanup, createSignal } from "solid-js"; +import { Match, Show, Switch, createResource, onCleanup } from "solid-js"; import BlockExplorerLink from "../components/BlockExplorerLink"; import LoadingSpinner from "../components/LoadingSpinner";