55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import Link from "next/link";
|
||
import { prisma } from "@/lib/prisma";
|
||
import { requireSession } from "@/lib/session-helpers";
|
||
|
||
export default async function PortalCertificatesPage() {
|
||
const session = await requireSession();
|
||
|
||
const rows = await prisma.certificate.findMany({
|
||
where: { userId: session.user.id },
|
||
orderBy: { issuedAt: "desc" },
|
||
include: { course: { select: { title: true, slug: true } } },
|
||
});
|
||
|
||
return (
|
||
<div>
|
||
<h1 className="page-title">Zertifikate</h1>
|
||
<p className="muted subtitle">Teilnahmebestätigungen nach vollständigem Kursabschluss.</p>
|
||
|
||
{rows.length === 0 ? (
|
||
<div className="panel">
|
||
<p className="muted">Noch keine Zertifikate – schließe zuerst alle Lektionen eines Kurses ab.</p>
|
||
<Link href="/portal" className="btn btn-primary">
|
||
Zu deinen Kursen
|
||
</Link>
|
||
</div>
|
||
) : (
|
||
<div className="table-wrap">
|
||
<table className="simple">
|
||
<thead>
|
||
<tr>
|
||
<th>Kurs</th>
|
||
<th>Ausgestellt</th>
|
||
<th>Code</th>
|
||
<th />
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{rows.map((r) => (
|
||
<tr key={r.id}>
|
||
<td>{r.course.title}</td>
|
||
<td className="muted">{r.issuedAt.toLocaleDateString("de-DE")}</td>
|
||
<td className="muted">{r.code}</td>
|
||
<td>
|
||
<Link href={`/zertifikat/${r.code}`}>Ansehen / Drucken</Link>
|
||
</td>
|
||
</tr>
|
||
))}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|