"use client"; import api from "@app/api"; import { Avatar, AvatarFallback } from "@app/components/ui/avatar"; import { Button } from "@app/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@app/components/ui/dropdown-menu"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, } from "@app/components/ui/select"; import { useToast } from "@app/hooks/use-toast"; import { ListOrgsResponse } from "@server/routers/org"; import Link from "next/link"; import { useRouter } from "next/navigation"; type HeaderProps = { name?: string; email: string; orgName: string; orgs: ListOrgsResponse["orgs"]; }; export default function Header({ email, orgName, name, orgs }: HeaderProps) { const { toast } = useToast(); const router = useRouter(); function getInitials() { if (name) { const [firstName, lastName] = name.split(" "); return `${firstName[0]}${lastName[0]}`; } return email.substring(0, 2).toUpperCase(); } function logout() { api.post("/auth/logout") .catch((e) => { console.error("Error logging out", e); toast({ title: "Error logging out", }); }) .then(() => { router.push("/auth/login"); }); } return ( <>
{name && (

{name}

)}

{email}

Log out
{name || email}
Documentation Support
); }