From 5efe8aa37766c17444f7bc939ee7c4f5cac75c1e Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Mon, 9 Dec 2024 10:31:57 +0100 Subject: [PATCH] - fiexed redirection to login error; - refactored the code; --- .../components/ArchiveDocument/index.js | 4 +- .../components/ListOfFiles/index.js | 72 ++++++++++++++++ src/pages/DomandaEditPreInstructor/index.js | 84 ++++--------------- src/pages/Login/index.js | 6 +- 4 files changed, 94 insertions(+), 72 deletions(-) create mode 100644 src/pages/DomandaEditPreInstructor/components/ListOfFiles/index.js diff --git a/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js b/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js index 094d468..b50c321 100644 --- a/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js +++ b/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js @@ -80,8 +80,8 @@ const ArchiveDocument = ({ applicationId, ndg = '', fileId = 0 }) => { } } } - console.log('submitData', submitData); - //AppointmentService.archiveDocument(applicationId, fileId, submitData, submitCallback, errSubmitCallback) + + AppointmentService.archiveDocument(applicationId, fileId, submitData, submitCallback, errSubmitCallback) } } diff --git a/src/pages/DomandaEditPreInstructor/components/ListOfFiles/index.js b/src/pages/DomandaEditPreInstructor/components/ListOfFiles/index.js new file mode 100644 index 0000000..80f5a85 --- /dev/null +++ b/src/pages/DomandaEditPreInstructor/components/ListOfFiles/index.js @@ -0,0 +1,72 @@ +import React from 'react'; +import { Button } from 'primereact/button'; +import { __ } from '@wordpress/i18n'; +import { isNil } from 'ramda'; +import ArchiveDocument from '../ArchiveDocument'; + +const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applicationId }) => { + + return ( +
    + {files.map((o, i) =>
  1. +
    + {o.label} +
    + {o.fileDetail && o.fileDetail.length === 1 + ?
    +
    + {o.fileDetail && o.fileDetail.length > 1 + ?
      + {o.fileDetail.map((k) =>
    • + {k.name} +
      + +
      +
    • )} +
    + : null} +
  2. )} +
+ ) +} + +export default ListOfFiles; diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index 2bd14cb..f9b5d75 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -36,6 +36,7 @@ import DownloadApplicationArchive from './components/DownloadApplicationArchive' import DownloadCompanyDelegation from './components/DownloadCompanyDelegation'; import DownloadSignedApplication from './components/DownloadSignedApplication'; import AppointmentService from '../../service/appointment-service'; +import ListOfFiles from './components/ListOfFiles'; const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID; @@ -140,15 +141,14 @@ const DomandaEditPreInstructor = () => { const header = renderHeader(); - const updateEvaluationValue = (value, path, maxValue) => { - const pathEls = path.split('.'); + const updateEvaluationValue = (value, path, maxValue = null) => { let finalValue = value; if (maxValue || maxValue === 0) { finalValue = value > maxValue ? maxValue : value; } - const newData = wrap(data).set(pathEls, finalValue).value(); + const newData = wrap(data).set(path, finalValue).value(); setData(newData); updateFlagsForSoccorso(newData); } @@ -548,7 +548,7 @@ const DomandaEditPreInstructor = () => { inputId={`checklist_${o.id}`} onChange={(e) => updateEvaluationValue( e.checked, - `checklist.${i}.valid` + ['checklist', i, 'valid'] )} checked={o.valid}> @@ -565,7 +565,7 @@ const DomandaEditPreInstructor = () => { headerTemplate={header} onTextChange={(e) => updateEvaluationValue( e.htmlValue, - 'note' + ['note'] )} style={{ height: 80 * 3, width: '100%' }} /> @@ -573,65 +573,13 @@ const DomandaEditPreInstructor = () => {

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

-
    - {data.files.map((o, i) =>
  1. -
    - {o.label} -
    - {o.fileDetail && o.fileDetail.length === 1 - ?
    -
    - {o.fileDetail && o.fileDetail.length > 1 - ?
      - {o.fileDetail.map((k, i) =>
    • - {k.name} -
      - -
      -
    • )} -
    - : null} -
  2. )} -
+
@@ -660,8 +608,8 @@ const DomandaEditPreInstructor = () => { max={o.maxScore} onChange={(e) => updateEvaluationValue( e.value, - `criteria.${i}.score`, - o.maxScore + ['criteria', i, 'score'], + o.criteria )}/> / {o.maxScore} @@ -680,7 +628,7 @@ const DomandaEditPreInstructor = () => { severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'} onClick={() => updateEvaluationValue( true, - `criteria.${i}.valid` + ['criteria', i, 'valid'] )} aria-label={__('Su', 'gepafin')}/>