From 390e779e9366b109bee6dbad495062ecac02bd73 Mon Sep 17 00:00:00 2001 From: 0xShuk Date: Sat, 28 Sep 2024 20:45:45 +0700 Subject: [PATCH 1/3] add accept terms popup --- components/App.tsx | 2 ++ components/TermsPopup.tsx | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 components/TermsPopup.tsx diff --git a/components/App.tsx b/components/App.tsx index 97d67b43e3..a199520b87 100644 --- a/components/App.tsx +++ b/components/App.tsx @@ -37,6 +37,7 @@ import { tryParsePublicKey } from '@tools/core/pubkey' import { useAsync } from 'react-async-hook' import { useVsrClient } from '../VoterWeightPlugins/useVsrClient' import { useRealmVoterWeightPlugins } from '@hooks/useRealmVoterWeightPlugins' +import TermsPopupModal from './TermsPopup' const Notifications = dynamic(() => import('../components/Notification'), { ssr: false, @@ -327,6 +328,7 @@ export function AppContents(props: Props) { {props.children} + diff --git a/components/TermsPopup.tsx b/components/TermsPopup.tsx new file mode 100644 index 0000000000..8145c48559 --- /dev/null +++ b/components/TermsPopup.tsx @@ -0,0 +1,60 @@ +import Modal from "./Modal" +import Button, { SecondaryButton } from './Button' +import { useEffect, useState } from "react" +import { useRouter } from "next/router" + +const TermsPopupModal = () => { + const [openModal, setOpenModal] = useState(true) + const [isClient, setIsClient] = useState(false) + const router = useRouter() + + useEffect(() => { + setIsClient(true) + }, []) + + useEffect(() => { + if (localStorage) { + const isTermAccepted = typeof window !== "undefined" ? + localStorage.getItem("accept-terms") === "true" : + false + + if (isTermAccepted) { + setOpenModal(false) + } + } + + console.log("Current accept-term state, ", localStorage.getItem("accept-terms")) + }) + + const acceptTerms = () => { + localStorage.setItem("accept-terms", "true") + setOpenModal(false) + } + + const rejectTerms = () => { + localStorage.setItem("accept-terms", "false") + router.push("https://realms.today#terms-rejected") + } + + console.log("Current Open Modal: ", openModal, "Current Set Client: ", isClient) + return ( + <> + {isClient && openModal ? + ( setOpenModal(false)} bgClickClose={false} hideClose={true}> +

+ The operating entity of this site and owner of the related intellectual property has + changed. The new operator is Realms Today Ltd. (the New Operator). We have accordingly + amended the Terms and the Private Policy governing the relationship between our users + and the New Operator. By clicking "accept", you represent and warrant that you agree to + the revised Terms and Private Policy. +

+
+ + Reject +
+
) : null + } + ) +} + +export default TermsPopupModal; \ No newline at end of file From d426bc19e70ceb264ce3dac8a92ae85546da320c Mon Sep 17 00:00:00 2001 From: 0xShuk Date: Sat, 28 Sep 2024 20:47:00 +0700 Subject: [PATCH 2/3] remove console logs --- components/TermsPopup.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/TermsPopup.tsx b/components/TermsPopup.tsx index 8145c48559..2c28f79b8f 100644 --- a/components/TermsPopup.tsx +++ b/components/TermsPopup.tsx @@ -22,8 +22,6 @@ const TermsPopupModal = () => { setOpenModal(false) } } - - console.log("Current accept-term state, ", localStorage.getItem("accept-terms")) }) const acceptTerms = () => { @@ -36,7 +34,6 @@ const TermsPopupModal = () => { router.push("https://realms.today#terms-rejected") } - console.log("Current Open Modal: ", openModal, "Current Set Client: ", isClient) return ( <> {isClient && openModal ? From 60b4da15785c91dce7d2fa78941900b994ae1311 Mon Sep 17 00:00:00 2001 From: 0xShuk Date: Sat, 28 Sep 2024 20:53:42 +0700 Subject: [PATCH 3/3] update reject link --- components/TermsPopup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/TermsPopup.tsx b/components/TermsPopup.tsx index 2c28f79b8f..a2360e0c6e 100644 --- a/components/TermsPopup.tsx +++ b/components/TermsPopup.tsx @@ -31,7 +31,7 @@ const TermsPopupModal = () => { const rejectTerms = () => { localStorage.setItem("accept-terms", "false") - router.push("https://realms.today#terms-rejected") + router.push("https://realms.today?terms=rejected") } return (