From 9e98600a5f23eb28d1de2ecb8bb66263430e4854 Mon Sep 17 00:00:00 2001 From: Nathnael Date: Wed, 8 Jul 2026 10:51:22 +0000 Subject: [PATCH] fix: add vat to the settings, and docs to the profile --- .../pages/customers/CustomerDetailPage.tsx | 123 +++++++++++++----- .../src/pages/settings/TabCompanyProfile.tsx | 21 +++ 2 files changed, 112 insertions(+), 32 deletions(-) diff --git a/apps/edr-freight-web/backoffice/src/pages/customers/CustomerDetailPage.tsx b/apps/edr-freight-web/backoffice/src/pages/customers/CustomerDetailPage.tsx index fa7b03be7..c68a4ca25 100644 --- a/apps/edr-freight-web/backoffice/src/pages/customers/CustomerDetailPage.tsx +++ b/apps/edr-freight-web/backoffice/src/pages/customers/CustomerDetailPage.tsx @@ -164,25 +164,85 @@ export default function CustomerDetailPage() { { id: "type", header: "Role", - cell: ({ row }) => , - }, - { - id: "reference", - header: "Reference", cell: ({ row }) => ( - - {row.original.reference} - +
+ + + + {row.original.reference} + +
), }, { - id: "businessLicense", - header: "Business license", - cell: ({ row }) => ( - - {row.original.businessLicense || "—"} - - ), + id: "licenseFiles", + header: "License documents", + cell: ({ row }) => { + const files = row.original.licenseFiles ?? []; + if (files.length === 0) { + return ( + + — + + ); + } + return ( + + {files.map((f) => ( + + + view({ + name: f.name, + url: fileViewUrl(f.id), + mimeType: f.mimeType, + }) + } + > + + + + view({ + name: f.name, + url: fileViewUrl(f.id), + mimeType: f.mimeType, + }) + } + style={{ + maxWidth: 170, + textAlign: "left", + textDecoration: + f.status === "pending_remove" + ? "line-through" + : undefined, + }} + > + {f.name} + + {f.status === "pending_add" && ( + + Pending + + )} + {f.status === "pending_remove" && ( + + Removing + + )} + + ))} + + ); + }, }, { id: "status", @@ -210,7 +270,7 @@ export default function CustomerDetailPage() { ), }, ], - [], + [view], ); const bookingColumns: ColumnDef[] = useMemo( @@ -504,9 +564,8 @@ export default function CustomerDetailPage() { ]} backTo="/dashboard/customers" title={company.name} - subtitle={`TIN ${company.tin}${ - company.country ? ` · ${company.country}` : "" - }`} + subtitle={`TIN ${company.tin}${company.country ? ` · ${company.country}` : "" + }`} meta={ @@ -620,7 +679,7 @@ export default function CustomerDetailPage() { - + void bookingsQuery.refetch(), - } + message: "Failed to load bookings.", + onRetry: () => void bookingsQuery.refetch(), + } : undefined } /> @@ -669,9 +728,9 @@ export default function CustomerDetailPage() { error={ documentsQuery.isError ? { - message: "Failed to load documents.", - onRetry: () => void documentsQuery.refetch(), - } + message: "Failed to load documents.", + onRetry: () => void documentsQuery.refetch(), + } : undefined } /> @@ -750,9 +809,9 @@ export default function CustomerDetailPage() { error={ paymentsQuery.isError ? { - message: "Failed to load payments.", - onRetry: () => void paymentsQuery.refetch(), - } + message: "Failed to load payments.", + onRetry: () => void paymentsQuery.refetch(), + } : undefined } /> @@ -773,9 +832,9 @@ export default function CustomerDetailPage() { error={ invoicesQuery.isError ? { - message: "Failed to load invoices.", - onRetry: () => void invoicesQuery.refetch(), - } + message: "Failed to load invoices.", + onRetry: () => void invoicesQuery.refetch(), + } : undefined } pagination={{ diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx index 995acc104..27011a9d7 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx @@ -34,6 +34,12 @@ export const COMPANY_PROFILE_SCHEMA = z.object({ companyAddress: z.string().min(1, "Address is required"), tinNumber: z.string().length(10, "TIN must be exactly 10 digits"), fanNumber: z.string().length(16, "FAN must be exactly 16 digits"), + vatNumber: z + .string() + .trim() + .max(20, "VAT number is too long") + .optional() + .or(z.literal("")), }); export type CompanyProfileFormData = z.infer; @@ -63,6 +69,7 @@ export default function TabCompanyProfile({ companyAddress: profile.companyAddress ?? "", tinNumber: profile.tinNumber, fanNumber: profile.fanNumber ?? "", + vatNumber: profile.vatNumber ?? "", }; } return { @@ -73,6 +80,7 @@ export default function TabCompanyProfile({ companyAddress: "", tinNumber: "", fanNumber: "", + vatNumber: "", }; }, [profile]); @@ -97,6 +105,7 @@ export default function TabCompanyProfile({ companyAddress: data.companyAddress, tin: data.tinNumber, fanNumber: data.fanNumber, + vatNumber: data.vatNumber ?? "", }; if (isCreate) { @@ -223,6 +232,18 @@ export default function TabCompanyProfile({ /> + + + + + +