File tree Expand file tree Collapse file tree 8 files changed +94
-213
lines changed Expand file tree Collapse file tree 8 files changed +94
-213
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
2
3
3
import * as React from 'react'
4
- import {
5
- BellElectric ,
6
- BookOpen ,
7
- Bot ,
8
- FileUser ,
9
- Settings2 ,
10
- SquareTerminal ,
11
- Users ,
12
- } from 'lucide-react'
13
4
14
5
import { Sidebar } from '@/components/ui/sidebar'
15
- import { InsideCourseSidebar } from './InsideCourseSidebar '
6
+ import { InsideSidebar } from './InsideSidebar/InsideSidebar '
16
7
import { CourseSwitchSidebar } from './CourseSwitchSidebar/CourseSwitchSidebar'
17
8
18
- const data = {
19
- user : {
20
- name : 'shadcn' ,
21
-
22
- avatar : '/avatars/shadcn.jpg' ,
23
- } ,
24
- navMain : [
25
- {
26
- title : 'iPraktikum' ,
27
- url : '#' ,
28
- icon : SquareTerminal ,
29
- isActive : true ,
30
- items : [
31
- {
32
- title : 'Application' ,
33
- url : '#' ,
34
- icon : FileUser ,
35
- items : [
36
- {
37
- title : 'Dashboard' ,
38
- url : '#' ,
39
- } ,
40
- {
41
- title : 'Applications' ,
42
- url : '#' ,
43
- } ,
44
- {
45
- title : 'Application Questions' ,
46
- url : '#' ,
47
- } ,
48
- ] ,
49
- } ,
50
- {
51
- title : 'Intro Course' ,
52
- url : '#' ,
53
- icon : BellElectric ,
54
- } ,
55
- {
56
- title : 'Team Phase' ,
57
- url : '#' ,
58
- icon : Users ,
59
- } ,
60
- {
61
- title : 'Settings' ,
62
- url : '#' ,
63
- icon : Settings2 ,
64
- } ,
65
- ] ,
66
- } ,
67
- {
68
- title : 'Models' ,
69
- url : '#' ,
70
- icon : Bot ,
71
- items : [
72
- {
73
- title : 'Genesis' ,
74
- url : '#' ,
75
- icon : Settings2 ,
76
- } ,
77
- {
78
- title : 'Explorer' ,
79
- url : '#' ,
80
- icon : Settings2 ,
81
- } ,
82
- {
83
- title : 'Quantum' ,
84
- url : '#' ,
85
- icon : Settings2 ,
86
- } ,
87
- ] ,
88
- } ,
89
- {
90
- title : 'Documentation' ,
91
- url : '#' ,
92
- icon : BookOpen ,
93
- items : [
94
- {
95
- title : 'Introduction' ,
96
- url : '#' ,
97
- } ,
98
- {
99
- title : 'Get Started' ,
100
- url : '#' ,
101
- } ,
102
- {
103
- title : 'Tutorials' ,
104
- url : '#' ,
105
- } ,
106
- {
107
- title : 'Changelog' ,
108
- url : '#' ,
109
- } ,
110
- ] ,
111
- } ,
112
- {
113
- title : 'Settings' ,
114
- url : '#' ,
115
- icon : Settings2 ,
116
- items : [
117
- {
118
- title : 'General' ,
119
- url : '#' ,
120
- } ,
121
- {
122
- title : 'Team' ,
123
- url : '#' ,
124
- } ,
125
- {
126
- title : 'Billing' ,
127
- url : '#' ,
128
- } ,
129
- {
130
- title : 'Limits' ,
131
- url : '#' ,
132
- } ,
133
- ] ,
134
- } ,
135
- ] ,
136
- }
137
-
138
9
interface AppSidebarProps extends React . ComponentProps < typeof Sidebar > {
139
10
onLogout : ( ) => void
140
11
}
141
12
142
13
export function AppSidebar ( { onLogout, ...props } : AppSidebarProps ) : JSX . Element {
143
- // TODO this will be replaced with router logic
144
- const [ activeItem ] = React . useState ( data . navMain [ 0 ] )
145
-
146
14
return (
147
15
< Sidebar
148
16
collapsible = 'icon'
@@ -151,7 +19,7 @@ export function AppSidebar({ onLogout, ...props }: AppSidebarProps): JSX.Element
151
19
>
152
20
{ /* This is the first sidebar */ }
153
21
< CourseSwitchSidebar onLogout = { onLogout } />
154
- < InsideCourseSidebar activeItem = { activeItem } />
22
+ < InsideSidebar />
155
23
</ Sidebar >
156
24
)
157
25
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { SidebarMenu } from '@/components/ui/sidebar'
2
+
3
+ export const InsideCourseSidebar = ( ) : JSX . Element => {
4
+ return < SidebarMenu > </ SidebarMenu >
5
+ }
Original file line number Diff line number Diff line change
1
+ import { Collapsible , CollapsibleContent , CollapsibleTrigger } from '@/components/ui/collapsible'
2
+ import {
3
+ SidebarMenu ,
4
+ SidebarMenuButton ,
5
+ SidebarMenuItem ,
6
+ SidebarMenuSub ,
7
+ SidebarMenuSubButton ,
8
+ SidebarMenuSubItem ,
9
+ } from '@/components/ui/sidebar'
10
+ import { ChevronRight , Settings } from 'lucide-react'
11
+
12
+ export const InsideGeneralSidebar = ( ) : JSX . Element => {
13
+ return (
14
+ < SidebarMenu >
15
+ < SidebarMenuItem >
16
+ < Collapsible key = { 'settings' } asChild defaultOpen = { false } className = 'group/collapsible' >
17
+ < SidebarMenuItem >
18
+ < CollapsibleTrigger asChild >
19
+ < SidebarMenuButton tooltip = { 'Settings' } >
20
+ < Settings />
21
+ < span > Settings</ span >
22
+ < ChevronRight className = 'ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90' />
23
+ </ SidebarMenuButton >
24
+ </ CollapsibleTrigger >
25
+ < CollapsibleContent >
26
+ < SidebarMenuSub >
27
+ < SidebarMenuSubItem key = { 'Something' } >
28
+ < SidebarMenuSubButton asChild >
29
+ < span > Something</ span >
30
+ </ SidebarMenuSubButton >
31
+ </ SidebarMenuSubItem >
32
+ < SidebarMenuSubItem key = { 'Something else' } >
33
+ < SidebarMenuSubButton asChild >
34
+ < span > Something else</ span >
35
+ </ SidebarMenuSubButton >
36
+ </ SidebarMenuSubItem >
37
+ </ SidebarMenuSub >
38
+ </ CollapsibleContent >
39
+ </ SidebarMenuItem >
40
+ </ Collapsible >
41
+ </ SidebarMenuItem >
42
+ </ SidebarMenu >
43
+ )
44
+ }
Original file line number Diff line number Diff line change
1
+ import { Label } from '@/components/ui/label'
2
+ import {
3
+ Sidebar ,
4
+ SidebarContent ,
5
+ SidebarGroup ,
6
+ SidebarGroupContent ,
7
+ SidebarHeader ,
8
+ } from '@/components/ui/sidebar'
9
+ import { useCourseStore } from '@/zustand/useCourseStore'
10
+ import { useLocation , useParams } from 'react-router-dom'
11
+ import { InsideCourseSidebar } from './InsideCourseSidebar'
12
+ import { InsideGeneralSidebar } from './InsideGeneralSidebar'
13
+
14
+ export const InsideSidebar = ( ) : JSX . Element => {
15
+ const { courses } = useCourseStore ( )
16
+ const { courseId } = useParams < { courseId : string } > ( )
17
+ const currentCourse = courses . find ( ( course ) => course . id === courseId )
18
+
19
+ // set the correct header
20
+ const location = useLocation ( )
21
+ const isCourseSidebar = location . pathname . startsWith ( '/management/course' )
22
+ const headerName = isCourseSidebar ? currentCourse ?. name || 'Unknown Course' : 'General'
23
+
24
+ return (
25
+ < Sidebar collapsible = 'none' className = 'flex-1 flex' >
26
+ < SidebarHeader className = 'gap-3.5 border-b p-4' >
27
+ < div className = 'flex w-full items-center justify-between' >
28
+ < div className = 'text-base font-medium text-foreground' > { headerName } </ div >
29
+ < Label className = 'flex items-center gap-2 text-sm' > </ Label >
30
+ </ div >
31
+ </ SidebarHeader >
32
+ < SidebarContent >
33
+ < SidebarGroup className = 'px-2 py-4' >
34
+ < SidebarGroupContent >
35
+ { isCourseSidebar ? < InsideCourseSidebar /> : < InsideGeneralSidebar /> }
36
+ </ SidebarGroupContent >
37
+ </ SidebarGroup >
38
+ </ SidebarContent >
39
+ </ Sidebar >
40
+ )
41
+ }
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ export const ManagementRoot = ({ children }: { children?: React.ReactNode }): JS
66
66
return < UnauthorizedPage />
67
67
}
68
68
69
+ // TODO: when calling /management -> check for course in local storage, else redirect to /management/general
70
+
69
71
// TODO do course id management here
70
72
// store latest selected course in local storage
71
73
// check authorization
You can’t perform that action at this time.
0 commit comments