Skip to content
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
1 change: 1 addition & 0 deletions src/app/app/virtual-lab/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default async function Page() {
undefined,
{
section: 'virtual-lab-home-page',
feature: 'list-virtual-labs',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react';
import Link from 'next/link';

import { useSession } from 'next-auth/react';
import { classNames } from '@/util/utils';

import styles from './terms-of-use-acceptance.module.css';
Expand All @@ -15,6 +16,9 @@ const STORAGE_ID = 'terms-of-use-acceptance';

export function TermsOfUseAcceptance({ className }: TermsOfUseAcceptanceProps) {
const [accepted, setAccepted] = useAccepted();
const { status } = useSession();
if (status === 'unauthenticated') return null;

return (
<div
className={classNames(className, styles.termsOfUseAcceptance, accepted && styles.accepted)}
Expand All @@ -40,12 +44,12 @@ export function TermsOfUseAcceptance({ className }: TermsOfUseAcceptanceProps) {

function useAccepted(): [boolean, () => void] {
const [accepted, setAccepted] = React.useState(
globalThis.localStorage.getItem(STORAGE_ID) === 'yes'
typeof window !== 'undefined' && window.localStorage.getItem(STORAGE_ID) === 'yes'
);
return [
accepted,
() => {
globalThis.localStorage.setItem(STORAGE_ID, 'yes');
if (typeof window !== 'undefined') window.localStorage.setItem(STORAGE_ID, 'yes');
setAccepted(true);
},
];
Expand Down