'use client'; import type {ReactNode} from 'react'; import {useEffect, useRef} from 'react'; import {Button, Skeleton} from 'antd'; import {LockOutlined} from '@ant-design/icons'; import {useAuth} from '@/app/context/AuthContext'; import {useLanguage} from '@/app/context/LanguageContext'; import {accountCopy} from '@/data/account'; export default function ProtectedPage({children}: {children: ReactNode}) { const auth = useAuth(); const {locale} = useLanguage(); const copy = accountCopy[locale]; const prompted = useRef(false); useEffect(() => { if (auth.ready && !auth.isAuthenticated && !prompted.current) { prompted.current = true; auth.openLogin(); } }, [auth]); if (!auth.ready) return ( ); if (!auth.isAuthenticated) return ( {copy.protectedTitle} {copy.protectedDescription} auth.openLogin()}> {copy.openLogin} ); return children; }
{copy.protectedDescription}