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