"use client" import Link from "next/link" import { useSession } from "./SessionProvider" import { authClient } from "@/lib/auth-client" import { useEffect, useState } from "react" export default function Navigation() { const { session, loading } = useSession() const [userRole, setUserRole] = useState(null) useEffect(() => { // Fetch user role from database if session exists const userId = (session?.user as { id?: string })?.id if (userId) { fetch(`/api/users/${userId}/role`) .then(res => res.json()) .then(data => setUserRole(data.role)) .catch(() => setUserRole(null)); } }, [session]); const handleLogout = async () => { await authClient.signOut() window.location.href = '/auth/login' } return ( ) }