import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { erfordereBenutzer } from '@/lib/auth/rechte'; import { inhalte } from '@/lib/inhalte'; import { verlinkeGlossar } from '@/lib/inhalte/glossarverweise'; import { gelesenAm } from '@/lib/repos/fortschritt'; import { alsZeitpunktText } from '@/lib/zeit'; import { gelesenUmschalten } from './aktionen'; import { Druckknopf } from '@/komponenten/Druckknopf'; export const dynamic = 'force-dynamic'; export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise { const { id } = await params; const handout = inhalte().handoutNach.get(id.toUpperCase()); return { title: handout ? `${handout.id} – ${handout.titel}` : 'Handout' }; } export default async function HandoutSeite({ params }: { params: Promise<{ id: string }> }) { const benutzer = await erfordereBenutzer(); const { id } = await params; const alle = inhalte(); const handout = alle.handoutNach.get(id.toUpperCase()); if (!handout) notFound(); const block = alle.blockNach.get(handout.block); const lernfeld = alle.lernfeldNach.get(handout.lernfeld); const positionen = handout.rahmenplan.map((p) => alle.positionNach.get(p)).filter((p) => p !== undefined); const woche = alle.wocheNach.get(handout.woche); const istAzubi = benutzer.rolle === 'azubi'; const gelesen = istAzubi ? gelesenAm(benutzer.id, handout.id) : null; const desBlocks = alle.handoutsNachBlock.get(handout.block) ?? []; const stelle = desBlocks.findIndex((h) => h.id === handout.id); const vorher = stelle > 0 ? desBlocks[stelle - 1] : undefined; const nachher = stelle < desBlocks.length - 1 ? desBlocks[stelle + 1] : undefined; const wesentlichHtml = handout.wesentlich ? verlinkeGlossar(handout.wesentlich.html, alle.glossar) : ''; return (
{handout.id} {gelesen ? ( ✓ gelesen am {alsZeitpunktText(gelesen)} ) : null}

{handout.titel}

{handout.worum}

Ausbildungsrahmenplan
{positionen.length === 0 ? '–' : positionen.map((p) => ( {p.id} {p.kurz} ))}
Lernfeld
{lernfeld ? ( {lernfeld.id} {lernfeld.titel} ) : ( '–' )}
Woche
{woche ? ( {woche.nummer} {woche.titel} ) : ( '–' )}
{handout.wesentlich ? (

Das Wesentliche

) : null} {handout.uebersicht ? (

Übersicht

) : null} {handout.pruefungsfrage ? (
Prüfungsfrage anzeigen
) : null}

Merkkarten zu diesem Handout

{handout.karten.length === 1 ? 'Eine Karte' : `${handout.karten.length} Karten`} – im Lernmodus tauchen sie nach Fälligkeit auf.

    {handout.karten.map((karte, index) => (
  1. {karte.frage}
    {karte.antwort}
  2. ))}
{istAzubi ? (
) : null}

Quelle: {handout.datei}

); }