- fix for uploading files for amendment;
This commit is contained in:
@@ -100,8 +100,8 @@ const Fileupload = ({
|
||||
if (file.id) {
|
||||
FileUploadService.deleteFile(
|
||||
{},
|
||||
(data) => dCallback(data, file.id),
|
||||
dErrorCallback,
|
||||
(data) => deleteCallback(data, file.id),
|
||||
deleteErrorCallback,
|
||||
[['id', file.id]]
|
||||
);
|
||||
} else {
|
||||
@@ -111,7 +111,7 @@ const Fileupload = ({
|
||||
}
|
||||
}
|
||||
|
||||
const dCallback = (data, id) => {
|
||||
const deleteCallback = (data, id) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setStateFieldData(prevState => {
|
||||
const newFiles = prevState.filter(o => o.id !== id);
|
||||
@@ -122,7 +122,7 @@ const Fileupload = ({
|
||||
}
|
||||
}
|
||||
|
||||
const dErrorCallback = (err) => {
|
||||
const deleteErrorCallback = (err) => {
|
||||
console.log('err', err);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,13 @@ const DomandaBeneficiario = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
const newFormDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formInitialData);
|
||||
setFormInitialData(newFormDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -157,10 +164,18 @@ const DomandaBeneficiario = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
//set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData) {
|
||||
//reset();
|
||||
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]));
|
||||
trigger();
|
||||
}
|
||||
}, [formInitialData]);
|
||||
|
||||
return (
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
@@ -270,13 +285,11 @@ const DomandaBeneficiario = () => {
|
||||
fieldName={o.fieldId}
|
||||
label={o.label}
|
||||
control={control}
|
||||
register={register}
|
||||
errors={errors}
|
||||
defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []}
|
||||
accept={[]}
|
||||
doctype="document"
|
||||
register={register}
|
||||
sourceId={data.applicationId}
|
||||
source="application"
|
||||
multiple={true}
|
||||
/>
|
||||
}) : null}
|
||||
|
||||
@@ -139,7 +139,6 @@ const SoccorsoEditPreInstructor = () => {
|
||||
const submitData = {
|
||||
applicationFormFields: newFormValues,
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
AmendmentsService.updateSoccorso(amendmentId, submitData, updateAmendmentCallback, errUpdateAmendmentCallback);
|
||||
}
|
||||
@@ -153,6 +152,13 @@ const SoccorsoEditPreInstructor = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
const newFormDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formInitialData);
|
||||
setFormInitialData(newFormDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -289,6 +295,14 @@ const SoccorsoEditPreInstructor = () => {
|
||||
setIsLoadingReminding(false);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData) {
|
||||
//reset();
|
||||
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]));
|
||||
trigger();
|
||||
}
|
||||
}, [formInitialData]);
|
||||
|
||||
useEffect(() => {
|
||||
const parsedSoccorsoId = parseInt(amendmentId);
|
||||
const soccorsoEntityId = !isNaN(parsedSoccorsoId) ? parsedSoccorsoId : 0;
|
||||
@@ -388,13 +402,11 @@ const SoccorsoEditPreInstructor = () => {
|
||||
fieldName={o.fieldId}
|
||||
label={o.label}
|
||||
control={control}
|
||||
register={register}
|
||||
errors={errors}
|
||||
defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []}
|
||||
accept={[]}
|
||||
doctype="document"
|
||||
register={register}
|
||||
sourceId={data.applicationId}
|
||||
source="application"
|
||||
multiple={true}
|
||||
/>
|
||||
}) : null}
|
||||
|
||||
Reference in New Issue
Block a user