"use client"; import Link from "next/link"; import { useEffect, useState } from "react"; import { browserFetch } from "../lib/api"; import { logoutByNavigation } from "../lib/logout"; type MeResponse = { user: { id: string; email: string; role: string } | null; makerProfile: { id: string; slug: string; business_name: string | null; status: string } | null; }; export default function AuthNav() { const [session, setSession] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { let active = true; async function loadSession() { try { const response = await browserFetch("/auth/me"); if (active) { setSession(response); } } catch { if (active) { setSession({ user: null, makerProfile: null }); } } finally { if (active) { setLoading(false); } } } void loadSession(); return () => { active = false; }; }, []); function logout() { logoutByNavigation(); } const user = session?.user || null; const makerProfile = session?.makerProfile || null; const isAdmin = user?.role === "admin"; const isMaker = Boolean(makerProfile && makerProfile.status !== "draft"); return ( ); }