This repository has no description
644 B
26 lines
1'use client';
2
3import { useEffect } from 'react';
4import { useRouter } from 'next/navigation';
5import { useAuth } from '@/hooks/useAuth';
6import AppLayout from '@/components/navigation/appLayout/AppLayout';
7
8interface Props {
9 children: React.ReactNode;
10}
11export default function Layout(props: Props) {
12 const router = useRouter();
13 const { isAuthenticated, isLoading } = useAuth();
14
15 useEffect(() => {
16 if (!isLoading && !isAuthenticated) {
17 router.push('/login');
18 }
19 }, [isAuthenticated, isLoading, router]);
20
21 if (!isAuthenticated) {
22 return null; // Redirecting
23 }
24
25 return <AppLayout>{props.children}</AppLayout>;
26}