From 099ac72563466845b4ab2aaa3e88c295995e8bc1 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 19 Dec 2024 15:54:53 +0100 Subject: [PATCH] - updates to teh flow; --- src/pages/DomandaBeneficiario/index.js | 6 +- .../components/ArchiveDocument/index.js | 33 ++++-- .../components/ListOfFiles/index.js | 31 ++++- src/pages/DomandaEditPreInstructor/index.js | 109 +++++++++++++----- .../components/AllDomandeTable/index.js | 2 +- .../BeneficiarioDomandeTable/index.js | 4 +- src/pages/SoccorsoEditPreInstructor/index.js | 4 +- src/service/appointment-service.js | 10 +- 8 files changed, 142 insertions(+), 57 deletions(-) diff --git a/src/pages/DomandaBeneficiario/index.js b/src/pages/DomandaBeneficiario/index.js index 1eaece3..e03c2d0 100644 --- a/src/pages/DomandaBeneficiario/index.js +++ b/src/pages/DomandaBeneficiario/index.js @@ -134,7 +134,9 @@ const DomandaBeneficiario = () => { }); return acc; }, []); - const newAmendDocs = formValues.amendmentDocuments.map(o => o.id).join(','); + const newAmendDocs = formValues.amendmentDocuments + ? formValues.amendmentDocuments.map(o => o.id).join(',') + : ''; const submitData = { applicationFormFields: newFormValues, @@ -340,7 +342,7 @@ const DomandaBeneficiario = () => { defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []} accept={[]} source="AMENDMENT" - sourceId={data.applicationId} + sourceId={data.id} multiple={true} /> }) : null} diff --git a/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js b/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js index bd72bc8..5a1bb66 100644 --- a/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js +++ b/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js @@ -1,8 +1,14 @@ import React, { useEffect, useRef, useState } from 'react'; import { __ } from '@wordpress/i18n'; -import { isEmpty } from 'ramda'; +import { isEmpty, pathOr, isNil } from 'ramda'; import { wrap } from 'object-path-immutable'; +// store +import AppointmentService from '../../../../service/appointment-service'; + +// tools +import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; + // components import { Button } from 'primereact/button'; import { Dialog } from 'primereact/dialog'; @@ -11,14 +17,11 @@ import { Dropdown } from 'primereact/dropdown'; import { classNames } from 'primereact/utils'; import { InputSwitch } from 'primereact/inputswitch'; import { InputText } from 'primereact/inputtext'; - -import { classificationType, protocolType } from '../../../../configData'; -import AppointmentService from '../../../../service/appointment-service'; -import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; -import { storeSet } from '../../../../store'; import { Toast } from 'primereact/toast'; -const ArchiveDocument = ({ applicationId, ndg = '', fileId = 0, docAttachmentId = null }) => { +import { classificationType, protocolType } from '../../../../configData'; + +const ArchiveDocument = ({ applicationId, ndg = '', fileId = 0, docAttachmentId = null, updateFn = () => {} }) => { const [loading, setLoading] = useState(false); const [isVisibleDialog, setIsVisibleDialog] = useState(false); const [modalData, setModalData] = useState({}); @@ -87,19 +90,29 @@ const ArchiveDocument = ({ applicationId, ndg = '', fileId = 0, docAttachmentId const submitCallback = (data) => { if (data.status === 'SUCCESS') { - console.log(data.data); + if (toast.current && data.message) { + toast.current.show({ + severity: 'success', + summary: '', + detail: data.message + }); + } + const documentAttachmentId = pathOr('fake_id', ['documentAttachmentId'], data.data); + updateFn(documentAttachmentId); } + setIsVisibleDialog(false); setLoading(false); } const errSubmitCallback = (data) => { if (toast.current && data.message) { toast.current.show({ - severity: 'error', + severity: data.status === 'SUCCESS' ? 'info' : 'error', summary: '', detail: data.message }); } + setIsVisibleDialog(false); set404FromErrorResponse(data); setLoading(false); } @@ -119,7 +132,7 @@ const ArchiveDocument = ({ applicationId, ndg = '', fileId = 0, docAttachmentId setTypes(protocolType.map(o => ({ value: o.id, label: o.name }))); }, []); - return (!isEmpty(ndg) && !docAttachmentId + return (!isEmpty(ndg) && !isNil(ndg) && !docAttachmentId ? <>