-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
28 lines (24 loc) · 756 Bytes
/
page.tsx
File metadata and controls
28 lines (24 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use client";
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useAuth } from '../context/AuthContext';
export default function Home() {
const { user } = useAuth();
const router = useRouter();
useEffect(() => {
if (user) {
const defaultRoutes = {
SuperAdmin: '/dashboard-superadmin',
Gestor: '/dashboard-gestor',
Telefonista: '/dashboard-telefonista',
'Telefonista Supervisora': '/dashboard-telefonista-supervisora',
Tecnico: '/dashboard-tecnico',
};
const defaultRoute = defaultRoutes[user.role] || '/';
router.push(defaultRoute);
} else {
router.push('/login');
}
}, [user, router]);
return <div>Carregando...</div>;
}