- merged with develop;

This commit is contained in:
Vitalii Kiiko
2025-01-03 09:43:15 +01:00
63 changed files with 2966 additions and 415 deletions

View File

@@ -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 }) => {
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 }) => {
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 }) => {
setTypes(protocolType.map(o => ({ value: o.id, label: o.name })));
}, []);
return (!isEmpty(ndg)
return (!isEmpty(ndg) && !isNil(ndg) && !docAttachmentId
? <>
<Toast ref={toast}/>
<Button icon="pi pi-file-export"