diff --git a/src/app/dashboard/components/DashboardNavbar.tsx b/src/app/dashboard/components/DashboardNavbar.tsx index 07dd719..da0f365 100644 --- a/src/app/dashboard/components/DashboardNavbar.tsx +++ b/src/app/dashboard/components/DashboardNavbar.tsx @@ -1,24 +1,159 @@ +"use client"; import Navbar from "@/src/components/Navbar"; import Link from "next/link"; import Image from "next/image"; import UserDropdown from "@/src/components/Navbar/UserDropdown"; import { SidebarTrigger } from "@/src/components/ui/sidebar"; +import { useTeam, useTeams } from "@/src/hooks/useTeam"; +import { useProject, useProjects } from "@/src/hooks/useProject"; +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, + BreadcrumbSeparator, +} from "@/src/components/ui/breadcrumb"; +import { Box, Building2, Check, ChevronsUpDown } from "lucide-react"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/src/components/ui/dropdown-menu"; +import { Button } from "@/src/components/ui/button"; +import { usePathname } from "next/navigation"; + +interface ItemDropdownProps { + label: string; + items: T[] | undefined; + activeItem: T | undefined; + getLabel: (item: T) => string; + getHref: (item: T) => string; +} +function ItemDropdown({ + label, + items, + activeItem, + getLabel, + getHref, +}: ItemDropdownProps) { + return ( + + + + + + {label} + + + {items?.map((t) => ( + + + {getLabel(t)} + {t.id == activeItem?.id && } + + + ))} + + + + ); +} export default function DashboardNavbar() { + const pathname = usePathname(); + const { data: teams, isLoading: isTeamsLoading } = useTeams(); + const { data: team, isLoading: isTeamLoading } = useTeam(); + const { data: projects, isLoading: isProjectsLoading } = useProjects(); + const { data: project, isLoading: isProjectLoading } = useProject(); + + const afterTeamPath = pathname.split(`/dashboard/${team?.slug}`)[1]; + const afterProjectPath = pathname.split(`/dashboard/${team?.slug}/projects/${project?.slug}`)[1]; + return (
-
- - - Logo - +
+ + + + + + Logo + + + {team && ( + <> +
+ +
+ + + + + {team.displayName} + + + + t.displayName} + getHref={(t) => + project ? `/dashboard/${t.slug}` : `/dashboard/${t.slug}/${afterTeamPath}` + } + /> +
+
+ + )} + {team && project && ( + <> +
+ +
+ + + + + {project.name} + + + + p.name} + getHref={(p) => + `/dashboard/${team.slug}/projects/${p.slug}/${afterProjectPath}` + } + /> +
+
+ + )} +
+
+
diff --git a/src/components/ui/breadcrumb.tsx b/src/components/ui/breadcrumb.tsx new file mode 100644 index 0000000..8757be9 --- /dev/null +++ b/src/components/ui/breadcrumb.tsx @@ -0,0 +1,109 @@ +import * as React from "react" +import { ChevronRight, MoreHorizontal } from "lucide-react" +import { Slot } from "radix-ui" + +import { cn } from "@/src/lib/utils" + +function Breadcrumb({ ...props }: React.ComponentProps<"nav">) { + return