diff --git a/dashboard/src/components/ConsultationModal.js b/dashboard/src/components/ConsultationModal.js index 1da18034b..7c1b9e2ab 100644 --- a/dashboard/src/components/ConsultationModal.js +++ b/dashboard/src/components/ConsultationModal.js @@ -455,46 +455,44 @@ function ConsultationContent({ personId, consultation, date, onClose }) { className={['tw-flex tw-h-[50vh] tw-w-full tw-flex-col tw-gap-4 tw-overflow-y-auto', activeTab !== 'Documents' && 'tw-hidden'] .filter(Boolean) .join(' ')}> - {data.person && ( - ({ - ...doc, - type: doc.type ?? 'document', // or 'folder' - linkedItem: { _id: consultation?._id, type: 'consultation' }, - }))} - onAddDocuments={async (nextDocuments) => { - const newData = { - ...data, - documents: [...data.documents, ...nextDocuments], - }; - setData(newData); - const ok = await handleSubmit({ newData }); - if (ok && nextDocuments.length > 1) toast.success('Documents ajoutés'); - }} - onDeleteDocument={async (document) => { - const newData = { ...data, documents: data.documents.filter((d) => d._id !== document._id) }; - setData(newData); - const ok = await handleSubmit({ newData }); - if (ok) toast.success('Document supprimé'); - return ok; - }} - onSubmitDocument={async (document) => { - const newData = { - ...data, - documents: data.documents.map((d) => { - if (d._id === document._id) return document; - return d; - }), - }; - setData(newData); - const ok = await handleSubmit({ newData }); - if (ok) toast.success('Document mis à jour'); - }} - /> - )} + ({ + ...doc, + type: doc.type ?? 'document', // or 'folder' + linkedItem: { _id: consultation?._id, type: 'consultation' }, + }))} + onAddDocuments={async (nextDocuments) => { + const newData = { + ...data, + documents: [...data.documents, ...nextDocuments], + }; + setData(newData); + const ok = await handleSubmit({ newData }); + if (ok && nextDocuments.length > 1) toast.success('Documents ajoutés'); + }} + onDeleteDocument={async (document) => { + const newData = { ...data, documents: data.documents.filter((d) => d._id !== document._id) }; + setData(newData); + const ok = await handleSubmit({ newData }); + if (ok) toast.success('Document supprimé'); + return ok; + }} + onSubmitDocument={async (document) => { + const newData = { + ...data, + documents: data.documents.map((d) => { + if (d._id === document._id) return document; + return d; + }), + }; + setData(newData); + const ok = await handleSubmit({ newData }); + if (ok) toast.success('Document mis à jour'); + }} + />
{ + if (!personId) { + e.preventDefault(); + toast.error('Veuillez sélectionner une personne auparavant'); + return; + } + }} onChange={async (e) => { if (!e.target.files?.length) return; + if (!personId) { + toast.error('Veuillez sélectionner une personne auparavant'); + return; + } const docsResponses = []; for (let i = 0; i < e.target.files.length; i++) { const fileToUpload = e.target.files[i] as any;