diff --git a/src/components/FormField/components/CriteriaTable/RenderTable/components/LastRowCell/index.js b/src/components/FormField/components/CriteriaTable/RenderTable/components/LastRowCell/index.js
index cd0d954..73d987c 100644
--- a/src/components/FormField/components/CriteriaTable/RenderTable/components/LastRowCell/index.js
+++ b/src/components/FormField/components/CriteriaTable/RenderTable/components/LastRowCell/index.js
@@ -1,4 +1,4 @@
-import { head, isNil, pathOr } from 'ramda';
+import { head, is, isNil, pathOr } from 'ramda';
import getNumberFormatted from '../../../../../../../helpers/getNumberFormatted';
const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) => {
@@ -9,7 +9,7 @@ const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) =
cellValue = pathOr(0, ['total'], tableValue);
}
- return
{getNumberFormatted(cellValue)} | ;
+ return {is(Number, cellValue) ? getNumberFormatted(cellValue) : cellValue} | ;
};
export default LastRowCell;
\ No newline at end of file
diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js
index 3860f56..64b4546 100644
--- a/src/pages/DomandaEditPreInstructor/index.js
+++ b/src/pages/DomandaEditPreInstructor/index.js
@@ -121,7 +121,7 @@ const DomandaEditPreInstructor = () => {
navigate('/domande');
}
- const updateFlagsForSoccorso = (data) => {
+ const updateFlagsForSoccorso = useCallback((data) => {
let nonRatedFilesLength = 0;
if (data.files) {
@@ -140,14 +140,28 @@ const DomandaEditPreInstructor = () => {
setAllFilesRated(nonRatedFilesLength === 0);
- if (data.checklist) {
- const checkedChecklistItems = data.checklist
- .map(el => el.valid)
- .filter(v => v);
- setAtLeastOneChecked(checkedChecklistItems.length > 0);
- setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
+ if (data.evaluationVersion === 'V1') {
+ if (data.checklist) {
+ const checkedChecklistItems = data.checklist
+ .map(el => el.valid)
+ .filter(v => v);
+ setAtLeastOneChecked(checkedChecklistItems.length > 0);
+ setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
+ }
+ } else if (data.evaluationVersion === 'V2') {
+ const minChecks = data.numberOfCheck;
+ const formFieldsChecklist = formData
+ .filter(o => head(o.settings.filter(s => s.name === 'isChecklistItem' && s.value)))
+ .map(o => o.id);
+
+ if (formFieldsChecklist.length >= minChecks) {
+ const valuesTotal = formFieldsChecklist.map(v => formValues[v]);
+ const valuesFirst = valuesTotal.toSpliced(minChecks);
+ setAtLeastOneChecked(valuesTotal.filter(v => v === true).length === valuesTotal.length);
+ setAllChecksChecked(valuesFirst.filter(v => v === true).length === valuesFirst.length)
+ }
}
- }
+ }, [formValues]);
const doNewSoccorso = () => {
if (connectedSoccorsoId !== 0) {
@@ -191,25 +205,28 @@ const DomandaEditPreInstructor = () => {
setData(getFormattedData(resp.data));
setMotivation(resp.data.motivation);
updateFlagsForSoccorso(resp.data);
- setFormData(resp.data.applicationEvaluationFormResponse.content);
- setFormId(resp.data.applicationEvaluationFormResponse.id);
- let formDataInitial = {};
- if (resp.data.applicationEvaluationFormResponse.formFields) {
- const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
- fieldId: o.fieldId,
- fieldValue: o.fieldValue
- }));
- formDataInitial = submitData.reduce((acc, cur) => {
- if (cur.fieldValue) {
- acc[cur.fieldId] = cur.fieldValue;
- }
- return acc;
- }, formDataInitial);
+ if (resp.data.evaluationVersion === 'V2') {
+ setFormData(resp.data.applicationEvaluationFormResponse.content);
+ setFormId(resp.data.applicationEvaluationFormResponse.id);
+ let formDataInitial = {};
+
+ if (resp.data.applicationEvaluationFormResponse.formFields) {
+ const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
+ fieldId: o.fieldId,
+ fieldValue: o.fieldValue
+ }));
+ formDataInitial = submitData.reduce((acc, cur) => {
+ if (cur.fieldValue) {
+ acc[cur.fieldId] = cur.fieldValue;
+ }
+ return acc;
+ }, formDataInitial);
+ }
+
+ reset();
+ setFormInitialData(formDataInitial);
}
-
- reset();
- setFormInitialData(formDataInitial);
}
storeSet.main.unsetAsyncRequest();
}
@@ -848,6 +865,8 @@ const DomandaEditPreInstructor = () => {
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
reset(updatedFormValues);
}
+
+ updateFlagsForSoccorso(data);
}, [formValues]);
useEffect(() => {