- added company name to tables with applications;

- added form and file inputs to the page of editing/viewing soccorso for beneficiary;
This commit is contained in:
Vitalii Kiiko
2024-11-21 08:44:22 +01:00
parent 7c4b511dac
commit 7c2feb20c7
11 changed files with 217 additions and 85 deletions

View File

@@ -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')}*
<span>{__('(almeno 1 elemento)', 'gepafin')}</span></>}
config={{
validate: {

View File

@@ -172,9 +172,15 @@ const DraftApplicationsTable = () => {
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
onFilter={(e) => setFilters(e.filters)}>
<Column field="id" header={__('ID domanda', 'gepafin')}
filter filterPlaceholder={__('Cerca', 'gepafin')}
sortable
filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column field="callTitle" header={__('Bando', 'gepafin')} filter
<Column field="callTitle" header={__('Bando', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column field="companyName" header={__('Azienda', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
{/*<Column header={__('Scadenza', 'gepafin')} filterField="callEndDate" dataType="date"
@@ -184,7 +190,8 @@ const DraftApplicationsTable = () => {
style={{ minWidth: '8rem' }}
body={dateModifyBodyTemplate} filter filterElement={dateFilterTemplate}/>*/}
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
style={{ minWidth: '7rem' }} body={statusBodyTemplate} filter
style={{ minWidth: '7rem' }} body={statusBodyTemplate}
filter
filterElement={statusFilterTemplate}/>
<Column header={__('Progressi', 'gepafin')}
style={{ minWidth: '10rem' }} field="progress" body={progressBodyTemplate}/>

View File

@@ -177,16 +177,26 @@ const MyLatestSubmissionsTable = () => {
header={header}
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
onFilter={(e) => setFilters(e.filters)}>
<Column field="callTitle" header={__('Bando', 'gepafin')} filter filterPlaceholder={__('Cerca il nome', 'gepafin')}
<Column field="callTitle" header={__('Bando', 'gepafin')}
sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column field="companyName" header={__('Azienda', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column header={__('Scadenza', 'gepafin')} filterField="callEndDate" dataType="date"
style={{ minWidth: '8rem' }}
body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/>
body={dateEndBodyTemplate}
filter
filterElement={dateFilterTemplate}/>
<Column header={__('Ultima modifica', 'gepafin')} filterField="modifiedDate" dataType="date"
style={{ minWidth: '8rem' }}
body={dateModifyBodyTemplate} filter filterElement={dateFilterTemplate}/>
body={dateModifyBodyTemplate}
filter
filterElement={dateFilterTemplate}/>
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
style={{ minWidth: '7rem' }} body={statusBodyTemplate} filter
style={{ minWidth: '7rem' }} body={statusBodyTemplate}
filterElement={statusFilterTemplate}/>
<Column header={__('Progressi', 'gepafin')}
style={{ minWidth: '10rem' }} field="progress" body={progressBodyTemplate}/>

View File

@@ -143,10 +143,15 @@ const PreInstructorDomandeTable = () => {
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
onFilter={(e) => setFilters(e.filters)}>
<Column field="applicationId" header={__('ID domanda', 'gepafin')}
filter filterPlaceholder={__('Cerca', 'gepafin')}
sortable filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '6rem' }}/>
<Column field="callName" header={__('Bando', 'gepafin')}
filter filterPlaceholder={__('Cerca', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column field="companyName" header={__('Azienda', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column header={__('Data ricezione', 'gepafin')} filterField="submissionDate" dataType="date"
style={{ minWidth: '8rem' }}

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
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';
@@ -27,6 +27,9 @@ 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';
const DomandaBeneficiario = () => {
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 (
<div className="appPage">
<div className="appPage__pageHeader">
@@ -273,18 +352,6 @@ const DomandaBeneficiario = () => {
{data.id
? <div className="appPageSection">
<h2>{__('Dettagli Richiesta', 'gepafin')}</h2>
<h3>{__('Documenti Richiesti', 'gepafin')}</h3>
<ol className="appPageSection__list">
{data.formFields
? data.formFields.map((o, i) => <li key={o.fieldId}
style={{ flexDirection: 'row' }}>
<span>{o.label}</span>
</li>) : null}
</ol>
</div> : null}
{data.id
? <div className="appPageSection">
<h3>{__('Note e spiegazioni', 'gepafin')}</h3>
<div className="appPageSection__withBorder grey ql-editor"
style={{ minHeight: '200px' }}>
@@ -292,6 +359,44 @@ const DomandaBeneficiario = () => {
</div>
</div> : null}
{data.id
? <div className="appPageSection">
<h3>{__('Documenti Richiesti', 'gepafin')}</h3>
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
{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 <FormField
key={o.fieldId}
disabled={data.status === 'CLOSE'}
type="fileupload"
setDataFn={setValue}
saveFormCallback={doUpdateAmendment}
fieldName={o.fieldId}
label={o.label}
control={control}
errors={errors}
defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []}
accept={[]}
doctype="document"
register={register}
sourceId={data.applicationId}
source="application"
multiple={true}
/>
}) : null}
</form>
{/*<ol className="appPageSection__list">
{data.formFields
? data.formFields.map((o, i) => <li key={o.fieldId}
style={{ flexDirection: 'row' }}>
<span>{o.label}</span>
</li>) : null}
</ol>*/}
</div> : null}
{data.id
? <div className="appPageSection">
<h2>{__('Comunicazioni', 'gepafin')}</h2>

View File

@@ -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 = () => {
</p>
</div>
<div className="appPageSection">
</div>
<div className="appPageSection"></div>
<div className="appPageSection">
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
@@ -350,7 +352,7 @@ const DomandaEditPreInstructor = () => {
<td>
<div className="p-inputgroup">
<InputNumber
disabled={data.status === 'CLOSE'}
disabled={shouldDisableField('criteria')}
placeholder={__('Punteggio', 'gepafin')}
keyfilter="int"
value={o.score}
@@ -373,7 +375,7 @@ const DomandaEditPreInstructor = () => {
onClick={() => displayCriterionData(o.id)}
aria-label={__('Mostra', 'gepafin')}/> : null}
<Button icon="pi pi-thumbs-up" rounded outlined
disabled={data.status === 'CLOSE'}
disabled={shouldDisableField('criteria')}
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
onClick={() => updateEvaluationValue(
true,
@@ -381,7 +383,7 @@ const DomandaEditPreInstructor = () => {
)}
aria-label={__('Su', 'gepafin')}/>
<Button icon="pi pi-thumbs-down" rounded outlined
disabled={data.status === 'CLOSE'}
disabled={shouldDisableField('criteria')}
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
onClick={() => updateEvaluationValue(
false,
@@ -422,7 +424,7 @@ const DomandaEditPreInstructor = () => {
<div className="appPageSection__checklist">
{data.checklist.map((o, i) => <div key={o.id}>
<Checkbox
disabled={data.status === 'CLOSE'}
disabled={shouldDisableField('checklist')}
inputId={`checklist_${o.id}`}
onChange={(e) => updateEvaluationValue(
e.checked,
@@ -438,7 +440,7 @@ const DomandaEditPreInstructor = () => {
<div>
<Editor
value={data.note}
readOnly={data.status === 'CLOSE'}
readOnly={shouldDisableField('note')}
placeholder={__('Digita qui il messagio', 'gepafin')}
headerTemplate={header}
onTextChange={(e) => updateEvaluationValue(
@@ -466,7 +468,7 @@ const DomandaEditPreInstructor = () => {
outlined severity="info"
aria-label={__('Mostra', 'gepafin')}/> : null}
<Button icon="pi pi-thumbs-up" rounded outlined
disabled={data.status === 'CLOSE'}
disabled={shouldDisableField('files')}
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
onClick={() => updateEvaluationValue(
true,
@@ -474,7 +476,7 @@ const DomandaEditPreInstructor = () => {
)}
aria-label={__('Su', 'gepafin')}/>
<Button icon="pi pi-thumbs-down" rounded outlined
disabled={data.status === 'CLOSE'}
disabled={shouldDisableField('files')}
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
onClick={() => updateEvaluationValue(
false,

View File

@@ -157,11 +157,17 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
onFilter={(e) => setFilters(e.filters)}>
<Column field="id" header={__('ID domanda', 'gepafin')}
filter filterPlaceholder={__('Cerca', 'gepafin')}
sortable
filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column field="callTitle" header={__('Bando', 'gepafin')}
filter filterPlaceholder={__('Cerca', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '10rem' }}/>
<Column field="companyName" header={__('Azienda', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column header={__('Data Ricezione', 'gepafin')}
filterField="submissionDate" dataType="date"
style={{ minWidth: '8rem' }}

View File

@@ -169,7 +169,7 @@ const Domande = () => {
<div className="appForm__field">
<label
className={classNames({ 'p-error': isEmpty(chosenUser) || chosenUser === 0 || chosenApplication === 0 })}>
{__('Pre-istruttore', 'gepafin')}*
{__('Istruttore', 'gepafin')}*
</label>
<Dropdown
value={chosenUser}

View File

@@ -171,17 +171,23 @@ const BeneficiarioDomandeTable = () => {
header={header}
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
onFilter={(e) => setFilters(e.filters)}>
<Column field="id" header={__('ID domanda', 'gepafin')} filter
<Column field="id" header={__('ID domanda', 'gepafin')}
sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '6rem' }}/>
<Column field="callTitle" header={__('Titolo bando', 'gepafin')} filter
<Column field="callTitle" header={__('Titolo bando', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column field="companyName" header={__('Azienda', 'gepafin')}
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
<Column header={__('Data di invio', 'gepafin')} filterField="submissionDate" dataType="date"
style={{ minWidth: '8rem' }}
body={dateSubmissionBodyTemplate} filter filterElement={dateFilterTemplate}/>
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
style={{ minWidth: '7rem' }} body={statusBodyTemplate} filter
style={{ minWidth: '7rem' }} body={statusBodyTemplate}
filterElement={statusFilterTemplate}/>
<Column header={__('Esito', 'gepafin')}
style={{ minWidth: '7rem' }} field="progress" body={progressBodyTemplate}/>

View File

@@ -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,

View File

@@ -397,8 +397,6 @@ const SoccorsoEditPreInstructor = () => {
AmendmentsService.getSoccorsoById(getCallback, errGetCallback, [['id', soccorsoEntityId]]);
}, [amendmentId]);
console.log('formInitialData', formInitialData)
return (
<div className="appPage">
<div className="appPage__pageHeader">
@@ -536,13 +534,6 @@ const SoccorsoEditPreInstructor = () => {
/>
}) : null}
</form>
{/*<Button
style={{ marginTop: 30 }}
type="button"
disabled={data.status === 'CLOSE'}
onClick={doUpdateAmendment}
label={__('Aggiorna', 'gepafin')}/>*/}
</div>
<div className="appPage__spacer"></div>