-
Notifications
You must be signed in to change notification settings - Fork 0
FR: List All Tutorials For Admins #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e03bb1d
4b9c0f5
b473c94
e33371e
97518a5
f4511b7
6316f5d
e6f0833
e2da23b
a981bbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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} /> | ||
</> | ||
); | ||
} |
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> | ||
); | ||
} |
Plebysnacc marked this conversation as resolved.
Show resolved
Hide resolved
|
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> | ||
) | ||
<></> | ||
); | ||
} |
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, | ||
|
@@ -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/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
</> | ||
); | ||
} |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.