Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add accept terms popup #2449

Merged
merged 3 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -327,6 +328,7 @@ export function AppContents(props: Props) {
<TransactionLoader></TransactionLoader>
<NftVotingCountingModal />
<PageBodyContainer>{props.children}</PageBodyContainer>
<TermsPopupModal />
</GatewayProvider>
</ThemeProvider>
</ErrorBoundary>
Expand Down
57 changes: 57 additions & 0 deletions components/TermsPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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)
}
}
})

const acceptTerms = () => {
localStorage.setItem("accept-terms", "true")
setOpenModal(false)
}

const rejectTerms = () => {
localStorage.setItem("accept-terms", "false")
router.push("https://realms.today?terms=rejected")
}

return (
<>
{isClient && openModal ?
(<Modal isOpen={openModal && isClient} onClose={() => setOpenModal(false)} bgClickClose={false} hideClose={true}>
<p className="text-justify">
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.
</p>
<div className="flex gap-4 mt-4 justify-center">
<Button onClick={acceptTerms}>Accept</Button>
<SecondaryButton onClick={rejectTerms}>Reject</SecondaryButton>
</div>
</Modal>) : null
}
</>)
}

export default TermsPopupModal;
Loading