Skip to content

Commit 9616b3a

Browse files
authored
fix accept terms modal (#221)
1 parent 8b24153 commit 9616b3a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/terms-of-use-acceptance/terms-of-use-acceptance.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import React from 'react';
3+
import React, { useEffect } from 'react';
44
import Link from 'next/link';
55

66
import { useSession } from 'next-auth/react';
@@ -17,7 +17,7 @@ const STORAGE_ID = 'terms-of-use-acceptance';
1717
export function TermsOfUseAcceptance({ className }: TermsOfUseAcceptanceProps) {
1818
const [accepted, setAccepted] = useAccepted();
1919
const { status } = useSession();
20-
if (status === 'unauthenticated') return null;
20+
if (status === 'unauthenticated' || accepted) return null;
2121

2222
return (
2323
<div
@@ -46,6 +46,12 @@ function useAccepted(): [boolean, () => void] {
4646
const [accepted, setAccepted] = React.useState(
4747
typeof window !== 'undefined' && window.localStorage.getItem(STORAGE_ID) === 'yes'
4848
);
49+
50+
useEffect(() => {
51+
if (typeof window !== 'undefined' && window.localStorage.getItem(STORAGE_ID))
52+
setAccepted(window.localStorage.getItem(STORAGE_ID) === 'yes');
53+
}, []);
54+
4955
return [
5056
accepted,
5157
() => {

0 commit comments

Comments
 (0)