From 7c2feb20c776e579c5edd0685e02f6210f3a4cb1 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 21 Nov 2024 08:44:22 +0100 Subject: [PATCH 1/5] - added company name to tables with applications; - added form and file inputs to the page of editing/viewing soccorso for beneficiary; --- .../components/BandoEditFormStep2/index.js | 2 +- .../DraftApplicationsTable/index.js | 13 +- .../MyLatestSubmissionsTable/index.js | 18 +- .../PreInstructorDomandeTable/index.js | 9 +- src/pages/DomandaBeneficiario/index.js | 199 +++++++++++++----- src/pages/DomandaEditPreInstructor/index.js | 24 ++- .../components/AllDomandeTable/index.js | 10 +- src/pages/Domande/index.js | 2 +- .../BeneficiarioDomandeTable/index.js | 12 +- src/pages/ProfileCompany/index.js | 4 +- src/pages/SoccorsoEditPreInstructor/index.js | 9 - 11 files changed, 217 insertions(+), 85 deletions(-) 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}
From 1e1d16b3cdc8973b7234e02b2391e8b4bcae531e Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 21 Nov 2024 12:42:03 +0100 Subject: [PATCH 2/5] - fixed issue in datepicker; - updated styles; --- src/assets/scss/components/appPage.scss | 31 ++++++++++++------- .../FormField/components/Datepicker/index.js | 4 +-- src/pages/DomandaEditPreInstructor/index.js | 10 ++---- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index 4a1771b..c22488f 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -221,22 +221,29 @@ flex-direction: column; padding: 0; width: 100%; +} - > li { - padding: 15px; - border-bottom: 1px solid var(--button-secondary-borderColor); - display: flex; - justify-content: space-between; - align-items: center; - flex-direction: column; - gap: 1rem; - - &.row { - flex-direction: row; - } +.appPageSection__listItem { + padding: 15px; + border-bottom: 1px solid var(--button-secondary-borderColor); + display: flex; + justify-content: space-between; + align-items: center; + flex-direction: column; + gap: 1rem; + + &.row { + flex-direction: row; } } +.appPageSection__listItemRow { + display: flex; + flex-direction: row; + justify-content: space-between; + gap: 16px; +} + .appPageSection__checklist { display: flex; flex-direction: column; diff --git a/src/components/FormField/components/Datepicker/index.js b/src/components/FormField/components/Datepicker/index.js index b33c13c..f4164c5 100644 --- a/src/components/FormField/components/Datepicker/index.js +++ b/src/components/FormField/components/Datepicker/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { classNames } from 'primereact/utils'; import { Controller } from 'react-hook-form'; -import { is } from 'ramda'; +import { is, isEmpty } from 'ramda'; import { Calendar } from 'primereact/calendar'; @@ -30,7 +30,7 @@ const Datepicker = ({ rules={config} render={({ field, fieldState }) => ( field.onChange(e.value)} dateFormat="dd/mm/yy" hourFormat="24" diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index 5ca8898..67bf975 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -259,7 +259,7 @@ const DomandaEditPreInstructor = () => { } const shouldDisableField = (fieldName) => { - return !['EVALUATION'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria' + return !['EVALUATION', 'OPEN'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria' } useEffect(() => { @@ -454,12 +454,8 @@ const DomandaEditPreInstructor = () => {

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

    - {data.files.map((o, i) =>
  1. -
    + {data.files.map((o, i) =>
  2. +
    {o.label}
    {o.fileDetail && o.fileDetail.length === 1 From 8fd8f3116f4f5381df1fe4c5d093932d668f380d Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 21 Nov 2024 16:49:59 +0100 Subject: [PATCH 3/5] - added modal window for approving/rejecting; --- src/pages/DomandaEditPreInstructor/index.js | 69 ++++++++++++++++++++- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index 67bf975..ac6e506 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -28,6 +28,8 @@ import BlockingOverlay from '../../components/BlockingOverlay'; import { Toast } from 'primereact/toast'; import HelpIcon from '../../icons/HelpIcon'; import { Dialog } from 'primereact/dialog'; +import { classNames } from 'primereact/utils'; +import { Dropdown } from 'primereact/dropdown'; const DomandaEditPreInstructor = () => { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -40,6 +42,9 @@ const DomandaEditPreInstructor = () => { const [isAdmissible, setIsAdmissible] = useState(false); const [connectedSoccorsoId, setConnectedSoccorsoId] = useState(0); const toast = useRef(null); + const [loading, setLoading] = useState(false); + const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false); + const [operationType, setOperationType] = useState('') const goToEvaluationsPage = () => { navigate('/domande'); @@ -256,12 +261,48 @@ const DomandaEditPreInstructor = () => { } const errGetAmendmentsCallback = () => { + if (toast.current && data.message) { + toast.current.show({ + severity: 'error', + summary: '', + detail: data.message + }); + } + set404FromErrorResponse(data); } const shouldDisableField = (fieldName) => { return !['EVALUATION', 'OPEN'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria' } + const headerCompleteDialog = () => { + return 'approve' === operationType + ? {__('Confermare l\'approvazione', 'gepafin')} + : {__('Confermare il rifiuto', 'gepafin')}; + } + + const hideCompleteDialog = () => { + setIsVisibleCompleteDialog(false); + } + + const footerCompleteDialog = () => { + return
    +
    + } + + const initiateApproving = () => { + setOperationType('approve'); + } + + const initiateRejecting = () => { + setOperationType('approve'); + } + useEffect(() => { const maxScore = pathOr(0, ['minScore'], data); const criteria = pathOr([], ['criteria'], data); @@ -329,7 +370,7 @@ const DomandaEditPreInstructor = () => {

    {__('Stato', 'gepafin')} - {getBandoLabel(data.status)} + {getBandoLabel(data.applicationStatus)}

    @@ -548,14 +589,14 @@ const DomandaEditPreInstructor = () => { ?
    @@ -569,6 +610,28 @@ const DomandaEditPreInstructor = () => { {criterionDataContent} + +
    + {/* + setChosenUser(e.value)} + options={users} + optionLabel="name" + optionValue="value"/>*/} +
    +
    +
: <> From 9465cbd55a64b789656d1648d3b546abe12cd135 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 21 Nov 2024 17:23:48 +0100 Subject: [PATCH 4/5] - added modal window for approve/reject; --- src/pages/DomandaEditPreInstructor/index.js | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index ac6e506..095bedd 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -44,7 +44,8 @@ const DomandaEditPreInstructor = () => { const toast = useRef(null); const [loading, setLoading] = useState(false); const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false); - const [operationType, setOperationType] = useState('') + const [operationType, setOperationType] = useState(''); + const [motivation, setMotivation] = useState(''); const goToEvaluationsPage = () => { navigate('/domande'); @@ -272,7 +273,7 @@ const DomandaEditPreInstructor = () => { } const shouldDisableField = (fieldName) => { - return !['EVALUATION', 'OPEN'].includes(data.status) || ['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria' + return !['EVALUATION', 'OPEN'].includes(data.status) || (['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria') } const headerCompleteDialog = () => { @@ -283,6 +284,7 @@ const DomandaEditPreInstructor = () => { const hideCompleteDialog = () => { setIsVisibleCompleteDialog(false); + setOperationType(''); } const footerCompleteDialog = () => { @@ -297,10 +299,13 @@ const DomandaEditPreInstructor = () => { const initiateApproving = () => { setOperationType('approve'); + setIsVisibleCompleteDialog(true); + } const initiateRejecting = () => { setOperationType('approve'); + setIsVisibleCompleteDialog(true); } useEffect(() => { @@ -618,17 +623,15 @@ const DomandaEditPreInstructor = () => { style={{ maxWidth: '600px', width: '100%' }} onHide={hideCompleteDialog}>
- {/* - setChosenUser(e.value)} - options={users} - optionLabel="name" - optionValue="value"/>*/} + + setMotivation(e.htmlValue)} + style={{ height: 80 * 3, width: '100%' }} + />
From fdda72b6176f9c9256c945e7fc6af66d781ba66b Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Fri, 22 Nov 2024 16:37:59 +0100 Subject: [PATCH 5/5] - added FLOW_ID env variable; - implemented two types of evaluation flow; - refactored component related to communication messages; - fixed displaying elements based on evaluation status; - fixed some styles; --- .env | 3 +- environments/dev/dev.env | 3 +- environments/prod/prod.env | 3 +- src/assets/scss/components/appPage.scss | 11 +- src/assets/scss/components/myTable.scss | 3 + src/pages/DashboardBeneficiario/index.js | 2 +- src/pages/DomandaBeneficiario/index.js | 184 +-------------- src/pages/DomandaEditPreInstructor/index.js | 55 ++++- .../components/SoccorsoComunications/index.js | 218 ++++++++++++++++++ src/pages/SoccorsoEditPreInstructor/index.js | 175 +------------- 10 files changed, 294 insertions(+), 363 deletions(-) create mode 100644 src/pages/SoccorsoEditPreInstructor/components/SoccorsoComunications/index.js diff --git a/.env b/.env index 0b1a428..9ef0c84 100644 --- a/.env +++ b/.env @@ -3,4 +3,5 @@ REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1 REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico -REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs \ No newline at end of file +REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs +REACT_APP_EVALUATION_FLOW_ID=1 \ No newline at end of file diff --git a/environments/dev/dev.env b/environments/dev/dev.env index 0b1a428..9ef0c84 100644 --- a/environments/dev/dev.env +++ b/environments/dev/dev.env @@ -3,4 +3,5 @@ REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1 REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico -REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs \ No newline at end of file +REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs +REACT_APP_EVALUATION_FLOW_ID=1 \ No newline at end of file diff --git a/environments/prod/prod.env b/environments/prod/prod.env index 6e25d7d..1755a33 100644 --- a/environments/prod/prod.env +++ b/environments/prod/prod.env @@ -3,4 +3,5 @@ REACT_APP_API_EXECUTION_ADDRESS=https://bandi-api.gepafin.it/v1 REACT_APP_API_ADDRESS=https://bandi-api.gepafin.it REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico -REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs \ No newline at end of file +REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs +REACT_APP_EVALUATION_FLOW_ID=1 \ No newline at end of file diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index c22488f..a347c24 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -208,10 +208,18 @@ column-count: 2; column-width: 4em; display: block; - padding-bottom: 0; + /*padding-bottom: 0;*/ .appPageSection__pMeta { margin-bottom: 1em; + + span:nth-of-type(1) { + max-width: 30%; + } + span:nth-of-type(2) { + max-width: 60%; + text-align: right; + } } } } @@ -221,6 +229,7 @@ flex-direction: column; padding: 0; width: 100%; + list-style: inside; } .appPageSection__listItem { diff --git a/src/assets/scss/components/myTable.scss b/src/assets/scss/components/myTable.scss index bbfbb2a..67b3b41 100644 --- a/src/assets/scss/components/myTable.scss +++ b/src/assets/scss/components/myTable.scss @@ -23,6 +23,9 @@ border-width: 0 0 1px 0; padding: 1rem 1rem; } + tr.outgoing { + background-color: #DAF0C3B2; + } } .myTfoot { diff --git a/src/pages/DashboardBeneficiario/index.js b/src/pages/DashboardBeneficiario/index.js index 6503111..66ac510 100644 --- a/src/pages/DashboardBeneficiario/index.js +++ b/src/pages/DashboardBeneficiario/index.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { __, sprintf } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; import { Link, useNavigate } from 'react-router-dom'; import { head, isEmpty, pathOr } from 'ramda'; import NumberFlow from '@number-flow/react'; diff --git a/src/pages/DomandaBeneficiario/index.js b/src/pages/DomandaBeneficiario/index.js index 322f1f4..50b8083 100644 --- a/src/pages/DomandaBeneficiario/index.js +++ b/src/pages/DomandaBeneficiario/index.js @@ -1,35 +1,30 @@ import React, { useState, useEffect, useRef, useMemo } from 'react'; import { __, sprintf } from '@wordpress/i18n'; import { useNavigate, useParams } from 'react-router-dom'; -import { is, isEmpty, isNil } from 'ramda'; -import { wrap } from 'object-path-immutable'; +import { is, isEmpty } from 'ramda'; +import { useForm } from 'react-hook-form'; +import { klona } from 'klona'; // store import { storeSet, useStore } from '../../store'; // api import AmendmentsService from '../../service/amendments-service'; -import CommunicationService from '../../service/communication-service'; +import ApplicationService from '../../service/application-service'; // tools import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; import getBandoLabel from '../../helpers/getBandoLabel'; import getDateFromISOstring from '../../helpers/getDateFromISOstring'; import renderHtmlContent from '../../helpers/renderHtmlContent'; -import uniqid from '../../helpers/uniqid'; // components import { Button } from 'primereact/button'; import BlockingOverlay from '../../components/BlockingOverlay'; import { Toast } from 'primereact/toast'; -import { classNames } from 'primereact/utils'; import { Dialog } from 'primereact/dialog'; -import { InputText } from 'primereact/inputtext'; -import { InputTextarea } from 'primereact/inputtextarea'; -import ApplicationService from '../../service/application-service'; import FormField from '../../components/FormField'; -import { useForm } from 'react-hook-form'; -import { klona } from 'klona'; +import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/SoccorsoComunications'; const DomandaBeneficiario = () => { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -37,10 +32,6 @@ const DomandaBeneficiario = () => { const navigate = useNavigate(); const [data, setData] = useState({}); const [dataAppl, setDataAppl] = useState({}); - const [comms, setComms] = useState([]); - const [isVisibleNewCommDialog, setIsVisibleNewCommDialog] = useState(false); - const [newCommData, setNewCommData] = useState({}); - const [isLoadingCommunication, setIsLoadingCommunication] = useState(false); const [isVisibleEmailDialog, setIsVisibleEmailDialog] = useState(false); const toast = useRef(null); const [formInitialData, setFormInitialData] = useState({}); @@ -83,7 +74,6 @@ const DomandaBeneficiario = () => { return acc; }, {}); setFormInitialData(formDataInitial); - CommunicationService.getCommsByAmendmentId(amendmentObj.id, getCommsCallback, errGetCommsCallback); storeSet.main.unsetAsyncRequest(); } else { ApplicationService.getApplication(id, getApplCallback, errGetCallback) @@ -110,25 +100,6 @@ const DomandaBeneficiario = () => { storeSet.main.unsetAsyncRequest(); } - const getCommsCallback = (data) => { - if (data.status === 'SUCCESS') { - setComms(data.data.commentsList.map(o => getFormattedCommsData(o))); - } - storeSet.main.unsetAsyncRequest(); - } - - const errGetCommsCallback = (data) => { - if (toast.current && data.message) { - toast.current.show({ - severity: 'error', - summary: '', - detail: data.message - }); - } - set404FromErrorResponse(data); - storeSet.main.unsetAsyncRequest(); - } - const getFormattedData = (data) => { data.submissionDate = is(String, data.submissionDate) ? new Date(data.submissionDate) : (data.submissionDate ? data.submissionDate : ''); data.startDate = is(String, data.startDate) ? new Date(data.startDate) : (data.startDate ? data.startDate : ''); @@ -136,81 +107,6 @@ const DomandaBeneficiario = () => { return data; }; - const getFormattedCommsData = (data) => { - data.id = isNil(data.id) ? uniqid('id') : data.id; - data.commentedDate = is(String, data.commentedDate) ? new Date(data.commentedDate) : (data.commentedDate ? data.commentedDate : ''); - data.createdDate = is(String, data.createdDate) ? new Date(data.createdDate) : (data.createdDate ? data.createdDate : ''); - data.updatedDate = is(String, data.updatedDate) ? new Date(data.updatedDate) : (data.updatedDate ? data.updatedDate : ''); - return data; - }; - - const headerNewComDialog = () => { - return {__('Aggiungi comunicazione', 'gepafin')} - } - - const hideNewComDialog = () => { - setIsVisibleNewCommDialog(false); - setNewCommData({ - title: '', - comment: '' - }); - } - - const footerNewComDialog = () => { - return
-
- } - - const openNewCommDialog = () => { - setIsVisibleNewCommDialog(true); - setNewCommData({ - title: '', - comment: '' - }); - } - - const updateNewCommData = (value, path) => { - const newData = wrap(newCommData).set(path.split('.'), value).value(); - setNewCommData(newData); - } - - const createCommunication = () => { - setIsLoadingCommunication(true); - CommunicationService.createCommunication(data.id, newCommData, createCommunicationCallback, errCreateCommunicationCallback); - } - - const createCommunicationCallback = (data) => { - if (data.status === 'SUCCESS') { - if (toast.current) { - toast.current.show({ - severity: 'success', - summary: '', - detail: data.message - }); - } - setComms([...comms, getFormattedCommsData(data.data)]) - setIsVisibleNewCommDialog(false); - } - setIsLoadingCommunication(false); - } - - const errCreateCommunicationCallback = (data) => { - if (toast.current && data.message) { - toast.current.show({ - severity: 'error', - summary: '', - detail: data.message - }); - } - set404FromErrorResponse(data); - setIsLoadingCommunication(false); - } - const onSubmit = () => { }; @@ -354,7 +250,7 @@ const DomandaBeneficiario = () => {

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

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

+ style={{ minHeight: '100px' }}> {renderHtmlContent(data.note)}
: null} @@ -365,9 +261,6 @@ const DomandaBeneficiario = () => {
{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 { {data.id ?

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

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

{o.title}

-

{o.comment}

-
--
- -
: null} {data.id @@ -459,40 +321,8 @@ const DomandaBeneficiario = () => { icon="pi pi-times" iconPos="right"/> - - - -
- - updateNewCommData(e.target.value, 'title')}/> - - - updateNewCommData(e.target.value, 'comment')}/> -
-
- { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -63,6 +63,7 @@ const DomandaEditPreInstructor = () => { const getCallback = (data) => { if (data.status === 'SUCCESS') { setData(getFormattedData(data.data)); + setMotivation(data.data.motivation); } storeSet.main.unsetAsyncRequest(); } @@ -158,8 +159,10 @@ const DomandaEditPreInstructor = () => { criteria: klona(data.criteria), checklist: klona(data.checklist), files: klona(data.files), - note: data.note + note: data.note, + motivation } + ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback); } @@ -169,8 +172,10 @@ const DomandaEditPreInstructor = () => { criteria: klona(data.criteria), checklist: klona(data.checklist), files: klona(data.files), - note: data.note + note: data.note, + motivation } + ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback); } @@ -273,7 +278,8 @@ const DomandaEditPreInstructor = () => { } const shouldDisableField = (fieldName) => { - return !['EVALUATION', 'OPEN'].includes(data.status) || (['ADMISSIBLE'].includes(data.status) && fieldName !== 'criteria') + return !['EVALUATION'].includes(data.applicationStatus) + || (['ADMISSIBLE'].includes(data.applicationStatus) && fieldName !== 'criteria') } const headerCompleteDialog = () => { @@ -285,6 +291,7 @@ const DomandaEditPreInstructor = () => { const hideCompleteDialog = () => { setIsVisibleCompleteDialog(false); setOperationType(''); + setMotivation(''); } const footerCompleteDialog = () => { @@ -304,10 +311,18 @@ const DomandaEditPreInstructor = () => { } const initiateRejecting = () => { - setOperationType('approve'); + setOperationType('reject'); setIsVisibleCompleteDialog(true); } + const doCreateAppointment = () => { + // TODO + } + + const doMakeAdmisible = () => { + // TODO + } + useEffect(() => { const maxScore = pathOr(0, ['minScore'], data); const criteria = pathOr([], ['criteria'], data); @@ -565,18 +580,21 @@ const DomandaEditPreInstructor = () => {
-
+ } + + const openNewCommDialog = () => { + setIsVisibleNewCommDialog(true); + setNewCommData({ + title: '', + comment: '' + }); + } + + const updateNewCommData = (value, path) => { + const newData = wrap(newCommData).set(path.split('.'), value).value(); + setNewCommData(newData); + } + + const createCommunication = () => { + setIsLoadingCommunication(true); + CommunicationService.createCommunication(amendmentId, newCommData, createCommunicationCallback, errCreateCommunicationCallback); + } + + const createCommunicationCallback = (data) => { + if (data.status === 'SUCCESS') { + if (toast.current) { + toast.current.show({ + severity: 'success', + summary: '', + detail: data.message + }); + } + setComms([...comms, getFormattedCommsData(data.data)]) + setIsVisibleNewCommDialog(false); + } + setIsLoadingCommunication(false); + } + + const errCreateCommunicationCallback = (data) => { + if (toast.current && data.message) { + toast.current.show({ + severity: 'error', + summary: '', + detail: data.message + }); + } + set404FromErrorResponse(data); + setIsLoadingCommunication(false); + } + + const displayCommIcon = (comm) => { + const userData = storeGet.main.userData(); + return userData.id === comm.senderUserId + ? + : ; + } + + const getCommRowClass = (comm) => { + const userData = storeGet.main.userData(); + return userData.id === comm.senderUserId ? 'outgoing' : 'incoming'; + } + + return ( + <> + + + + + + + + + + + {!isNil(comms) && !isEmpty(comms) + ? comms.map((o, i) => + + + + ) + : + + + + } + +
{__('Data', 'gepafin')}{__('Comunicazione', 'gepafin')}
+ {displayCommIcon(o)} + + {getDateFromISOstring(o.commentedDate)} + +

{o.title}

+

{o.comment}

+
--
+ +
- } - - const openNewCommDialog = () => { - setIsVisibleNewCommDialog(true); - setNewCommData({ - title: '', - comment: '' - }); - } - - const updateNewCommData = (value, path) => { - const newData = wrap(newCommData).set(path.split('.'), value).value(); - setNewCommData(newData); - } - const renderHeader = () => { return ( @@ -185,38 +116,6 @@ const SoccorsoEditPreInstructor = () => { setData(newData); } - const createCommunication = () => { - setIsLoadingCommunication(true); - CommunicationService.createCommunication(amendmentId, newCommData, createCommunicationCallback, errCreateCommunicationCallback); - } - - const createCommunicationCallback = (data) => { - if (data.status === 'SUCCESS') { - if (toast.current) { - toast.current.show({ - severity: 'success', - summary: '', - detail: data.message - }); - } - setComms([...comms, getFormattedCommsData(data.data)]) - setIsVisibleNewCommDialog(false); - } - setIsLoadingCommunication(false); - } - - const errCreateCommunicationCallback = (data) => { - if (toast.current && data.message) { - toast.current.show({ - severity: 'error', - summary: '', - detail: data.message - }); - } - set404FromErrorResponse(data); - setIsLoadingCommunication(false); - } - const onSubmit = () => { }; @@ -471,38 +370,7 @@ const SoccorsoEditPreInstructor = () => {

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

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

{o.title}

-

{o.comment}

-
--
- -
@@ -511,9 +379,6 @@ const SoccorsoEditPreInstructor = () => { {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 {
- -
- - updateNewCommData(e.target.value, 'title')}/> - - - updateNewCommData(e.target.value, 'comment')}/> -
-
-