1
0
Fork 0

feat: Lesbare Foto-Bezeichnungen, Kamera direkt beim Fahrtbeginn, Ziffern-Tastatur fuer KM, Leerzustand mit Anlegen-Link

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jonny 2026-11-02 17:23:10 +01:00
parent e490bc6142
commit 1f9b22559f
7 changed files with 73 additions and 22 deletions

View File

@ -7,7 +7,7 @@ import { istEinsatzrolle, kannAuftraegeVerwalten, personBezeichnung } from "@/li
import { listEinsatzPersonen } from "@/lib/dashboard/queries"; import { listEinsatzPersonen } from "@/lib/dashboard/queries";
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung"; import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
import { finAbgleichText } from "@/lib/auftraege/fin-abgleich"; import { finAbgleichText } from "@/lib/auftraege/fin-abgleich";
import { STANDARD_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen"; import { fotoBezeichnung, STANDARD_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
import { loadAuftragFotos, loadUnterschriftUrl } from "@/lib/auftraege/fotos"; import { loadAuftragFotos, loadUnterschriftUrl } from "@/lib/auftraege/fotos";
import { FinFeld } from "@/components/fahrzeuge/FinFeld"; import { FinFeld } from "@/components/fahrzeuge/FinFeld";
import { FotoGalerie } from "@/components/auftraege/FotoGalerie"; import { FotoGalerie } from "@/components/auftraege/FotoGalerie";
@ -277,7 +277,7 @@ export default async function AuftragDetailPage({
<NetzSicheresFormular action={fahrtBeginnenAction}> <NetzSicheresFormular action={fahrtBeginnenAction}>
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beginnen</h2> <h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beginnen</h2>
<FormField label="KM-Stand" htmlFor="start_km"> <FormField label="KM-Stand" htmlFor="start_km">
<input id="start_km" name="start_km" type="number" min="0" required className={FIELD_CLASSES} /> <input id="start_km" name="start_km" type="number" inputMode="numeric" min="0" required className={FIELD_CLASSES} />
</FormField> </FormField>
{auftrag.start_fin_status === "abweichend" ? ( {auftrag.start_fin_status === "abweichend" ? (
<div <div
@ -294,21 +294,21 @@ export default async function AuftragDetailPage({
vergleichsFin={auftrag.fahrzeug.fin} vergleichsFin={auftrag.fahrzeug.fin}
/> />
)} )}
<h3 className="mb-2 font-medium text-asphalt-grey">Fahrzeugfotos (optional)</h3>
<div className="grid grid-cols-1 gap-x-4 sm:grid-cols-2">
{STANDARD_FOTO_POSITIONEN.map((position) => ( {STANDARD_FOTO_POSITIONEN.map((position) => (
<FormField <FormField key={position} label={fotoBezeichnung(position)} htmlFor={`foto_${position}`}>
key={position}
label={`${position.replaceAll("_", " ")} (optional)`}
htmlFor={`foto_${position}`}
>
<input <input
id={`foto_${position}`} id={`foto_${position}`}
name={`foto_${position}`} name={`foto_${position}`}
type="file" type="file"
accept="image/*" accept="image/*"
capture="environment"
className={FIELD_CLASSES} className={FIELD_CLASSES}
/> />
</FormField> </FormField>
))} ))}
</div>
<SchadenFotoFelder /> <SchadenFotoFelder />
<Button type="submit">Fahrt beginnen</Button> <Button type="submit">Fahrt beginnen</Button>
</NetzSicheresFormular> </NetzSicheresFormular>
@ -320,7 +320,7 @@ export default async function AuftragDetailPage({
<NetzSicheresFormular action={fahrtBeendenAction}> <NetzSicheresFormular action={fahrtBeendenAction}>
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beenden</h2> <h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beenden</h2>
<FormField label="End-KM-Stand" htmlFor="end_km"> <FormField label="End-KM-Stand" htmlFor="end_km">
<input id="end_km" name="end_km" type="number" min="0" required className={FIELD_CLASSES} /> <input id="end_km" name="end_km" type="number" inputMode="numeric" min="0" required className={FIELD_CLASSES} />
</FormField> </FormField>
<FormField label="Empfänger (optional)" htmlFor="empfaenger_name"> <FormField label="Empfänger (optional)" htmlFor="empfaenger_name">
<input <input

View File

@ -48,7 +48,12 @@ export default async function AuftraegePage({
) : ( ) : (
<> <>
{kannAnlegen && meine.length > 0 && <AuftragListe titel="Meine Aufträge" auftraege={meine} filter={filter} />} {kannAnlegen && meine.length > 0 && <AuftragListe titel="Meine Aufträge" auftraege={meine} filter={filter} />}
<AuftragListe titel={filter === "aktiv" ? "Aktive Aufträge" : "Alle Aufträge"} auftraege={alle} filter={filter} /> <AuftragListe
titel={filter === "aktiv" ? "Aktive Aufträge" : "Alle Aufträge"}
auftraege={alle}
filter={filter}
anlegenLink={kannAnlegen}
/>
</> </>
)} )}
</div> </div>

View File

@ -10,10 +10,12 @@ export function AuftragListe({
titel, titel,
auftraege, auftraege,
filter, filter,
anlegenLink = false,
}: { }: {
titel: string; titel: string;
auftraege: Auftrag[]; auftraege: Auftrag[];
filter?: StatusFilter; filter?: StatusFilter;
anlegenLink?: boolean;
}) { }) {
return ( return (
<section className="mb-8"> <section className="mb-8">
@ -30,6 +32,14 @@ export function AuftragListe({
) : ( ) : (
"Keine Aufträge." "Keine Aufträge."
)} )}
{anlegenLink && (
<>
{" "}
<Link href="/auftraege/neu" className="text-performance-blue underline">
Neuen Auftrag anlegen
</Link>
</>
)}
</p> </p>
) : ( ) : (
<ul className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3"> <ul className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3">

View File

@ -0,0 +1,20 @@
import { describe, expect, it } from "vitest";
import { fotoBezeichnung, STANDARD_FOTO_POSITIONEN } from "./foto-positionen";
describe("fotoBezeichnung", () => {
it("liefert lesbare Namen fuer alle Standardpositionen", () => {
expect(STANDARD_FOTO_POSITIONEN.map(fotoBezeichnung)).toEqual([
"Front",
"Seitlich rechts",
"Rechte Seite",
"Seitlich rechts Heck",
"Heck",
"Seitlich links Heck",
"Linke Seite",
"Seitlich vorne links",
]);
});
it("faellt bei unbekannten Positionen auf den Rohwert zurueck", () => {
expect(fotoBezeichnung("dach_hinten")).toBe("dach hinten");
});
});

View File

@ -10,3 +10,19 @@ export const STANDARD_FOTO_POSITIONEN = [
] as const; ] as const;
export type StandardFotoPosition = (typeof STANDARD_FOTO_POSITIONEN)[number]; export type StandardFotoPosition = (typeof STANDARD_FOTO_POSITIONEN)[number];
// Lesbare Bezeichnungen (Wortlaut der Anforderungen in CLAUDE.md).
export const FOTO_BEZEICHNUNGEN: Record<StandardFotoPosition, string> = {
front: "Front",
seitlich_rechts: "Seitlich rechts",
rechte_seite: "Rechte Seite",
seitlich_rechts_heck: "Seitlich rechts Heck",
heck: "Heck",
seitlich_links_heck: "Seitlich links Heck",
linke_seite: "Linke Seite",
seitlich_vorne_links: "Seitlich vorne links",
};
export function fotoBezeichnung(position: string): string {
return FOTO_BEZEICHNUNGEN[position as StandardFotoPosition] ?? position.replaceAll("_", " ");
}

View File

@ -16,7 +16,7 @@ describe("sortiereUndBeschrifteFotos", () => {
{ position: "seitlich_rechts", storage_path: "a/seitlich_rechts.jpg", uploaded_at: "2026-01-01T09:00:00Z", beschreibung: null }, { position: "seitlich_rechts", storage_path: "a/seitlich_rechts.jpg", uploaded_at: "2026-01-01T09:00:00Z", beschreibung: null },
]; ];
const result = sortiereUndBeschrifteFotos(fotos); const result = sortiereUndBeschrifteFotos(fotos);
expect(result[0].label).toBe("seitlich rechts"); expect(result[0].label).toBe("Seitlich rechts");
}); });
it("laesst fehlende Pflicht-Positionen einfach weg", () => { it("laesst fehlende Pflicht-Positionen einfach weg", () => {

View File

@ -1,6 +1,6 @@
import type { SupabaseClient } from "@supabase/supabase-js"; import type { SupabaseClient } from "@supabase/supabase-js";
import { createClient } from "@/lib/supabase/server"; import { createClient } from "@/lib/supabase/server";
import { STANDARD_FOTO_POSITIONEN } from "./foto-positionen"; import { STANDARD_FOTO_POSITIONEN, fotoBezeichnung } from "./foto-positionen";
import type { ProtokollFoto } from "./protokoll"; import type { ProtokollFoto } from "./protokoll";
export type AuftragFoto = { export type AuftragFoto = {
@ -29,7 +29,7 @@ export function sortiereUndBeschrifteFotos(fotos: FotoZeile[]): (FotoZeile & { l
const beschriftetePflichtFotos = pflichtFotos.map((foto) => ({ const beschriftetePflichtFotos = pflichtFotos.map((foto) => ({
...foto, ...foto,
label: foto.position.replaceAll("_", " "), label: fotoBezeichnung(foto.position),
})); }));
const beschrifteteSchadenFotos = schadenFotos.map((foto, index) => ({ const beschrifteteSchadenFotos = schadenFotos.map((foto, index) => ({