forked from fahrPool/fahrPool
feat: Seite /fahrer, Admin und Disponent sehen die Fahrer-Details
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2cacd33372
commit
abdc4e7f32
|
|
@ -0,0 +1,33 @@
|
|||
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>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import Link from "next/link";
|
||||
import { canManageUsers, kannAuslastungSehen, kannStammdatenPflegen, kannZeiterfassungNutzen, type Role } from "@/lib/auth/roles";
|
||||
import { canManageUsers, kannAuslastungSehen, kannFahrerdetailsSehen,kannStammdatenPflegen, kannZeiterfassungNutzen, type Role } from "@/lib/auth/roles";
|
||||
|
||||
export function NavLinks({
|
||||
role,
|
||||
|
|
@ -32,6 +32,14 @@ export function NavLinks({
|
|||
Auslastung
|
||||
</Link>
|
||||
)}
|
||||
{kannFahrerdetailsSehen(role) && (
|
||||
<Link
|
||||
href="/fahrer"
|
||||
className="flex min-h-11 items-center text-asphalt-grey hover:text-performance-blue focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-performance-blue"
|
||||
>
|
||||
Fahrer
|
||||
</Link>
|
||||
)}
|
||||
{kannZeiterfassungNutzen(role) && (
|
||||
<Link
|
||||
href="/zeiterfassung"
|
||||
|
|
|
|||
Loading…
Reference in New Issue