Skip to content

Commit 94b3463

Browse files
committed
chore: add quote states to MainNav
1 parent 08349f5 commit 94b3463

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

src/components/AppSidebar.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,30 @@ const data = {
2626
title: "Pending",
2727
url: "/quotes/pending",
2828
},
29+
{
30+
title: "Offered",
31+
url: "/quotes/offered",
32+
disabled: true,
33+
},
2934
{
3035
title: "Accepted",
3136
url: "/quotes/accepted",
3237
},
38+
{
39+
title: "Denied",
40+
url: "/quotes/denied",
41+
disabled: true,
42+
},
43+
{
44+
title: "Rejected",
45+
url: "/quotes/rejected",
46+
disabled: true,
47+
},
48+
{
49+
title: "Expired",
50+
url: "/quotes/expired",
51+
disabled: true,
52+
},
3353
],
3454
},
3555
{

src/components/nav/NavMain.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
SidebarMenuSubItem,
1313
useSidebar,
1414
} from "@/components/ui/sidebar"
15+
import { cn } from "@/lib/utils"
1516

1617
export function NavMain({
1718
items,
@@ -25,6 +26,7 @@ export function NavMain({
2526
items?: {
2627
title: string
2728
url: string
29+
disabled?: boolean
2830
}[]
2931
}[]
3032
}) {
@@ -38,10 +40,17 @@ export function NavMain({
3840
(item.items ?? []).length === 0 || state === "collapsed" ? (
3941
<SidebarMenuItem key={item.title}>
4042
<SidebarMenuButton asChild tooltip={item.title} disabled={item.disabled}>
41-
<NavLink to={item.url}>
42-
{item.icon && <item.icon />}
43-
<span>{item.title}</span>
44-
</NavLink>
43+
{item.disabled === true ? (
44+
<>
45+
{item.icon && <item.icon />}
46+
<span>{item.title}</span>
47+
</>
48+
) : (
49+
<NavLink to={item.url}>
50+
{item.icon && <item.icon />}
51+
<span>{item.title}</span>
52+
</NavLink>
53+
)}
4554
</SidebarMenuButton>
4655
</SidebarMenuItem>
4756
) : (
@@ -59,7 +68,14 @@ export function NavMain({
5968
{item.items?.map((subItem) => (
6069
<SidebarMenuSubItem key={subItem.title}>
6170
<SidebarMenuSubButton asChild>
62-
<NavLink to={subItem.url}>
71+
<NavLink
72+
to={subItem.url}
73+
onClick={subItem.disabled ? (e) => e.preventDefault() : undefined}
74+
className={cn({
75+
"opacity-50": subItem.disabled,
76+
"cursor-not-allowed": subItem.disabled,
77+
})}
78+
>
6379
<span>{subItem.title}</span>
6480
</NavLink>
6581
</SidebarMenuSubButton>

0 commit comments

Comments
 (0)