import { Document, Page, Text, View, Image, StyleSheet } from "@react-pdf/renderer"; import type { ProtokollProps } from "./protokoll"; const styles = StyleSheet.create({ page: { padding: 32, fontSize: 11 }, kopf: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginBottom: 12 }, logo: { height: 32, maxWidth: 160, objectFit: "contain" }, firmenname: { fontSize: 10 }, h1: { fontSize: 16, marginBottom: 12, fontWeight: 700 }, row: { flexDirection: "row", justifyContent: "space-between", marginBottom: 4 }, fotoGrid: { flexDirection: "row", flexWrap: "wrap", gap: 8, marginTop: 12 }, foto: { width: 120, marginBottom: 8 }, fotoImg: { width: 120, height: 90, objectFit: "cover" }, fotoLabel: { fontSize: 9, marginTop: 2 }, unterschrift: { width: 200, height: 80, marginTop: 8, borderWidth: 1, borderColor: "#ccc" }, }); function formatDatum(iso: string | null): string { if (iso === null) { return "-"; } return new Intl.DateTimeFormat("de-DE", { dateStyle: "medium", timeStyle: "short" }).format(new Date(iso)); } export function ProtokollDocument({ props }: { props: ProtokollProps }) { return ( {props.firma.logo ? ( ) : ( {props.firma.name} )} {props.firma.logo && {props.firma.name}} Übergabeprotokoll {props.auftragsnummer} Fahrzeug {props.fahrzeug} {props.fahrzeugFin && ( FIN {props.fahrzeugFin} )} {props.finAbgleich && ( FIN-Abgleich bei Fahrtbeginn {props.finAbgleich} )} Abholort {props.abholort.adresse} ({props.abholort.ansprechpartner}) Zielort {props.zielort.adresse} ({props.zielort.ansprechpartner}) Fahrer {props.fahrerName ?? "-"} Startzeit {formatDatum(props.startZeit)} Start-KM {props.startKm ?? "-"} End-KM {props.endKm ?? "-"} Übergabe bestätigt {formatDatum(props.uebergabeBestaetigtAt)} Empfänger {props.empfaengerName ?? "-"} {props.fotos.length > 0 && ( {props.fotos.map((foto, index) => ( {foto.label} {foto.beschreibung ? `: ${foto.beschreibung}` : ""} ))} )} {props.unterschriftBuffer && ( <> Unterschrift )} ); }