diff --git a/frontend/src/components/commonUI/GuestModeNotice.tsx b/frontend/src/components/commonUI/GuestModeNotice.tsx index b30f114..e3b360c 100644 --- a/frontend/src/components/commonUI/GuestModeNotice.tsx +++ b/frontend/src/components/commonUI/GuestModeNotice.tsx @@ -1,19 +1,35 @@ import { useAuthContext } from '@/hooks/useAuthContext' import { HStack, Text } from '@chakra-ui/react' import { useNavigate } from '@tanstack/react-router' +import { useState } from 'react' import { useTranslation } from 'react-i18next' -import { DefaultButton } from './Button' +import { DefaultButton, RedButton } from './Button' + +const GUEST_MODE_NOTIFICATION = 'guest_mode_notification' export default function GuestModeNotice() { const navigate = useNavigate() const { t } = useTranslation() const { logout } = useAuthContext() + //check localstorage to persist the notice visibility state + const [showNotice, setShowNotice] = useState(() => { + const savedState = localStorage.getItem(GUEST_MODE_NOTIFICATION) + return savedState ? JSON.parse(savedState) : true // Default to be true if not found + }) + const handleLogin = () => { logout() navigate({ to: '/login' }) } + const handleCancel = () => { + setShowNotice(false) + localStorage.setItem(GUEST_MODE_NOTIFICATION, JSON.stringify(false)) + } + + if (!showNotice) return null + return ( {t('general.actions.login')} + + {t('general.actions.cancel')} + ) }