forked from fahrPool/fahrPool
feat: remove required attribute from Fahrtbeginn photo fields
Photos are now optional when a driver starts a trip: the 8 vehicle photo fields remain in the form but no longer carry the required attribute, are labeled "(optional)", and validateFahrtBeginn no longer checks for missing positions. Combined with the DB trigger fix in 9f410cb/eaa5faa, a trip can now begin with zero, some, or all photos uploaded. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HCHRPWuV3bd37NJhW2NK6P
This commit is contained in:
parent
eaa5faad7b
commit
e9c7827611
|
|
@ -3,7 +3,7 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import { createClient } from "@/lib/supabase/server";
|
||||
import { validateFahrtBeginn, validateFahrtEnde } from "@/lib/auftraege/validate-fahrt";
|
||||
import { PFLICHT_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
||||
import { STANDARD_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
||||
import { loadProfile } from "@/lib/auth/profile";
|
||||
|
||||
export async function uebernehmen(auftragId: string): Promise<void> {
|
||||
|
|
@ -45,7 +45,7 @@ export async function fahrtBeginnen(auftragId: string, formData: FormData): Prom
|
|||
}
|
||||
|
||||
const uploads: { position: string; file: File }[] = [];
|
||||
for (const position of PFLICHT_FOTO_POSITIONEN) {
|
||||
for (const position of STANDARD_FOTO_POSITIONEN) {
|
||||
const file = formData.get(`foto_${position}`);
|
||||
if (file instanceof File && file.size > 0) {
|
||||
uploads.push({ position, file });
|
||||
|
|
@ -55,7 +55,6 @@ export async function fahrtBeginnen(auftragId: string, formData: FormData): Prom
|
|||
|
||||
const validation = validateFahrtBeginn({
|
||||
startKm: formData.get("start_km"),
|
||||
vorhandenePositionen: uploads.map((u) => u.position),
|
||||
});
|
||||
|
||||
if (!validation.valid) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { notFound } from "next/navigation";
|
|||
import Link from "next/link";
|
||||
import { loadAuftrag, findeFolgeauftrag } from "@/lib/auftraege/queries";
|
||||
import { loadProfile } from "@/lib/auth/profile";
|
||||
import { PFLICHT_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
||||
import { STANDARD_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
||||
import { loadAuftragFotos } from "@/lib/auftraege/fotos";
|
||||
import { FotoGalerie } from "@/components/auftraege/FotoGalerie";
|
||||
import { uebernehmen, fahrtBeginnen, schadenFotoNachtragen, fahrtBeenden, stornieren } from "./actions";
|
||||
|
|
@ -106,14 +106,17 @@ export default async function AuftragDetailPage({
|
|||
<FormField label="KM-Stand" htmlFor="start_km">
|
||||
<input id="start_km" name="start_km" type="number" min="0" required className={FIELD_CLASSES} />
|
||||
</FormField>
|
||||
{PFLICHT_FOTO_POSITIONEN.map((position) => (
|
||||
<FormField key={position} label={position.replaceAll("_", " ")} htmlFor={`foto_${position}`}>
|
||||
{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/*"
|
||||
required
|
||||
className={FIELD_CLASSES}
|
||||
/>
|
||||
</FormField>
|
||||
|
|
|
|||
Loading…
Reference in New Issue