diff --git a/client/.env.development.imex b/client/.env.development.imex index a7c9c1349..79d1b4e63 100644 --- a/client/.env.development.imex +++ b/client/.env.development.imex @@ -16,4 +16,5 @@ TEST_USERNAME="test@imex.dev" TEST_PASSWORD="test123" VITE_PUBLIC_POSTHOG_KEY=phc_xtLmBIu0rjWwExY73Oj5DTH1bGbwq1G1Y8jnlTceien VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com -VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com \ No newline at end of file +VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com +VITE_APP_AMP_KEY=6228a598e57cd66875cfd41604f1f891 \ No newline at end of file diff --git a/client/.env.development.rome b/client/.env.development.rome index 816df9917..eabf048e8 100644 --- a/client/.env.development.rome +++ b/client/.env.development.rome @@ -18,4 +18,5 @@ TEST_USERNAME="test@imex.dev" TEST_PASSWORD="test123" VITE_PUBLIC_POSTHOG_KEY=phc_xtLmBIu0rjWwExY73Oj5DTH1bGbwq1G1Y8jnlTceien VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com -VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com \ No newline at end of file +VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com +VITE_APP_AMP_KEY=46b1193a867d4e3131ae4c3a64a3fc78 \ No newline at end of file diff --git a/client/.env.production.imex b/client/.env.production.imex index dc1d7fe7a..70c7c01c7 100644 --- a/client/.env.production.imex +++ b/client/.env.production.imex @@ -15,4 +15,5 @@ VITE_APP_SPLIT_API=et9pjkik6bn67he5evpmpr1agoo7gactphgk VITE_APP_INSTANCE=IMEX VITE_PUBLIC_POSTHOG_KEY=phc_xtLmBIu0rjWwExY73Oj5DTH1bGbwq1G1Y8jnlTceien VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com -VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com \ No newline at end of file +VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com +VITE_APP_AMP_KEY=6228a598e57cd66875cfd41604f1f891 \ No newline at end of file diff --git a/client/.env.production.rome b/client/.env.production.rome index 808c8e199..cb2cd88ac 100644 --- a/client/.env.production.rome +++ b/client/.env.production.rome @@ -15,4 +15,5 @@ VITE_APP_SPLIT_API=et9pjkik6bn67he5evpmpr1agoo7gactphgk VITE_APP_INSTANCE=ROME VITE_PUBLIC_POSTHOG_KEY=phc_xtLmBIu0rjWwExY73Oj5DTH1bGbwq1G1Y8jnlTceien VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com -VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com \ No newline at end of file +VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com +VITE_APP_AMP_KEY=46b1193a867d4e3131ae4c3a64a3fc78 \ No newline at end of file diff --git a/client/.env.test.imex b/client/.env.test.imex index 2ff9a10d7..0afecd91b 100644 --- a/client/.env.test.imex +++ b/client/.env.test.imex @@ -15,4 +15,5 @@ VITE_APP_SPLIT_API=ts615lqgnmk84thn72uk18uu5pgce6e0l4rc VITE_APP_INSTANCE=IMEX VITE_PUBLIC_POSTHOG_KEY=phc_xtLmBIu0rjWwExY73Oj5DTH1bGbwq1G1Y8jnlTceien VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com -VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com \ No newline at end of file +VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com +VITE_APP_AMP_KEY=6228a598e57cd66875cfd41604f1f891 \ No newline at end of file diff --git a/client/.env.test.rome b/client/.env.test.rome index 24c9b7047..558c4528e 100644 --- a/client/.env.test.rome +++ b/client/.env.test.rome @@ -15,4 +15,5 @@ VITE_APP_SPLIT_API=ts615lqgnmk84thn72uk18uu5pgce6e0l4rc VITE_APP_INSTANCE=ROME VITE_PUBLIC_POSTHOG_KEY=phc_xtLmBIu0rjWwExY73Oj5DTH1bGbwq1G1Y8jnlTceien VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com -VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com \ No newline at end of file +VITE_APP_AMP_URL=https://vp8k908qy2.execute-api.ca-central-1.amazonaws.com +VITE_APP_AMP_KEY=46b1193a867d4e3131ae4c3a64a3fc78 \ No newline at end of file diff --git a/client/src/App/App.jsx b/client/src/App/App.jsx index fa24ef07e..ea3be8f5a 100644 --- a/client/src/App/App.jsx +++ b/client/src/App/App.jsx @@ -24,6 +24,7 @@ import InstanceRenderMgr from "../utils/instanceRenderMgr"; import ProductFruitsWrapper from "./ProductFruitsWrapper.jsx"; import { NotificationProvider } from "../contexts/Notifications/notificationContext.jsx"; import SocketProvider from "../contexts/SocketIO/socketProvider.jsx"; +import SoundWrapper from "./SoundWrapper.jsx"; const ResetPassword = lazy(() => import("../pages/reset-password/reset-password.component")); const ManagePage = lazy(() => import("../pages/manage/manage.page.container")); @@ -72,9 +73,6 @@ export function App({ setIsPartsEntry(isParts); }, [setIsPartsEntry]); - //const b = Grid.useBreakpoint(); - // console.log("Breakpoints:", b); - // Associate event listeners, memoize to prevent multiple listeners being added useEffect(() => { const offlineListener = () => { @@ -164,85 +162,87 @@ export function App({ /> - - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - + + + + + + } + /> + + + + } + /> + + + + } + /> + + + + } + /> + + + + } + /> + + + + + + } + > + } /> + + + + + + + } + > + } /> + + - - - } - > - } /> - - - - - - - } - > - } /> - - - - - } - > - } /> - - }> - } /> - - + + } + > + } /> + + }> + } /> + + + ); diff --git a/client/src/App/SoundWrapper.jsx b/client/src/App/SoundWrapper.jsx new file mode 100644 index 000000000..639fac3c9 --- /dev/null +++ b/client/src/App/SoundWrapper.jsx @@ -0,0 +1,43 @@ +import { useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { useNotification } from "../contexts/Notifications/notificationContext.jsx"; +import { initNewMessageSound, unlockAudio } from "./../utils/soundManager"; +import { initSingleTabAudioLeader } from "../utils/singleTabAudioLeader"; + +export default function SoundWrapper({ children, bodyshop }) { + const { t } = useTranslation(); + const notification = useNotification(); + + useEffect(() => { + if (!bodyshop?.id) return; + + // 1) Init single-tab leader election (only one tab should play sounds), scoped by bodyshopId + const cleanupLeader = initSingleTabAudioLeader(bodyshop.id); + + // 2) Initialize base audio + initNewMessageSound("https://images.imex.online/app/messageTone.wav", 0.7); + + // 3) Show a one-time prompt when autoplay blocks first play + const onNeedsUnlock = () => { + notification.info({ + description: t("audio.manager.description"), + duration: 3 + }); + }; + window.addEventListener("sound-needs-unlock", onNeedsUnlock); + + // 4) Proactively unlock on first gesture (once per session) + const gesture = () => unlockAudio(bodyshop.id); + window.addEventListener("click", gesture, { once: true, passive: true }); + window.addEventListener("touchstart", gesture, { once: true, passive: true }); + window.addEventListener("keydown", gesture, { once: true }); + + return () => { + cleanupLeader(); + window.removeEventListener("sound-needs-unlock", onNeedsUnlock); + // gesture listeners were added with {once:true} + }; + }, [notification, t, bodyshop?.id]); // include bodyshop.id so this runs when org changes + + return <>{children}; +} diff --git a/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx b/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx index 7775fbb8f..a3aacdb08 100644 --- a/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx +++ b/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx @@ -142,7 +142,16 @@ export function AccountingReceivablesTableComponent({ bodyshop, loading, jobs, r refetch={refetch} /> - + ) diff --git a/client/src/components/bills-list-table/bills-list-table.component.jsx b/client/src/components/bills-list-table/bills-list-table.component.jsx index 8b1d8e09c..166cd0b5b 100644 --- a/client/src/components/bills-list-table/bills-list-table.component.jsx +++ b/client/src/components/bills-list-table/bills-list-table.component.jsx @@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next"; import { FaTasks } from "react-icons/fa"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.utils"; import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { setModalContext } from "../../redux/modals/modals.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; @@ -75,6 +76,7 @@ export function BillsListTableComponent({