'use client';

import './style.scss';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import useAuth from '@/hooks/useAuth';

export default function AccountLayout({ children }: { children: React.ReactNode }) {
	const router = useRouter();
	const { isAuthenticated, isLoading } = useAuth();

	// 로그인 만료 시 홈으로 리다이렉트
	useEffect(() => {
		if (!isLoading && !isAuthenticated) {
			router.replace('/');
		}
	}, [isAuthenticated, isLoading, router]);

	if (isLoading || !isAuthenticated) {
		return null;
	}

	return <>{children}</>;
}