Skip to content

Commit 75c2211

Browse files
committed
Fix sidebar navigation
1 parent d6be17e commit 75c2211

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

components/app-sidebar.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ import {
8383
SidebarTrigger,
8484
} from "@/components/ui/sidebar";
8585
import { ThemeProvider, useTheme } from "@/contexts/theme-context";
86+
import { usePathname } from "next/navigation";
87+
import Link from "next/link";
8688

8789
// This is sample data.
8890
const data = {
@@ -111,31 +113,31 @@ const data = {
111113
navMain: [
112114
{
113115
title: "Users",
114-
url: "/users",
116+
url: "users",
115117
icon: Users,
116118
items: [],
117119
},
118120
{
119121
title: "Contests",
120-
url: "/contests",
122+
url: "contests",
121123
icon: Trophy,
122124
items: [],
123125
},
124126
{
125127
title: "Problems",
126-
url: "/problems",
128+
url: "problems",
127129
icon: FileCode,
128130
items: [],
129131
},
130132
{
131133
title: "Submissions",
132-
url: "/submissions",
134+
url: "submissions",
133135
icon: FileCheck,
134136
items: [],
135137
},
136138
{
137139
title: "Settings",
138-
url: "/settings",
140+
url: "settings",
139141
icon: Settings,
140142
items: [],
141143
},
@@ -185,6 +187,10 @@ function ThemeItems() {
185187

186188
export function AppSidebar({ children }: { children: React.ReactNode }) {
187189
const [activeTeam, setActiveTeam] = React.useState(data.teams[0]);
190+
const pathname = usePathname();
191+
192+
// Get the base path (e.g., /[orgId])
193+
const basePath = pathname.split("/").slice(0, 2).join("/");
188194

189195
return (
190196
<ThemeProvider>
@@ -258,10 +264,10 @@ export function AppSidebar({ children }: { children: React.ReactNode }) {
258264
{data.navMain.map((item) => (
259265
<SidebarMenuItem key={item.title}>
260266
<SidebarMenuButton asChild tooltip={item.title}>
261-
<a href={item.url}>
267+
<Link href={`${basePath}/${item.url}`}>
262268
{item.icon && <item.icon />}
263269
<span>{item.title}</span>
264-
</a>
270+
</Link>
265271
</SidebarMenuButton>
266272
</SidebarMenuItem>
267273
))}

0 commit comments

Comments
 (0)