forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidebar.tsx
More file actions
259 lines (252 loc) · 6.44 KB
/
Copy pathsidebar.tsx
File metadata and controls
259 lines (252 loc) · 6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useState, useEffect } from "react";
import {
LayoutGrid,
Package2,
Users,
LogOut,
CreditCard,
CheckSquare,
DollarSign,
Building2,
MessageSquare,
ChevronLeft,
ChevronRight,
Megaphone,
Truck,
Bell,
ShieldAlert,
ThumbsDown,
FlaskConical,
Rocket,
Handshake,
Star,
MessageSquarePlus,
Tv,
} from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { useAuth } from "@/components/auth-provider";
export function DashboardSidebar() {
const pathname = usePathname();
const { signOut } = useAuth();
const [isCollapsed, setIsCollapsed] = useState(false);
// Load collapsed state from localStorage on mount
useEffect(() => {
const savedState = localStorage.getItem("sidebarCollapsed");
if (savedState !== null) {
setIsCollapsed(savedState === "true");
}
}, []);
// Save collapsed state to localStorage
const toggleCollapse = () => {
const newState = !isCollapsed;
setIsCollapsed(newState);
localStorage.setItem("sidebarCollapsed", String(newState));
};
const navItems = [
{
title: "Dashboard",
href: "/dashboard",
icon: LayoutGrid,
},
{
title: "TV wall links",
href: "/dashboard/tv-links",
icon: Tv,
},
{
title: "Apps",
href: "/dashboard/apps",
icon: Package2,
},
{
title: "Summary Apps",
href: "/dashboard/summary-apps",
icon: MessageSquare,
},
{
title: "Reviews",
href: "/dashboard/reviews",
icon: CheckSquare,
},
{
title: "Subscriptions",
href: "/dashboard/subscriptions",
icon: CreditCard,
},
{
title: "App Payouts",
href: "/dashboard/payouts",
icon: DollarSign,
},
{
title: "Affiliates",
href: "/dashboard/affiliates",
icon: Handshake,
},
{
title: "Organizations",
href: "/dashboard/organizations",
icon: Building2,
},
{
title: "Team",
href: "/dashboard/team",
icon: Users,
},
{
title: "Announcements",
href: "/dashboard/announcements",
icon: Megaphone,
},
{
title: "Notifications",
href: "/dashboard/notifications",
icon: Bell,
},
{
title: "Prompts",
href: "/dashboard/prompts",
icon: MessageSquarePlus,
},
{
title: "CSAT",
href: "/dashboard/csat",
icon: Star,
},
{
title: "Releases",
href: "/dashboard/releases",
icon: Rocket,
},
{
title: "Chat Lab",
href: "/dashboard/chat-lab",
icon: FlaskConical,
},
{
title: "Distributors",
href: "/dashboard/distributors",
icon: Truck,
},
{
title: "Fair Use",
href: "/dashboard/fair-use",
icon: ShieldAlert,
},
{
title: "Negative Feedback",
href: "/dashboard/feedback",
icon: ThumbsDown,
},
];
const handleLogout = async () => {
await signOut();
};
return (
<aside
className={cn(
"sticky top-0 z-20 flex h-screen flex-shrink-0 flex-col border-r bg-card transition-all duration-300",
isCollapsed ? "w-16" : "w-64"
)}
>
<div
className={cn(
"relative flex h-14 items-center border-b transition-all duration-300",
isCollapsed ? "justify-center px-2" : "justify-between px-4"
)}
>
<Link
href="/dashboard"
className={cn(
"flex items-center space-x-2 font-semibold transition-all duration-200",
isCollapsed ? "justify-center" : "justify-start"
)}
>
<Package2 className="h-6 w-6 flex-shrink-0" />
<span
className={cn(
"whitespace-nowrap transition-opacity duration-200",
isCollapsed ? "w-0 overflow-hidden opacity-0" : "opacity-100"
)}
>
OMI Admin
</span>
</Link>
<Button
variant="ghost"
size="icon"
className={cn(
"h-8 w-8 flex-shrink-0",
isCollapsed &&
"absolute -right-3 top-1/2 z-10 translate-y-[-50%] rounded-full border border-border bg-background shadow-sm"
)}
onClick={toggleCollapse}
aria-label={isCollapsed ? "Expand sidebar" : "Collapse sidebar"}
>
{isCollapsed ? (
<ChevronRight className="h-4 w-4" />
) : (
<ChevronLeft className="h-4 w-4" />
)}
</Button>
</div>
<div className="flex flex-1 flex-col justify-between py-6">
<nav className="space-y-1 px-2">
{navItems.map((item) => (
<Link
key={item.href}
href={item.href}
className={cn(
"flex items-center rounded-md px-2 py-2 text-sm font-medium transition-colors",
isCollapsed ? "justify-center" : "justify-start",
pathname === item.href
? "bg-primary/10 text-primary"
: "text-foreground hover:bg-accent hover:text-accent-foreground"
)}
title={isCollapsed ? item.title : undefined}
>
<item.icon className="h-5 w-5 flex-shrink-0" />
<span
className={cn(
"transition-opacity duration-200",
isCollapsed
? "ml-0 w-0 overflow-hidden opacity-0"
: "ml-3 opacity-100"
)}
>
{item.title}
</span>
</Link>
))}
</nav>
<div className="space-y-1 px-2">
<Button
variant="ghost"
className={cn(
"w-full text-muted-foreground transition-colors",
isCollapsed ? "justify-center" : "justify-start"
)}
onClick={handleLogout}
title={isCollapsed ? "Log out" : undefined}
>
<LogOut className="h-5 w-5 flex-shrink-0" />
<span
className={cn(
"transition-opacity duration-200",
isCollapsed
? "ml-0 w-0 overflow-hidden opacity-0"
: "ml-3 opacity-100"
)}
>
Log out
</span>
</Button>
</div>
</div>
</aside>
);
}