'use client'

import { ReactNode, useEffect } from 'react';
import { notFound } from 'next/navigation';
import { AUTH_TOKEN_KEY } from '../../constants/common';
import { useLocalStorage } from '../../hooks/useLocalStorage';

function AccountWrapper ({ children }: { children: ReactNode }) {
    const [token] = useLocalStorage(AUTH_TOKEN_KEY, '');

    useEffect(() => {
        if(!token){
            return notFound();
        }
    }, []);

    return children;
}

export default AccountWrapper;
