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 4a1771b..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,22 +229,30 @@ flex-direction: column; padding: 0; width: 100%; + list-style: inside; +} - > 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/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/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/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 e3d9a5c..a356d68 100644 --- a/src/pages/Dashboard/components/DraftApplicationsTable/index.js +++ b/src/pages/Dashboard/components/DraftApplicationsTable/index.js @@ -173,9 +173,15 @@ const DraftApplicationsTable = () => { emptyMessage={translationStrings.emptyMessage} 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 e7a488d..9baac7b 100644 --- a/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js +++ b/src/pages/DashboardBeneficiario/components/MyLatestSubmissionsTable/index.js @@ -178,16 +178,26 @@ const MyLatestSubmissionsTable = () => { header={header} emptyMessage={translationStrings.emptyMessage} onFilter={(e) => setFilters(e.filters)}> - + + body={dateEndBodyTemplate} + filter + filterElement={dateFilterTemplate}/> + body={dateModifyBodyTemplate} + filter + filterElement={dateFilterTemplate}/> 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/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js index ab5fe5a..0a8b59a 100644 --- a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js +++ b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js @@ -158,10 +158,15 @@ const PreInstructorDomandeTable = () => { emptyMessage={translationStrings.emptyMessage} onFilter={(e) => setFilters(e.filters)}> + { const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -34,12 +32,22 @@ 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({}); + const { + control, + handleSubmit, + formState: { errors }, + setValue, + register, + trigger, + getValues + } = useForm({ + defaultValues: useMemo(() => { + return formInitialData; + }, [formInitialData]), mode: 'onChange' + }); const goToArchivePage = () => { navigate(`/domande`); @@ -57,8 +65,15 @@ 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); storeSet.main.unsetAsyncRequest(); } else { ApplicationService.getApplication(id, getApplCallback, errGetCallback) @@ -85,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 : ''); @@ -111,55 +107,36 @@ 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 onSubmit = () => { }; - const headerNewComDialog = () => { - return {__('Aggiungi comunicazione', 'gepafin')} + 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 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) => { + const updateAmendmentCallback = (data) => { if (data.status === 'SUCCESS') { if (toast.current) { toast.current.show({ @@ -168,13 +145,11 @@ const DomandaBeneficiario = () => { detail: data.message }); } - setComms([...comms, getFormattedCommsData(data.data)]) - setIsVisibleNewCommDialog(false); } - setIsLoadingCommunication(false); + storeSet.main.unsetAsyncRequest(); } - const errCreateCommunicationCallback = (data) => { + const errUpdateAmendmentCallback = (data) => { if (toast.current && data.message) { toast.current.show({ severity: 'error', @@ -183,7 +158,7 @@ const DomandaBeneficiario = () => { }); } set404FromErrorResponse(data); - setIsLoadingCommunication(false); + storeSet.main.unsetAsyncRequest(); } return ( @@ -272,61 +247,53 @@ 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) => { + 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} - - {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 @@ -354,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(); const { id } = useParams(); @@ -40,6 +42,10 @@ 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 [motivation, setMotivation] = useState(''); const goToEvaluationsPage = () => { navigate('/domande'); @@ -57,6 +63,7 @@ const DomandaEditPreInstructor = () => { const getCallback = (data) => { if (data.status === 'SUCCESS') { setData(getFormattedData(data.data)); + setMotivation(data.data.motivation); } storeSet.main.unsetAsyncRequest(); } @@ -102,7 +109,7 @@ const DomandaEditPreInstructor = () => { const updateEvaluationValue = (value, path, maxValue) => { let finalValue = value; - if (maxValue) { + if (maxValue || maxValue === 0) { finalValue = value > maxValue ? maxValue : value; } @@ -152,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); } @@ -163,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); } @@ -256,6 +267,60 @@ 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'].includes(data.applicationStatus) + || (['ADMISSIBLE'].includes(data.applicationStatus) && fieldName !== 'criteria') + } + + const headerCompleteDialog = () => { + return 'approve' === operationType + ? {__('Confermare l\'approvazione', 'gepafin')} + : {__('Confermare il rifiuto', 'gepafin')}; + } + + const hideCompleteDialog = () => { + setIsVisibleCompleteDialog(false); + setOperationType(''); + setMotivation(''); + } + + const footerCompleteDialog = () => { + return
+
+ } + + const initiateApproving = () => { + setOperationType('approve'); + setIsVisibleCompleteDialog(true); + + } + + const initiateRejecting = () => { + setOperationType('reject'); + setIsVisibleCompleteDialog(true); + } + + const doCreateAppointment = () => { + // TODO + } + + const doMakeAdmisible = () => { + // TODO } useEffect(() => { @@ -325,13 +390,11 @@ const DomandaEditPreInstructor = () => {

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

-
- -
+

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

@@ -350,7 +413,7 @@ const DomandaEditPreInstructor = () => {
{ onClick={() => displayCriterionData(o.id)} aria-label={__('Mostra', 'gepafin')}/> : null}
@@ -571,6 +648,26 @@ const DomandaEditPreInstructor = () => { {criterionDataContent}
+ +
+ + setMotivation(e.htmlValue)} + style={{ height: 80 * 3, width: '100%' }} + /> +
+
+ : <> diff --git a/src/pages/Domande/components/AllDomandeTable/index.js b/src/pages/Domande/components/AllDomandeTable/index.js index 6e6a507..81fba5b 100644 --- a/src/pages/Domande/components/AllDomandeTable/index.js +++ b/src/pages/Domande/components/AllDomandeTable/index.js @@ -158,11 +158,17 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => { emptyMessage={translationStrings.emptyMessage} onFilter={(e) => setFilters(e.filters)}> + {
{ header={header} emptyMessage={translationStrings.emptyMessage} onFilter={(e) => setFilters(e.filters)}> - - + diff --git a/src/pages/ProfileCompany/index.js b/src/pages/ProfileCompany/index.js index fb25389..8dc0128 100644 --- a/src/pages/ProfileCompany/index.js +++ b/src/pages/ProfileCompany/index.js @@ -5,7 +5,7 @@ import { klona } from 'klona'; import { wrap } from 'object-path-immutable'; import { useForm } from 'react-hook-form'; import emailjs from '@emailjs/browser'; -import { useNavigate } from 'react-router-dom'; +//import { useNavigate } from 'react-router-dom'; // store import { storeSet, useStore, storeGet } from '../../store'; @@ -41,7 +41,7 @@ const ProfileCompany = () => { const [isVisibleRemoveDialog, setIsVisibleRemoveDialog] = useState(false); const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData; const toast = useRef(null); - const navigate = useNavigate(); + //const navigate = useNavigate(); const { control, diff --git a/src/pages/SoccorsoEditPreInstructor/components/SoccorsoComunications/index.js b/src/pages/SoccorsoEditPreInstructor/components/SoccorsoComunications/index.js new file mode 100644 index 0000000..fa644cf --- /dev/null +++ b/src/pages/SoccorsoEditPreInstructor/components/SoccorsoComunications/index.js @@ -0,0 +1,218 @@ +import React, { useEffect, useRef, useState } from 'react'; +import { __ } from '@wordpress/i18n'; +import { is, isEmpty, isNil } from 'ramda'; +import { wrap } from 'object-path-immutable'; + +// tools +import getDateFromISOstring from '../../../../helpers/getDateFromISOstring'; +import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; +import uniqid from '../../../../helpers/uniqid'; + +// store +import { storeGet } from '../../../../store'; + +// api +import CommunicationService from '../../../../service/communication-service'; + +// components +import { Button } from 'primereact/button'; +import { classNames } from 'primereact/utils'; +import { InputText } from 'primereact/inputtext'; +import { InputTextarea } from 'primereact/inputtextarea'; +import { Dialog } from 'primereact/dialog'; +import { Toast } from 'primereact/toast'; + +const SoccorsoComunications = ({ amendmentId, soccorsoStatus }) => { + const [comms, setComms] = useState([]); + const [isVisibleNewCommDialog, setIsVisibleNewCommDialog] = useState(false); + const [newCommData, setNewCommData] = useState({}); + const [isLoadingCommunication, setIsLoadingCommunication] = useState(false); + const toast = useRef(null); + + useEffect(() => { + if (amendmentId && amendmentId !== 0) { + setIsLoadingCommunication(true); + CommunicationService.getCommsByAmendmentId(amendmentId, getCommsCallback, errGetCommsCallback); + } + }, [amendmentId]); + + const getCommsCallback = (data) => { + if (data.status === 'SUCCESS') { + setComms(data.data.commentsList.map(o => getFormattedCommsData(o))); + } + setIsLoadingCommunication(false); + } + + const errGetCommsCallback = (data) => { + if (toast.current && data.message) { + toast.current.show({ + severity: 'error', + summary: '', + detail: data.message + }); + } + setIsLoadingCommunication(false); + } + + 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(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 = () => { }; @@ -397,8 +296,6 @@ const SoccorsoEditPreInstructor = () => { AmendmentsService.getSoccorsoById(getCallback, errGetCallback, [['id', soccorsoEntityId]]); }, [amendmentId]); - console.log('formInitialData', formInitialData) - return (
@@ -473,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}

-
--
- -
@@ -513,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 { /> }) : null} - - {/*
@@ -598,36 +454,6 @@ const SoccorsoEditPreInstructor = () => {
- -
- - updateNewCommData(e.target.value, 'title')}/> - - - updateNewCommData(e.target.value, 'comment')}/> -
-
-