- updated zustand and react libraries;
- added 'put in draft' btn;
This commit is contained in:
@@ -10,7 +10,7 @@ import equal from 'fast-deep-equal';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, storeGet, useStore } from '../../store';
|
||||
import { storeSet, storeGet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../service/application-service';
|
||||
@@ -52,7 +52,7 @@ import { defaultMaxFileSize } from '../../configData';
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoApplication = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const { id } = useParams();
|
||||
const [isExpired, setIsExpired] = useState(false);
|
||||
const [formData, setFormData] = useState([]);
|
||||
@@ -68,7 +68,7 @@ const BandoApplication = () => {
|
||||
const [companyDocs, setCompanyDocs] = useState([]);
|
||||
const [personalDocs, setPersonalDocs] = useState([]);
|
||||
const [isRequestForApplData, setIsRequestForApplData] = useState(false);
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const previousStatus = useRef('');
|
||||
const toast = useRef(null);
|
||||
const formMsgs = useRef(null);
|
||||
@@ -111,7 +111,7 @@ const BandoApplication = () => {
|
||||
|
||||
const onSubmit = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.updateStatusApplication(applId, {}, submitApplicationCallback, errSubmitApplicationCallback, [
|
||||
@@ -125,11 +125,11 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'?
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errSubmitApplicationCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
@@ -179,7 +179,7 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.status);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errValidateApplicationCallback = (data) => {
|
||||
@@ -203,7 +203,7 @@ const BandoApplication = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const saveDraft = (saveAndMove = '') => {
|
||||
@@ -237,7 +237,7 @@ const BandoApplication = () => {
|
||||
|
||||
if (formId) {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.clear();
|
||||
@@ -255,7 +255,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
|
||||
const saveDraftCallback = (data, saveAndMove = '') => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -266,7 +266,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
if (!isEmpty(saveAndMove) && is(String, saveAndMove)) {
|
||||
if (['NEXT', 'PREVIOUS'].includes(saveAndMove)) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationService.getApplicationForm(data.data.id, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['formId', formId],
|
||||
['companyId', chosenCompanyId],
|
||||
@@ -274,7 +274,7 @@ const BandoApplication = () => {
|
||||
]);
|
||||
} else if (['VALIDATE'].includes(saveAndMove)) {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.validateApplication(applId, {}, validateApplicationCallback, errValidateApplicationCallback);
|
||||
@@ -288,7 +288,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
|
||||
const errSaveDraftCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
@@ -338,7 +338,7 @@ const BandoApplication = () => {
|
||||
setIsExpired(isCallExpired);
|
||||
|
||||
const chosenCompanyId = data.data.companyId;
|
||||
const companies = storeGet.main.companies();
|
||||
const companies = storeGet('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
let formDataInitial = {};
|
||||
let dynamicData = {
|
||||
@@ -360,7 +360,7 @@ const BandoApplication = () => {
|
||||
}, dynamicData);
|
||||
}
|
||||
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
Object.keys(userData).reduce((acc, cur) => {
|
||||
if ([
|
||||
'email', 'firstName', 'lastName', 'phoneNumber', 'codiceFiscale'
|
||||
@@ -403,12 +403,12 @@ const BandoApplication = () => {
|
||||
reset();
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
setIsRequestForApplData(false);
|
||||
}
|
||||
|
||||
const errGetApplFormCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
setIsRequestForApplData(false);
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (toast.current) {
|
||||
@@ -467,7 +467,7 @@ const BandoApplication = () => {
|
||||
|
||||
const onDownloadApplicationPdf = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
ApplicationService.downloadApplicationPdf(applId, {}, getPdfCallback, errPdfCallback);
|
||||
}
|
||||
@@ -482,23 +482,23 @@ const BandoApplication = () => {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errPdfCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getSignedPdfCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setSignedPdfFile([data.data]);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errSignedPdfCallbacks = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const handleSetSignedDocumentFromFileupload = (fieldName, stateFieldData) => {
|
||||
@@ -511,7 +511,7 @@ const BandoApplication = () => {
|
||||
|
||||
const doChangeToDraft = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.updateStatusApplication(applId, {}, changeToDraftCallback, errChangeToDraftCallback, [
|
||||
@@ -525,11 +525,11 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.status);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errChangeToDraftCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
@@ -613,7 +613,7 @@ const BandoApplication = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationService.getApplicationForm(applId, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['companyId', chosenCompanyId]
|
||||
]);
|
||||
@@ -628,7 +628,7 @@ const BandoApplication = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationService.getApplicationSignedPdf(applId, getSignedPdfCallback, errSignedPdfCallbacks);
|
||||
}
|
||||
}
|
||||
@@ -646,7 +646,7 @@ const BandoApplication = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
setIsRequestForApplData(true);
|
||||
ApplicationService.getApplicationForm(applId, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['companyId', chosenCompanyId]
|
||||
|
||||
Reference in New Issue
Block a user