fix: edit booking docs and prefill

This commit is contained in:
Nathnael
2026-06-11 12:32:23 +00:00
parent 103ff53fe0
commit 7c5dfa3ae1
2 changed files with 685 additions and 803 deletions

View File

@@ -2,6 +2,8 @@ import { Controller, type UseFormReturn } from "react-hook-form";
import { Box, Card, Checkbox, SimpleGrid, Text, Textarea, Title } from "@mantine/core";
import {
BookingFormInputValues,
BOOKING_DOCS_SETTING,
type BookingDocuments,
type BookingFormValues,
type RouteDirection,
} from "./schema";
@@ -67,6 +69,13 @@ export function Step8Review({
)
: 0;
const documents = (values.documents ?? {}) as BookingDocuments;
const docsAttached = BOOKING_DOCS_SETTING.fields.filter((f) => {
const value = documents[f.fileKey];
return Array.isArray(value) ? value.length > 0 : Boolean(value);
}).length;
const docsTotal = BOOKING_DOCS_SETTING.fields.length;
const cargoValue =
values.cargoType === "container"
? containerSummary
@@ -206,6 +215,18 @@ export function Step8Review({
target={4}
/>
</ReviewCard>
<ReviewCard title="Documents">
<Row
label="Attached"
value={
docsAttached > 0
? `${docsAttached} of ${docsTotal} attached`
: "None — upload later from the booking page"
}
target={5}
/>
</ReviewCard>
</SimpleGrid>
<Controller