"use client"; import Image from "next/image"; import { deleteAuth, getAuth } from "../../api/auth"; import { Button } from "@mui/material"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; interface AuthPayload { token?: string; email?: string; name?: string; [k: string]: unknown; } export default function Header() { const router = useRouter(); const [mounted, setMounted] = useState(false); const [auth, setAuth] = useState(null); useEffect(() => { setMounted(true); const a = getAuth() as AuthPayload | string | null; setAuth(a); }, []); const onLogout = () => { deleteAuth(); router.push("/login"); }; if (!mounted) return null; return (
logo {/* indoteknik */}
{typeof auth === "object" && auth?.email ? auth.email : ""}
); }