Skip to content

Commit caa99dc

Browse files
committed
settings page
- restructuring profile -> settings - new sidebar
1 parent a227198 commit caa99dc

File tree

12 files changed

+165
-84
lines changed

12 files changed

+165
-84
lines changed

frontend/app/(planner)/layout.tsx

-23
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,6 @@ export default function PlannerLayout({ children }: PlannerLayoutProps) {
3131

3232
const basePath = "/" + pathname.split("/")[1];
3333

34-
const adminNav = [
35-
{
36-
title: "Stundenplan",
37-
href: basePath,
38-
},
39-
{
40-
title: "Überblick",
41-
href: basePath + "/overview",
42-
},
43-
{
44-
title: "Veranstaltungen",
45-
href: basePath + "/events",
46-
},
47-
{
48-
title: "Anmeldungen",
49-
href: basePath + "/applications",
50-
},
51-
{
52-
title: "Einstellungen",
53-
href: basePath + "/settings",
54-
},
55-
];
56-
5734
useEffect(() => {
5835
const fetchData = async () => {
5936
const client = getClient();

frontend/app/(planner)/sidebar.tsx

+32-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BookCheck, Calendar, GraduationCap } from "lucide-react"
1+
import { BookCheck, Calendar, GraduationCap } from "lucide-react";
22

33
import {
44
Sidebar,
@@ -9,43 +9,47 @@ import {
99
SidebarMenu,
1010
SidebarMenuButton,
1111
SidebarMenuItem,
12-
} from "@/components/ui/sidebar"
13-
import {UmbrellaPopoverSelection} from "@/components/umbrella-popover-selection"
14-
import {Event} from "@/lib/gql/generated/graphql"
15-
import {usePathname} from "next/navigation"
12+
} from "@/components/ui/sidebar";
13+
import { UmbrellaPopoverSelection } from "@/components/umbrella-popover-selection";
14+
import { Event } from "@/lib/gql/generated/graphql";
15+
import { usePathname } from "next/navigation";
1616

1717
interface AdminSidebarProps {
18-
umbrellas: Event[]
18+
umbrellas: Event[];
1919
}
2020

21-
export function AdminSidebar({umbrellas}: AdminSidebarProps) {
22-
const pathname = usePathname()
21+
export function AdminSidebar({ umbrellas }: AdminSidebarProps) {
22+
const pathname = usePathname();
2323

24-
const basePath = "/" + pathname.split("/")[1]
24+
const basePath = "/" + pathname.split("/")[1];
25+
26+
const items = [
27+
{
28+
title: "Stundenplan",
29+
url: basePath,
30+
icon: Calendar,
31+
},
32+
{
33+
title: "Tutorien",
34+
url: basePath + "/tutorials",
35+
icon: GraduationCap,
36+
},
37+
{
38+
title: "Anmeldungen",
39+
url: basePath + "/registrations",
40+
icon: BookCheck,
41+
},
42+
];
2543

26-
const items = [
27-
{
28-
title: "Stundenplan",
29-
url: basePath,
30-
icon: Calendar,
31-
},
32-
{
33-
title: "Tutorien",
34-
url: basePath + "/tutorials",
35-
icon: GraduationCap,
36-
},
37-
{
38-
title: "Anmeldungen",
39-
url: basePath + "/registrations",
40-
icon: BookCheck,
41-
},
42-
]
4344
return (
4445
<Sidebar>
4546
<SidebarHeader>
4647
<SidebarMenu>
4748
<SidebarMenuItem>
48-
<UmbrellaPopoverSelection umbrellas={umbrellas} className="w-full justify-between" />
49+
<UmbrellaPopoverSelection
50+
umbrellas={umbrellas}
51+
className="w-full justify-between"
52+
/>
4953
</SidebarMenuItem>
5054
</SidebarMenu>
5155
</SidebarHeader>
@@ -68,5 +72,5 @@ const items = [
6872
</SidebarGroup>
6973
</SidebarContent>
7074
</Sidebar>
71-
)
75+
);
7276
}

frontend/app/(profile)/profile/layout.tsx

-33
This file was deleted.

frontend/app/(settings)/layout.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
2+
import { ProfileSidebar } from "./sidebar";
3+
import { Footer } from "@/components/footer";
4+
5+
interface SettingsLayoutProps {
6+
children: React.ReactNode;
7+
}
8+
9+
export default function SettingsLayout({ children }: SettingsLayoutProps) {
10+
return (
11+
<SidebarProvider>
12+
<ProfileSidebar />
13+
<main className="flex-1 mt-[80px]">
14+
<div className="p-5">
15+
<SidebarTrigger className="mb-2" />
16+
{children}
17+
</div>
18+
<Footer />
19+
</main>
20+
</SidebarProvider>
21+
);
22+
}

frontend/app/(settings)/sidebar.tsx

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
"use client";
2+
3+
import {
4+
BookCheck,
5+
CalendarCheck2,
6+
GraduationCap,
7+
Mail,
8+
School,
9+
Settings,
10+
Users,
11+
} from "lucide-react";
12+
13+
import {
14+
Sidebar,
15+
SidebarContent,
16+
SidebarGroup,
17+
SidebarGroupContent,
18+
SidebarGroupLabel,
19+
SidebarMenu,
20+
SidebarMenuButton,
21+
SidebarMenuItem,
22+
} from "@/components/ui/sidebar";
23+
import { useUser } from "@/components/providers";
24+
import { Role } from "@/lib/gql/generated/graphql";
25+
26+
export function ProfileSidebar() {
27+
const { user } = useUser();
28+
29+
const userItems = [
30+
{
31+
title: "Einstellungen",
32+
url: "/profile",
33+
icon: Settings,
34+
},
35+
{
36+
title: "Meine Anmeldungen",
37+
url: "/profile/registrations",
38+
icon: BookCheck,
39+
},
40+
{
41+
title: "Meine Tutorien",
42+
url: "/profile/tutorials",
43+
icon: GraduationCap,
44+
},
45+
{
46+
title: "Meine Verfügbarkeiten",
47+
url: "/profile/registrations",
48+
icon: CalendarCheck2,
49+
},
50+
];
51+
52+
const adminItems = [
53+
{
54+
title: "E-Mails",
55+
url: "/admin/mails",
56+
icon: Mail,
57+
},
58+
{
59+
title: "Nutzerverwaltung",
60+
url: "/admin/users",
61+
icon: Users,
62+
},
63+
{
64+
title: "Räume & Gebäude",
65+
url: "/admin/rooms",
66+
icon: School,
67+
},
68+
];
69+
70+
return (
71+
<Sidebar>
72+
<SidebarContent>
73+
<SidebarGroup>
74+
<SidebarGroupContent>
75+
<SidebarMenu>
76+
{userItems.map((item) => (
77+
<SidebarMenuItem key={item.title}>
78+
<SidebarMenuButton asChild>
79+
<a href={item.url}>
80+
<item.icon />
81+
<span>{item.title}</span>
82+
</a>
83+
</SidebarMenuButton>
84+
</SidebarMenuItem>
85+
))}
86+
</SidebarMenu>
87+
</SidebarGroupContent>
88+
</SidebarGroup>
89+
{user?.role === Role.Admin && (
90+
<SidebarGroup>
91+
<SidebarGroupLabel>Administration</SidebarGroupLabel>
92+
<SidebarGroupContent>
93+
<SidebarMenu>
94+
{adminItems.map((item) => (
95+
<SidebarMenuItem key={item.title}>
96+
<SidebarMenuButton asChild>
97+
<a href={item.url}>
98+
<item.icon />
99+
<span>{item.title}</span>
100+
</a>
101+
</SidebarMenuButton>
102+
</SidebarMenuItem>
103+
))}
104+
</SidebarMenu>
105+
</SidebarGroupContent>
106+
</SidebarGroup>
107+
)}
108+
</SidebarContent>
109+
</Sidebar>
110+
);
111+
}

0 commit comments

Comments
 (0)