Skip to content

Commit

Permalink
Merge pull request #214 from authzed/install-reo
Browse files Browse the repository at this point in the history
Install vendor scripts
  • Loading branch information
samkim authored Mar 12, 2024
2 parents 4fec854 + 9ecfc32 commit 4e52e3a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from 'next/link';
import { LogoIcon } from './logo';
import Scripts from './scripts';

export default function Footer() {
return (
Expand All @@ -19,6 +20,7 @@ export default function Footer() {
</div>
</div>
</div>
<Scripts />
</div>
);
}
36 changes: 36 additions & 0 deletions components/scripts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use client';

import inEU from '@segment/in-eu';
import Script from 'next/script';
import { useEffect, useState } from 'react';

export default function Scripts() {
const [loadReo, setLoadReo] = useState(false);
const [afterLoad, setAfterLoad] = useState(false);
const isProd = process.env.VERCEL_ENV === 'production';

useEffect(() => {
if (window) {
setLoadReo(!inEU());
}
}, [loadReo]);

useEffect(() => {
// @ts-ignore
if (afterLoad && window.Reo) {
// @ts-ignore
window.Reo.init({ clientID: 'bf9727b30a874e3' });
}
}, [afterLoad]);

return (
<>
{isProd && loadReo && (
<Script
src="https://static.reo.dev/bf9727b30a874e3/reo.js"
onLoad={() => setAfterLoad(true)}
></Script>
)}
</>
);
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@radix-ui/react-slot": "^1.0.2",
"@segment/in-eu": "^0.4.0",
"@svgr/webpack": "^8.1.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4e52e3a

Please sign in to comment.