diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx index 3ff52286..3a02bd33 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx @@ -28,10 +28,17 @@ export default function ClientView(props: IProps) { const customers: ICustomer[] = useMemo( () => - folder?.customers?.map((customer) => ({ - id: customer.uid ?? "", - ...customer, - })) ?? [], + folder?.customers + ?.map((customer) => ({ + id: customer.uid ?? "", + ...customer, + })) + .sort((a, b) => { + return a.documents && + a.documents.filter((document) => document.document_status === EDocumentStatus.DEPOSITED).length > 0 + ? -1 + : 1; + }) ?? [], [folder], ); @@ -39,17 +46,14 @@ export default function ClientView(props: IProps) { const tabs = useMemo( () => - customers - .map((customer) => ({ - label: `${customer.contact?.first_name} ${customer.contact?.last_name}`, - key: customer.uid, - value: customer, - hasWarning: - customer.documents && - customer.documents.filter((document) => document.document_status === EDocumentStatus.DEPOSITED).length > 0, - })) - // put every tabs that has warning first - .sort((a, b) => (a.hasWarning ? -1 : 1)), + customers.map((customer) => ({ + label: `${customer.contact?.first_name} ${customer.contact?.last_name}`, + key: customer.uid, + value: customer, + hasWarning: + customer.documents && + customer.documents.filter((document) => document.document_status === EDocumentStatus.DEPOSITED).length > 0, + })), [customers], );