"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { fetchAuthStatus } from "@/lib/auth"; import { SETTINGS_ITEMS } from "@/lib/settings-items"; export default function SettingsMiniNav() { const pathname = usePathname(); const { t } = useTranslation(); // Only hide admin-only entries when we positively know the user is a // non-admin; the backend rejects them regardless. const [hideAdminOnly, setHideAdminOnly] = useState(false); useEffect(() => { let cancelled = false; fetchAuthStatus().then((status) => { if (cancelled || !status) return; setHideAdminOnly(Boolean(status.enabled) && !status.is_admin); }); return () => { cancelled = true; }; }, []); const items = SETTINGS_ITEMS.filter( (item) => !(item.adminOnly && hideAdminOnly), ); return ( ); }