import { Badge, Divider, Group, Grid, Paper, Stack, Text, Title, } from "@mantine/core"; import { conditionHolds, displayFieldValue, type Attachment, type FormFieldConfig, type FormSectionConfig, type LicenseTypeRequirements, } from "@ema-platform/api"; import { useDateDisplayer } from "@ema-platform/shared"; import { useTranslation } from "react-i18next"; import { DocumentSlots } from "./DocumentSlots"; interface Props { /** Every form section (not just the "review" group) in wizard-step order. */ sections: FormSectionConfig[]; formData: Record>; localized: (value: { en?: string; am?: string } | undefined) => string; config: LicenseTypeRequirements; attachments: Attachment[]; applicationId: string; } /** * Read-only "what was filed" view for a submitted application: every * answered section as a labelled table, then the uploaded documents. * * Shown instead of the wizard once there is nothing left to step through — * the stepper is for filling a form in, not for re-reading one that is * already someone else's decision to make. */ export function ApplicationSummary({ sections, formData, localized, config, attachments, applicationId, }: Props) { const showDate = useDateDisplayer(); const { i18n } = useTranslation(); // Shared with the officer's review screen, so the applicant and the reviewer // never read the same answer two different ways. const display = (field: FormFieldConfig, raw: unknown) => displayFieldValue(field, raw, { language: i18n.language, showDate, currency: config.feeCurrency, }) || "—"; return ( {sections.map((section) => { const fields = (section.fields ?? []).filter((f) => conditionHolds(f.showWhen, formData), ); if (fields.length === 0) return null; return ( {localized(section.title)} {fields.length} {fields.length === 1 ? "detail" : "details"} {localized(section.description) && ( {localized(section.description)} )} {/* Label above value in two columns — a definition list reads far better than a bordered grid when most answers are short. */} {fields.map((field) => { const value = display( field, formData[section.key]?.[field.key], ); const answered = value !== "—"; return ( {localized(field.label)} {answered ? value : "Not provided"} ); })} ); })} Documents { // Read-only here — nothing to react to, but DocumentSlots // requires the callback. }} /> ); }