- added new role;
- added logic of statuses for amendment;
This commit is contained in:
@@ -28,7 +28,6 @@ import FormField from '../../components/FormField';
|
||||
import { Editor } from 'primereact/editor';
|
||||
import { InputNumber } from 'primereact/inputnumber';
|
||||
import SoccorsoComunications from './components/SoccorsoComunications';
|
||||
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
||||
|
||||
|
||||
const SoccorsoEditPreInstructor = () => {
|
||||
@@ -41,6 +40,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
const [extendedTime, setExtendedTime] = useState(3);
|
||||
const [isLoadingExtendingTime, setIsLoadingExtendingTime] = useState(false);
|
||||
const [isLoadingReminding, setIsLoadingReminding] = useState(false);
|
||||
const [internalNote, setInternalNote] = useState('');
|
||||
const toast = useRef(null);
|
||||
const [formInitialData, setFormInitialData] = useState({});
|
||||
const {
|
||||
@@ -125,7 +125,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
const onSubmit = () => {
|
||||
};
|
||||
|
||||
const doUpdateAmendment = () => {
|
||||
const doUpdateAmendment = (doClose = false) => {
|
||||
trigger();
|
||||
let formValues = klona(getValues());
|
||||
const newFormValues = Object.keys(formValues)
|
||||
@@ -148,33 +148,49 @@ const SoccorsoEditPreInstructor = () => {
|
||||
|
||||
const submitData = {
|
||||
applicationFormFields: newFormValues,
|
||||
amendmentDocuments: newAmendDocs
|
||||
amendmentDocuments: newAmendDocs,
|
||||
amendmentNotes: data.amendmentNotes
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
AmendmentsService.updateSoccorso(amendmentId, submitData, updateAmendmentCallback, errUpdateAmendmentCallback);
|
||||
AmendmentsService.updateSoccorso(
|
||||
amendmentId,
|
||||
submitData,
|
||||
(resp) => updateAmendmentCallback(resp, doClose),
|
||||
errUpdateAmendmentCallback
|
||||
);
|
||||
}
|
||||
|
||||
const updateAmendmentCallback = (data) => {
|
||||
const updateAmendmentCallback = (data, doClose = false) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
setData(getFormattedData(data.data));
|
||||
console.log('internalNote', internalNote)
|
||||
if (doClose) {
|
||||
const submitData = {
|
||||
internalNote
|
||||
}
|
||||
return acc;
|
||||
}, formInitialData);
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.data.amendmentDocuments
|
||||
storeSet.main.setAsyncRequest();
|
||||
AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
|
||||
} else {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formInitialData);
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.data.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -214,11 +230,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
}
|
||||
|
||||
const doCloseAmendment = () => {
|
||||
const submitData = {
|
||||
internalNote: data.internalNote
|
||||
}
|
||||
storeSet.main.setAsyncRequest();
|
||||
AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
|
||||
doUpdateAmendment(true);
|
||||
}
|
||||
|
||||
const closeAmendmentCallback = (data) => {
|
||||
@@ -434,7 +446,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
{data.formFields.map((o, i) => {
|
||||
return <FormField
|
||||
key={o.fieldId}
|
||||
disabled={data.status === 'CLOSE'}
|
||||
disabled={data.status === 'CLOSE' || data.status === 'AWAITING'}
|
||||
type="fileupload"
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doUpdateAmendment}
|
||||
@@ -456,16 +468,24 @@ const SoccorsoEditPreInstructor = () => {
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||
<div className="appPageSection">
|
||||
{data.amendmentNotes
|
||||
? <>
|
||||
<h3>{__('Notes', 'gepafin')}</h3>
|
||||
<div className="ql-editor" style={{ marginBottom: '30px', width: '100%' }}>
|
||||
{renderHtmlContent(data.amendmentNotes)}
|
||||
</div>
|
||||
</> : null}
|
||||
<h3>{__('Notes', 'gepafin')}</h3>
|
||||
<div style={{ marginBottom: '30px', width: '100%', position: 'relative' }}>
|
||||
<BlockingOverlay shouldDisplay={data.status === 'CLOSE' || data.status === 'AWAITING'}/>
|
||||
<Editor
|
||||
value={data.amendmentNotes}
|
||||
readOnly={data.status === 'CLOSE' || data.status === 'AWAITING'}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateNewAmendmentData(
|
||||
e.htmlValue,
|
||||
'amendmentNotes'
|
||||
)}
|
||||
style={{ height: 80 * 3, width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
<FormField
|
||||
type="fileupload"
|
||||
disabled={data.status === 'CLOSE'}
|
||||
disabled={data.status === 'CLOSE' || data.status === 'AWAITING'}
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doUpdateAmendment}
|
||||
fieldName="amendmentDocuments"
|
||||
@@ -490,12 +510,6 @@ const SoccorsoEditPreInstructor = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<div className="appPageSection__actions">
|
||||
{/*<Button
|
||||
type="button"
|
||||
disabled={isAsyncRequest}
|
||||
onClick={doUpdateAmendment}
|
||||
label={__('Salva', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>*/}
|
||||
<Button
|
||||
type="button"
|
||||
onClick={sendReminder}
|
||||
@@ -512,12 +526,12 @@ const SoccorsoEditPreInstructor = () => {
|
||||
label={__('Estendi Scadenza', 'gepafin')}
|
||||
icon="pi pi-stopwatch"
|
||||
/>
|
||||
{/*<Button
|
||||
<Button
|
||||
type="button"
|
||||
onClick={doUpdateAmendment}
|
||||
disabled={isAsyncRequest || data.status === 'CLOSE'}
|
||||
onClick={() => doUpdateAmendment()}
|
||||
disabled={isAsyncRequest || data.status === 'CLOSE' || data.status === 'AWAITING'}
|
||||
label={__('Salva bozza', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>*/}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={openCloseAmendmentDialog}
|
||||
@@ -562,14 +576,11 @@ const SoccorsoEditPreInstructor = () => {
|
||||
<div style={{ position: 'relative' }}>
|
||||
<BlockingOverlay shouldDisplay={data.status === 'CLOSE'}/>
|
||||
<Editor
|
||||
value={data.internalNote}
|
||||
value={internalNote}
|
||||
readOnly={data.status === 'CLOSE'}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateNewAmendmentData(
|
||||
e.htmlValue,
|
||||
['internalNote']
|
||||
)}
|
||||
onTextChange={(e) => setInternalNote(e.htmlValue)}
|
||||
style={{ height: 80 * 3, width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user