"use client"; import React, { useEffect } from "react"; import { useAuth } from "@/hooks/useAuth"; import { useRouter } from "next/navigation"; export default function DashboardIndex() { const { user, loading } = useAuth(); const router = useRouter(); useEffect(() => { if (loading) return; // wait for auth to initialize if (!user) { router.replace("/login"); return; } // Role-aware routing const role = user.role || "user"; if (role === "admin") router.replace("/dashboard/admin"); else if (role === "supervisor") router.replace("/dashboard/supervisor"); else if (role === "staff") router.replace("/dashboard/staff"); else router.replace("/dashboard/user"); }, [router, user, loading]); // This route only ever exists to redirect elsewhere (login now goes straight to the role // dashboard — see LoginForm — so this mainly serves bookmarks/direct links); show a deliberate // loading state instead of a blank screen while that redirect is worked out. return (