diff --git a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js index 8ce097e..d8483b2 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep2/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep2/index.js @@ -284,7 +284,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g options={checklistOptions} errors={errors} register={register} - label={<>{__('Checklist valutazione Pre-Istruttoria', 'gepafin')}* + label={<>{__('Checklist valutazione Istruttoria', 'gepafin')}* {__('(almeno 1 elemento)', 'gepafin')}} config={{ validate: { diff --git a/src/pages/Dashboard/components/DraftApplicationsTable/index.js b/src/pages/Dashboard/components/DraftApplicationsTable/index.js index 63518ff..6530216 100644 --- a/src/pages/Dashboard/components/DraftApplicationsTable/index.js +++ b/src/pages/Dashboard/components/DraftApplicationsTable/index.js @@ -172,9 +172,15 @@ const DraftApplicationsTable = () => { emptyMessage={__('Nessun dato disponibile', 'gepafin')} onFilter={(e) => setFilters(e.filters)}> - + {/* { style={{ minWidth: '8rem' }} body={dateModifyBodyTemplate} filter filterElement={dateFilterTemplate}/>*/} diff --git a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js index ce3f987..d5a4f84 100644 --- a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js +++ b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js @@ -177,16 +177,26 @@ const MyLatestSubmissionsTable = () => { header={header} emptyMessage={__('Nessun dato disponibile', 'gepafin')} onFilter={(e) => setFilters(e.filters)}> - + + body={dateEndBodyTemplate} + filter + filterElement={dateFilterTemplate}/> + body={dateModifyBodyTemplate} + filter + filterElement={dateFilterTemplate}/> diff --git a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js index 5e53e82..78de5dc 100644 --- a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js +++ b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js @@ -143,10 +143,15 @@ const PreInstructorDomandeTable = () => { emptyMessage={__('Nessun dato disponibile', 'gepafin')} onFilter={(e) => setFilters(e.filters)}> + { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -40,6 +43,20 @@ const DomandaBeneficiario = () => { const [isLoadingCommunication, setIsLoadingCommunication] = useState(false); const [isVisibleEmailDialog, setIsVisibleEmailDialog] = useState(false); const toast = useRef(null); + const [formInitialData, setFormInitialData] = useState({}); + const { + control, + handleSubmit, + formState: { errors }, + setValue, + register, + trigger, + getValues + } = useForm({ + defaultValues: useMemo(() => { + return formInitialData; + }, [formInitialData]), mode: 'onChange' + }); const goToArchivePage = () => { navigate(`/domande`); @@ -57,8 +74,16 @@ const DomandaBeneficiario = () => { const getCallback = (data) => { if (data.status === 'SUCCESS') { if (data.data.length) { - setData(getFormattedData(data.data[0])); - CommunicationService.getCommsByAmendmentId(data.data[0].id, getCommsCallback, errGetCommsCallback); + const amendmentObj = data.data[0]; + setData(getFormattedData(amendmentObj)); + const formDataInitial = amendmentObj.applicationFormFields.reduce((acc, cur) => { + if (cur.fieldValue) { + acc[cur.fieldId] = cur.fieldValue; + } + return acc; + }, {}); + setFormInitialData(formDataInitial); + CommunicationService.getCommsByAmendmentId(amendmentObj.id, getCommsCallback, errGetCommsCallback); storeSet.main.unsetAsyncRequest(); } else { ApplicationService.getApplication(id, getApplCallback, errGetCallback) @@ -186,6 +211,60 @@ const DomandaBeneficiario = () => { setIsLoadingCommunication(false); } + const onSubmit = () => { + }; + + const doUpdateAmendment = () => { + trigger(); + let formValues = klona(getValues()); + const newFormValues = Object.keys(formValues) + .reduce((acc, cur) => { + let fieldVal = formValues[cur]; + + fieldVal = isEmpty(fieldVal) ? null : fieldVal; + fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null; + + acc.push({ + 'fieldId': cur, + 'fieldValue': fieldVal + }); + return acc; + }, []); + + const submitData = { + applicationFormFields: newFormValues, + } + const amendmentId = data.id; + + storeSet.main.setAsyncRequest(); + AmendmentsService.updateSoccorso(amendmentId, submitData, updateAmendmentCallback, errUpdateAmendmentCallback); + } + + const updateAmendmentCallback = (data) => { + if (data.status === 'SUCCESS') { + if (toast.current) { + toast.current.show({ + severity: 'success', + summary: '', + detail: data.message + }); + } + } + storeSet.main.unsetAsyncRequest(); + } + + const errUpdateAmendmentCallback = (data) => { + if (toast.current && data.message) { + toast.current.show({ + severity: 'error', + summary: '', + detail: data.message + }); + } + set404FromErrorResponse(data); + storeSet.main.unsetAsyncRequest(); + } + return (
@@ -272,59 +351,85 @@ const DomandaBeneficiario = () => { {data.id ?
-

{__('Dettagli Richiesta', 'gepafin')}

-

{__('Documenti Richiesti', 'gepafin')}

-
    +

    {__('Dettagli Richiesta', 'gepafin')}

    +

    {__('Note e spiegazioni', 'gepafin')}

    +
    + {renderHtmlContent(data.note)} +
    +
: null} + + {data.id + ?
+

{__('Documenti Richiesti', 'gepafin')}

+
+ {data.formFields + ? data.formFields.map((o, i) => { + /*const thisField = head(test.updatedFormFields.filter(j => j.fieldId === o.fieldId)); + const value = pathOr({}, ['fieldValue'], thisField); + console.log('value', value, o.fieldId);*/ + return + }) : null} + + {/*
    {data.formFields ? data.formFields.map((o, i) =>
  1. {o.label}
  2. ) : null} -
-
: null} + */} +
: null} {data.id ?
-

{__('Note e spiegazioni', 'gepafin')}

-
- {renderHtmlContent(data.note)} -
-
: null} +

{__('Comunicazioni', 'gepafin')}

+ + + + + + + + + {!isNil(comms) && !isEmpty(comms) + ? comms.map((o, i) => + + + ) + : + + + } + +
{__('Data', 'gepafin')}{__('Comunicazione', 'gepafin')}
+ {getDateFromISOstring(o.commentedDate)} + +

{o.title}

+

{o.comment}

+
--
- {data.id - ?
-

{__('Comunicazioni', 'gepafin')}

- - - - - - - - - {!isNil(comms) && !isEmpty(comms) - ? comms.map((o, i) => - - - ) - : - - - } - -
{__('Data', 'gepafin')}{__('Comunicazione', 'gepafin')}
- {getDateFromISOstring(o.commentedDate)} - -

{o.title}

-

{o.comment}

-
--
- -
: null} diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index 82d1dd3..5ca8898 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -102,7 +102,7 @@ const DomandaEditPreInstructor = () => { const updateEvaluationValue = (value, path, maxValue) => { let finalValue = value; - if (maxValue) { + if (maxValue || maxValue === 0) { finalValue = value > maxValue ? maxValue : value; } @@ -258,6 +258,10 @@ const DomandaEditPreInstructor = () => { const errGetAmendmentsCallback = () => { } + const shouldDisableField = (fieldName) => { + return !['EVALUATION'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria' + } + useEffect(() => { const maxScore = pathOr(0, ['minScore'], data); const criteria = pathOr([], ['criteria'], data); @@ -329,9 +333,7 @@ const DomandaEditPreInstructor = () => {

-
- -
+

{__('Punteggi di valutazione', 'gepafin')}

@@ -350,7 +352,7 @@ const DomandaEditPreInstructor = () => {
{ onClick={() => displayCriterionData(o.id)} aria-label={__('Mostra', 'gepafin')}/> : null}