Skip to content

Commit

Permalink
chore: make zendesk executable
Browse files Browse the repository at this point in the history
  • Loading branch information
shelegdmitriy committed Feb 22, 2024
1 parent c18464f commit 9ec2d94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,13 @@ export default function App({ Component, pageProps }: AppPropsWithLayout) {
useEffect(() => {
// Displays the Zendesk widget only if user is signed in and on the home page
if (!window.zE) return;
if (
(!signedIn || Boolean(componentSrc?.componentAccountId && componentSrc?.componentName)) &&
!router.route.startsWith('/founders')
) {
if (!signedIn || Boolean(componentSrc?.componentAccountId && componentSrc?.componentName)) {
window.zE('webWidget', 'hide');
return;
}
localStorage.setItem('accountId', accountId);
window.zE('webWidget', 'show');
}, [accountId, signedIn, componentSrc, router.route]);
}, [accountId, signedIn, componentSrc]);

useEffect(() => {
const interval = setInterval(zendeskCheck, 20);
Expand Down
5 changes: 5 additions & 0 deletions src/pages/founders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useBosComponents } from '@/hooks/useBosComponents';
import { useDefaultLayout } from '@/hooks/useLayout';
import type { NextPageWithLayout } from '@/utils/types';

import { zendeskActivate } from '@/utils/zendesk';

const FoundersPage: NextPageWithLayout = () => {
const components = useBosComponents();
return (
Expand All @@ -12,6 +14,9 @@ const FoundersPage: NextPageWithLayout = () => {
title: 'NEAR | FounderHub',
description: 'FounderHub is a one-stop shop for Founders building with the near ecosystem.',
}}
componentProps={{
zendeskActivate,
}}
/>
);
};
Expand Down
7 changes: 7 additions & 0 deletions src/utils/zendesk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ export const styleZendesk = () => {
zwIcon.style.paddingRight = '0';
zwLabel.remove();
};

// export const getZendesk = () => {
// if (typeof window === 'undefined') return;
// return window.zE || null;
// };

export const zendeskActivate = () => (typeof window !== 'undefined' ? window.zE?.activate() || null : null);

0 comments on commit 9ec2d94

Please sign in to comment.