Files
glenloch-media/src/app/(app)/training/page.tsx
T
bhursey cb5976edb2
CI / build (push) Has been cancelled
feat(training): rich-text lessons with inline images and 25 MB manuals
Admins were authoring plain-text lessons, which made illustrated tutorials
and reordering images impossible. Lesson bodies are now sanitized HTML from a
Tiptap editor with alignment, sizing, drag-reorder and alt text, and inline
images reuse the training_resources table so no migration is needed.
Attachments grow to 25 MB, PDFs stream inline, and SVG is rejected because it
can execute as a document. Legacy plain-text bodies are normalized on read.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-20 12:18:24 +00:00

108 lines
4.6 KiB
TypeScript

import Link from "next/link";
import { auth } from "@/auth/config";
import { hasPermission } from "@/auth/permissions";
import type { SystemRole } from "@/auth/roles";
import { listLessons } from "@/db/training";
import { trainingBodyToHtml } from "@/lib/rich-text";
import { TrainingPanel } from "@/components/app/training-panel";
import { BookOpenCheck, Download, ShieldCheck, UserRound } from "lucide-react";
export const metadata = { title: "Training" };
/**
* Training content. Volunteers see published lessons and attachments; admins
* can author, publish, upload, and delete. Content is stored in Postgres and
* attachments under the uploads volume, so it is editable with no deploy.
*/
export default async function TrainingPage() {
const session = await auth();
const role = (session?.user as { systemRole?: SystemRole } | undefined)?.systemRole;
const canEdit = hasPermission(role, "training.author");
const lessons = (await listLessons({ includeUnpublished: canEdit })).map(
(lesson) => ({
...lesson,
body: trainingBodyToHtml(lesson.body),
}),
);
return (
<div className="space-y-4">
<div>
<h1 className="text-lg font-semibold tracking-tight">Training</h1>
<p className="text-sm text-muted-foreground">
How-tos and checklists for serving on the media team.
</p>
</div>
<section aria-labelledby="full-guides" className="space-y-3">
<div>
<h2 id="full-guides" className="text-base font-semibold tracking-tight">
Full guides
</h2>
<p className="text-sm text-muted-foreground">
Complete, illustrated walkthroughs with screenshots. Read them here
or download the PDF for printing and offline use.
</p>
</div>
<div className="grid gap-3 md:grid-cols-2">
<div className="flex flex-col rounded-md border border-border p-4">
<div className="flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
<ShieldCheck className="h-4 w-4" aria-hidden="true" />
Admins
</div>
<h3 className="mt-2 text-base font-semibold">
Platform administration guide
</h3>
<p className="mt-1 flex-1 text-sm leading-6 text-muted-foreground">
People and access, skill verification, positions, services and
publishing, coverage, run sheets, email, notifications, backups,
and exports.
</p>
<div className="mt-3 flex flex-wrap items-center gap-4 text-sm font-medium">
<Link href="/training/guides/admin" className="text-primary underline">
<BookOpenCheck className="mr-1 inline h-4 w-4" aria-hidden="true" />
Read the guide
</Link>
<a
href="/training/media-team-admin-guide.pdf"
download
className="inline-flex items-center gap-1 text-primary underline"
>
<Download className="h-4 w-4" aria-hidden="true" />
Download PDF
</a>
</div>
</div>
<div className="flex flex-col rounded-md border border-border p-4">
<div className="flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
<UserRound className="h-4 w-4" aria-hidden="true" />
Volunteers &amp; trainees
</div>
<h3 className="mt-2 text-base font-semibold">Volunteer guide</h3>
<p className="mt-1 flex-1 text-sm leading-6 text-muted-foreground">
Signing in, your next serve, the schedule, availability, swaps,
run sheets, events and media, training, profile, and reminders.
</p>
<div className="mt-3 flex flex-wrap items-center gap-4 text-sm font-medium">
<Link href="/training/guides/user" className="text-primary underline">
<BookOpenCheck className="mr-1 inline h-4 w-4" aria-hidden="true" />
Read the guide
</Link>
<a
href="/training/media-team-user-guide.pdf"
download
className="inline-flex items-center gap-1 text-primary underline"
>
<Download className="h-4 w-4" aria-hidden="true" />
Download PDF
</a>
</div>
</div>
</div>
</section>
<TrainingPanel lessons={lessons} canEdit={canEdit} />
</div>
);
}