Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {FerrisWheel, PlusCircle} from "lucide-react";
import {Button} from "@/components/ui/button";
import {ManagementPageHeader} from "@/components/management-page-header";
import {EventDialog} from "@/components/event-calendar/event-dialog";
import {Dialog} from "@/components/ui/dialog";
import {columns} from "@/app/(planner)/[planner]/columns";
import {DataTable} from "@/app/(planner)/[planner]/data-table";
import {useRefetch} from "@/components/providers";
Expand Down
15 changes: 15 additions & 0 deletions frontend/app/(planner)/[planner]/tutorials/[tutorial]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { extractId } from "@/lib/utils";
import { TutorialPage } from "@/components/tutorial-page";

export default async function TutorialDetailPage({
params,
}: {
params: Promise<{ tutorial: string }>;
}) {
const { tutorial } = await params;
return (
<>
<TutorialPage eventID={extractId(tutorial) ?? 0} />
</>
);
}
85 changes: 85 additions & 0 deletions frontend/app/(planner)/[planner]/tutorials/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"use client";

import {ManagementPageHeader} from "@/components/management-page-header";
import {RefetchProvider, useUser} from "@/components/providers";
import {SidebarNav} from "@/components/sidebar-nav";
import {EventsOfUmbrellaDocument} from "@/lib/gql/generated/graphql";
import {extractId, slugify} from "@/lib/utils";
import {GraduationCap} from "lucide-react";
import React, {useCallback, useEffect, useState} from "react";
import {usePathname} from "next/navigation";
import {getClient} from "@/lib/graphql";

interface ProfileTutorialsLayoutProps {
children: React.ReactNode;
}

export default function UmbrellaTutorialsLayout({
children,
}: ProfileTutorialsLayoutProps) {
const {sid} = useUser();
const pathname = usePathname();
const umbrellaID = extractId(pathname);
const [events, setEvents] = useState<{
title: string;
description: React.JSX.Element;
href: string;
}[]>([])

const fetchEvents = useCallback(async () => {
if (!umbrellaID) return;

const client = getClient(sid!);
const eventData = await client.request(EventsOfUmbrellaDocument, {umbrellaIDs: [umbrellaID]})

// INFO: this was absolutely vibe coded
const normalizedPath = pathname.replace(/\/$/, "");
const tutorialsBase = normalizedPath.includes("/tutorials")
? normalizedPath.replace(/\/tutorials(\/.*)?$/, "/tutorials")
: `${normalizedPath}/tutorials`;
// INFO: vibe code ends here.

const eventInfos = eventData.events
.filter(event => !!event.tutorials?.length)
.map((event) => {
const slug = `${slugify(event.title)}-${event.ID}`;
return {
title: event.title,
description: <>{new Date(event.from).toLocaleDateString()}</>,
href: `${tutorialsBase}/${slug}`
};
});

setEvents(eventInfos)
}, [umbrellaID]);

useEffect(() => {
void fetchEvents()
}, [umbrellaID])


return (
<div className="space-y-6">
<ManagementPageHeader
iconNode={<GraduationCap/>}
title={"Tutorien"}
description={"Hier findest du alle Tutorien dieses Programms."}
/>

{events ? (
<div className="flex flex-col space-y-5 lg:flex-row lg:space-y-0">
<aside>
<SidebarNav items={events ?? []}/>
</aside>
<RefetchProvider>
<div className="w-full lg:ml-4">{children}</div>
</RefetchProvider>
</div>
) : (
<div className={"w-full p-10 text-center"}>
Dieses Programm scheint noch keine Tutorien zu haben
</div>
)}
</div>
);
}
11 changes: 3 additions & 8 deletions frontend/app/(planner)/[planner]/tutorials/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@

export const metadata = {
title: "Tutorien",
}

export default function OverviewPage() {
export default function SettingsProfilePage() {
return (
<p>Tutorien</p>
)
<></>
);
}
4 changes: 2 additions & 2 deletions frontend/app/(settings)/profile/tutorials/[tutorial]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { extractId } from "@/lib/utils";
import { TutorialPage } from "./tutorial-page";
import { TutorialPage } from "@/components/tutorial-page";

export default async function TutorialDetailPage({
params,
Expand All @@ -9,7 +9,7 @@ export default async function TutorialDetailPage({
const { tutorial } = await params;
return (
<>
<TutorialPage id={extractId(tutorial) ?? 0} />
<TutorialPage eventID={extractId(tutorial) ?? 0} onlyCurrentUser/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not quite sure i get the point behind the onlyCurrentUser? (which somehow also doesn't appear in my code locally which is kinda weird)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to work as intended without the onlyCurrentUser thing and break if it's in there but i'm not quite sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you leave it out, all users can see all tutorials. I'll look into why it does not fetch correctly

</>
);
}
162 changes: 0 additions & 162 deletions frontend/app/(settings)/profile/tutorials/[tutorial]/tutorial-page.tsx

This file was deleted.

7 changes: 4 additions & 3 deletions frontend/components/dialog/events/event-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ export default function EventDialog({
...e.umbrella?.registrationForm,
},
},
tutorials: e.tutorials?.map((t) => ({
tutorials: e.tutorials?.map((tutorial) => ({
...defaultTutorial,
...t,
...tutorial,
event: { ...defaultEvent, ID: id! },
tutors: t.tutors?.map((tu) => ({ ...defaultUser, ...tu })),
tutors: tutorial.tutors?.map((tutor) => ({ ...defaultUser, ...tutor })),
students: tutorial.students?.map((student) => ({ ...defaultUser, ...student })),
})),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { User } from "@/lib/gql/generated/graphql";
import { ColumnDef } from "@tanstack/react-table";
import { SquareMinus } from "lucide-react";
import React from "react";
import { StudentTableDialogState } from "@/app/(settings)/profile/tutorials/[tutorial]/tutorial-page";
import { StudentTableDialogState } from "@/components/tutorial-page";

export default function StudentsColumns(
setDialog: React.Dispatch<React.SetStateAction<StudentTableDialogState>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {Input} from "@/components/ui/input";
import {DataTablePagination} from "@/components/tables/data-table-pagination";
import {DataTableViewOptions} from "@/components/tables/data-table-view-options";
import {User} from "@/lib/gql/generated/graphql";
import {StudentTableDialogState} from "@/app/(settings)/profile/tutorials/[tutorial]/tutorial-page";
import StudentsColumns from "@/app/(settings)/profile/tutorials/[tutorial]/students-columns";
import {StudentTableDialogState} from "@/components/tutorial-page";
import StudentsColumns from "@/components/tables/students-table/students-columns";

interface StudentTableProps {
data: User[];
Expand Down
Loading
Loading