forked from fahrPool/fahrPool
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { loadProfile } from "@/lib/auth/profile";
|
|
import { kannFahrerdetailsSehen } from "@/lib/auth/roles";
|
|
import { listFahrerMitDetails } from "@/lib/nutzerverwaltung/details-queries";
|
|
import { DetailsZusammenfassung } from "@/components/nutzerverwaltung/DetailsZusammenfassung";
|
|
import { Card } from "@/components/ui/Card";
|
|
|
|
export default async function FahrerPage() {
|
|
const profileResult = await loadProfile();
|
|
if (profileResult.status !== "ok" || !kannFahrerdetailsSehen(profileResult.profile.role)) {
|
|
redirect(`/auftraege?error=${encodeURIComponent("Nur Admin und Disponent dürfen die Fahrerdaten sehen.")}`);
|
|
}
|
|
|
|
const fahrer = await listFahrerMitDetails();
|
|
|
|
return (
|
|
<div className="mx-auto max-w-4xl p-4 md:p-8">
|
|
<h1 className="mb-6 text-xl font-semibold text-asphalt-grey">Fahrer</h1>
|
|
{fahrer.length === 0 ? (
|
|
<p className="text-asphalt-grey">Keine Fahrer angelegt.</p>
|
|
) : (
|
|
<div className="grid gap-3 md:grid-cols-2">
|
|
{fahrer.map((eintrag) => (
|
|
<Card key={eintrag.id}>
|
|
<h2 className="mb-2 font-semibold text-asphalt-grey">{eintrag.name}</h2>
|
|
<DetailsZusammenfassung details={eintrag.details} />
|
|
</Card>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|