forked from fahrPool/fahrPool
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:
parent
e490bc6142
commit
1f9b22559f
|
|
@ -7,7 +7,7 @@ import { istEinsatzrolle, kannAuftraegeVerwalten, personBezeichnung } from "@/li
|
|||
import { listEinsatzPersonen } from "@/lib/dashboard/queries";
|
||||
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||
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 { FinFeld } from "@/components/fahrzeuge/FinFeld";
|
||||
import { FotoGalerie } from "@/components/auftraege/FotoGalerie";
|
||||
|
|
@ -277,7 +277,7 @@ export default async function AuftragDetailPage({
|
|||
<NetzSicheresFormular action={fahrtBeginnenAction}>
|
||||
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beginnen</h2>
|
||||
<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>
|
||||
{auftrag.start_fin_status === "abweichend" ? (
|
||||
<div
|
||||
|
|
@ -294,21 +294,21 @@ export default async function AuftragDetailPage({
|
|||
vergleichsFin={auftrag.fahrzeug.fin}
|
||||
/>
|
||||
)}
|
||||
{STANDARD_FOTO_POSITIONEN.map((position) => (
|
||||
<FormField
|
||||
key={position}
|
||||
label={`${position.replaceAll("_", " ")} (optional)`}
|
||||
htmlFor={`foto_${position}`}
|
||||
>
|
||||
<input
|
||||
id={`foto_${position}`}
|
||||
name={`foto_${position}`}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
className={FIELD_CLASSES}
|
||||
/>
|
||||
</FormField>
|
||||
))}
|
||||
<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) => (
|
||||
<FormField key={position} label={fotoBezeichnung(position)} htmlFor={`foto_${position}`}>
|
||||
<input
|
||||
id={`foto_${position}`}
|
||||
name={`foto_${position}`}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
className={FIELD_CLASSES}
|
||||
/>
|
||||
</FormField>
|
||||
))}
|
||||
</div>
|
||||
<SchadenFotoFelder />
|
||||
<Button type="submit">Fahrt beginnen</Button>
|
||||
</NetzSicheresFormular>
|
||||
|
|
@ -320,7 +320,7 @@ export default async function AuftragDetailPage({
|
|||
<NetzSicheresFormular action={fahrtBeendenAction}>
|
||||
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beenden</h2>
|
||||
<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 label="Empfänger (optional)" htmlFor="empfaenger_name">
|
||||
<input
|
||||
|
|
|
|||
|
|
@ -48,7 +48,12 @@ export default async function AuftraegePage({
|
|||
) : (
|
||||
<>
|
||||
{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>
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ export function AuftragListe({
|
|||
titel,
|
||||
auftraege,
|
||||
filter,
|
||||
anlegenLink = false,
|
||||
}: {
|
||||
titel: string;
|
||||
auftraege: Auftrag[];
|
||||
filter?: StatusFilter;
|
||||
anlegenLink?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<section className="mb-8">
|
||||
|
|
@ -30,6 +32,14 @@ export function AuftragListe({
|
|||
) : (
|
||||
"Keine Aufträge."
|
||||
)}
|
||||
{anlegenLink && (
|
||||
<>
|
||||
{" "}
|
||||
<Link href="/auftraege/neu" className="text-performance-blue underline">
|
||||
Neuen Auftrag anlegen
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
@ -10,3 +10,19 @@ export const STANDARD_FOTO_POSITIONEN = [
|
|||
] as const;
|
||||
|
||||
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("_", " ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe("sortiereUndBeschrifteFotos", () => {
|
|||
{ position: "seitlich_rechts", storage_path: "a/seitlich_rechts.jpg", uploaded_at: "2026-01-01T09:00:00Z", beschreibung: null },
|
||||
];
|
||||
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", () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
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";
|
||||
|
||||
export type AuftragFoto = {
|
||||
|
|
@ -29,7 +29,7 @@ export function sortiereUndBeschrifteFotos(fotos: FotoZeile[]): (FotoZeile & { l
|
|||
|
||||
const beschriftetePflichtFotos = pflichtFotos.map((foto) => ({
|
||||
...foto,
|
||||
label: foto.position.replaceAll("_", " "),
|
||||
label: fotoBezeichnung(foto.position),
|
||||
}));
|
||||
|
||||
const beschrifteteSchadenFotos = schadenFotos.map((foto, index) => ({
|
||||
|
|
|
|||
Loading…
Reference in New Issue