This repository has been archived on 2026-11-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
hope-events/frontend/src/app/dashboard/page.tsx
T
joshua 3d381944d2 Initial commit
Next.js + Express event management app for Hope Family Church.
2026-07-23 15:26:47 +02:00

33 lines
1.2 KiB
TypeScript

"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 (
<div className="min-h-screen flex items-center justify-center bg-gray-50">
<div className="text-sm text-gray-400">Loading…</div>
</div>
);
}