"use client"; import * as React from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { Check, ChevronsUpDown, LogOut, Menu, Plus, Settings, User } from "lucide-react"; import { authClient } from "@/lib/auth-client"; import { selectProject } from "@/actions/projects"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; import { ThemeToggle } from "@/components/ui/theme"; import { Logo } from "@/components/ui/logo"; import { SidebarNav } from "./sidebar"; import { cn } from "@/lib/utils"; export interface TopbarProps { user: { name: string; email: string; image?: string | null }; organization: { id: string; name: string; plan: string }; projects: Array<{ id: string; name: string; environment: string }>; currentProjectId: string; isAdmin: boolean; } export function Topbar({ user, organization, projects, currentProjectId, isAdmin }: TopbarProps) { const router = useRouter(); const [open, setOpen] = React.useState(false); const [pending, startTransition] = React.useTransition(); const current = projects.find((p) => p.id === currentProjectId) ?? projects[0]; return (
{organization.name} /
Projects {projects.map((p) => ( startTransition(async () => { await selectProject(p.id); router.refresh(); })} className="justify-between" > {p.name} {p.id === currentProjectId ? : null} ))} New project {organization.plan}
{user.name || "Account"}
{user.email}
Profile Security {isAdmin ? Admin : null} { await authClient.signOut(); router.push("/login"); router.refresh(); }} > Sign out
Navigation
setOpen(false)} />
); }