- fixed flow of submitting application;
This commit is contained in:
@@ -4,7 +4,6 @@ import { useParams } from 'react-router-dom';
|
||||
import { head, is, pluck, isEmpty, pathOr } from 'ramda';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { TZDate } from '@date-fns/tz';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, storeGet, useStore } from '../../store';
|
||||
@@ -86,7 +85,7 @@ const BandoApplication = () => {
|
||||
const activeStepIndex = activeStep - 1;
|
||||
const values = getValues();
|
||||
|
||||
const onSubmit = () => {
|
||||
const onValidate = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
formMsgs.current.clear();
|
||||
@@ -94,6 +93,70 @@ const BandoApplication = () => {
|
||||
ApplicationService.validateApplication(applId, {}, validateApplicationCallback, errValidateApplicationCallback);
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.updateStatusApplication(applId, {}, submitApplicationCallback, errSubmitApplicationCallback, [
|
||||
['status', 'SUBMIT']
|
||||
]);
|
||||
};
|
||||
|
||||
const submitApplicationCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (data.data.status) {
|
||||
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'?
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errSubmitApplicationCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
{
|
||||
id: '99',
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.data.join(', '),
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else if (data.status === 'EXCEPTION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
{
|
||||
id: '99',
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else if (data.status === 'BAD_REQUEST') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
{
|
||||
id: '99',
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
} else {
|
||||
set404FromErrorResponse(data);
|
||||
}
|
||||
}
|
||||
|
||||
const validateApplicationCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (data.data.status) {
|
||||
@@ -383,13 +446,19 @@ const BandoApplication = () => {
|
||||
|
||||
const handleSetSignedDocumentFromFileupload = (fieldName, stateFieldData) => {
|
||||
setSignedPdfFile(stateFieldData);
|
||||
if (!isEmpty(stateFieldData)) {
|
||||
setApplicationStatus('READY');
|
||||
|
||||
/*if (!isEmpty(stateFieldData)) {
|
||||
setVisibleConfirmation(true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if ('SUBMIT' === applicationStatus) {
|
||||
setVisibleConfirmation(true);
|
||||
}
|
||||
|
||||
if (['AWAIT', 'READY', 'SUBMIT'].includes(applicationStatus)) {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
@@ -451,13 +520,14 @@ const BandoApplication = () => {
|
||||
|
||||
<div className="appPage__content">
|
||||
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
<form className="appForm" onSubmit={handleSubmit(onValidate)}>
|
||||
{'DRAFT' === applicationStatus
|
||||
? <div className="appPageSection">
|
||||
{actionBtns}
|
||||
</div> : null}
|
||||
|
||||
{'DRAFT' === applicationStatus
|
||||
/*|| 'AWAIT' === applicationStatus*/
|
||||
? formData.map(o => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
@@ -518,7 +588,7 @@ const BandoApplication = () => {
|
||||
})
|
||||
: null}
|
||||
|
||||
{'AWAIT' === applicationStatus
|
||||
{['AWAIT', 'READY', 'SUBMIT', 'EVALUATION'].includes(applicationStatus)
|
||||
? <div className="appPageSection">
|
||||
<div className="appForm__field">
|
||||
<label>
|
||||
@@ -534,7 +604,7 @@ const BandoApplication = () => {
|
||||
iconPos="right"/>
|
||||
</div> : null}
|
||||
|
||||
{'AWAIT' === applicationStatus
|
||||
{['AWAIT', 'READY', 'SUBMIT', 'EVALUATION'].includes(applicationStatus)
|
||||
? <div className="appPageSection">
|
||||
<div className="appForm__field">
|
||||
<label htmlFor="signedPdfFile">
|
||||
@@ -545,7 +615,7 @@ const BandoApplication = () => {
|
||||
<FileuploadApplicationSignedPdf
|
||||
setDataFn={handleSetSignedDocumentFromFileupload}
|
||||
fieldName="signedPdfFile"
|
||||
disabled={is(Array, signedPdfFile) ? !isEmpty(signedPdfFile) : false}
|
||||
disabled={['READY', 'SUBMIT', 'EVALUATION'].includes(applicationStatus)}
|
||||
defaultValue={is(Array, signedPdfFile) ? signedPdfFile : []}
|
||||
accept={['.p7m,application/pkcs7-mime,application/x-pkcs7-mime,.zip']}
|
||||
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
||||
@@ -557,6 +627,16 @@ const BandoApplication = () => {
|
||||
</div>
|
||||
: null}
|
||||
|
||||
<div className="appPageSection">
|
||||
<Button
|
||||
type="button"
|
||||
disabled={'READY' !== applicationStatus}
|
||||
onClick={onSubmit}
|
||||
label={__('Invia', 'gepafin')}
|
||||
icon="pi pi-download"
|
||||
iconPos="right"/>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
{'DRAFT' === applicationStatus
|
||||
|
||||
@@ -6,7 +6,7 @@ import { is, uniq } from 'ramda';
|
||||
//import { storeSet, storeGet } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
//import ApplicationService from '../../../../service/application-service';
|
||||
|
||||
// components
|
||||
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
||||
@@ -18,9 +18,12 @@ import { InputIcon } from 'primereact/inputicon';
|
||||
import { Button } from 'primereact/button';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import AssignedApplicationService from '../../../../service/assigned-application-service';
|
||||
import { useStore } from '../../../../store';
|
||||
|
||||
|
||||
const MyEvaluationsTable = () => {
|
||||
const userData = useStore().main.userData();
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
@@ -29,7 +32,7 @@ const MyEvaluationsTable = () => {
|
||||
|
||||
useEffect(() => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.getApplications(getCallback, errGetCallbacks, [['status', 'ASSIGNED']]);
|
||||
AssignedApplicationService.getAssignedApplications(getCallback, errGetCallbacks, [['userId', userData.id]]);
|
||||
}, []);
|
||||
|
||||
const getCallback = (data) => {
|
||||
|
||||
Reference in New Issue
Block a user