11'use client' ;
22
33import React from 'react' ;
4- import { useRouter , usePathname } from 'next/navigation' ;
5- import { useProjectStore } from '@/stores' ;
6- import { CheckIcon , ChevronDownIcon , Package } from 'lucide-react' ;
7- import { Breadcrumb , BreadcrumbItem , BreadcrumbList } from '@/components/ui/breadcrumb' ;
4+ import { usePathname , useRouter } from 'next/navigation' ;
5+ import { useDevlogStore , useProjectStore } from '@/stores' ;
6+ import { CheckIcon , ChevronsUpDown , NotepadText , Package } from 'lucide-react' ;
7+ import {
8+ Breadcrumb ,
9+ BreadcrumbItem ,
10+ BreadcrumbList ,
11+ BreadcrumbSeparator ,
12+ } from '@/components/ui/breadcrumb' ;
813import {
914 DropdownMenu ,
1015 DropdownMenuContent ,
@@ -19,20 +24,13 @@ export function NavigationBreadcrumb() {
1924 const pathname = usePathname ( ) ;
2025 const { currentProjectContext, currentProjectId, projectsContext, fetchProjects } =
2126 useProjectStore ( ) ;
27+ const { currentDevlogContext, currentDevlogId } = useDevlogStore ( ) ;
2228
2329 // Don't show breadcrumb on the home or project list page
2430 if ( [ '/' , '/projects' ] . includes ( pathname ) ) {
2531 return null ;
2632 }
2733
28- const getProjectInitials = ( name : string ) => {
29- return name
30- . split ( ' ' )
31- . map ( ( word ) => word . charAt ( 0 ) . toUpperCase ( ) )
32- . join ( '' )
33- . substring ( 0 , 2 ) ;
34- } ;
35-
3634 const switchProject = async ( projectId : number ) => {
3735 if ( currentProjectId === projectId ) return ;
3836
@@ -64,9 +62,7 @@ export function NavigationBreadcrumb() {
6462 if ( currentProjectContext . loading ) {
6563 return (
6664 < div className = "flex items-center gap-2" >
67- < Skeleton className = "h-4 w-4" />
68- < Skeleton className = "h-4 w-24" />
69- < Skeleton className = "h-4 w-4" />
65+ < Skeleton className = "h-4 w-32" />
7066 </ div >
7167 ) ;
7268 }
@@ -77,7 +73,7 @@ export function NavigationBreadcrumb() {
7773 < div className = "flex items-center gap-2 cursor-pointer rounded" >
7874 < Package size = { 14 } />
7975 < span > { currentProjectContext . data ?. name } </ span >
80- < ChevronDownIcon size = { 14 } className = "text-muted-foreground" />
76+ < ChevronsUpDown size = { 14 } className = "text-muted-foreground" />
8177 </ div >
8278 </ DropdownMenuTrigger >
8379 < DropdownMenuContent align = "start" className = "w-64" >
@@ -117,10 +113,34 @@ export function NavigationBreadcrumb() {
117113 ) ;
118114 } ;
119115
116+ const renderDevlogDropdown = ( ) => {
117+ if ( currentDevlogContext . loading ) {
118+ return (
119+ < div className = "flex items-center gap-2" >
120+ < Skeleton className = "h-4 w-32" />
121+ </ div >
122+ ) ;
123+ }
124+
125+ return (
126+ < div className = "flex items-center gap-2 cursor-pointer rounded" >
127+ < NotepadText size = { 14 } />
128+ < span > { currentDevlogContext . data ?. id } </ span >
129+ < ChevronsUpDown size = { 14 } className = "text-muted-foreground" />
130+ </ div >
131+ ) ;
132+ } ;
133+
120134 return (
121135 < Breadcrumb className = "navigation-breadcrumb" >
122136 < BreadcrumbList >
123- < BreadcrumbItem > { renderProjectDropdown ( ) } </ BreadcrumbItem >
137+ { currentProjectId && < BreadcrumbItem > { renderProjectDropdown ( ) } </ BreadcrumbItem > }
138+ { currentDevlogId && (
139+ < >
140+ < BreadcrumbSeparator />
141+ < BreadcrumbItem > { renderDevlogDropdown ( ) } </ BreadcrumbItem >
142+ </ >
143+ ) }
124144 </ BreadcrumbList >
125145 </ Breadcrumb >
126146 ) ;
0 commit comments