Merge branch 'develop' into master-sync/fields-calc-feature
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect} from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { is, uniq, isNil, isEmpty } from 'ramda';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@@ -30,6 +30,8 @@ import { Button } from 'primereact/button';
|
||||
// i18n
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
import isDateTimeInPast from '../../../../helpers/isDateTimeInPast';
|
||||
import isDateTimeInFuture from '../../../../helpers/isDateTimeInFuture';
|
||||
import { Badge } from 'primereact/badge';
|
||||
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
@@ -182,18 +184,22 @@ const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||
|
||||
const rowExpansionTemplate = (data) => {
|
||||
const isCallExpired = isDateTimeInPast(data.dates[1], data.endTime);
|
||||
const isCallScheduled = isDateTimeInFuture(data.dates[0], data.startTime);
|
||||
|
||||
return (
|
||||
<div className="p-3">
|
||||
{renderHtmlContent(data.descriptionShort)}
|
||||
<p>{__('Scadenza', 'gepafin')}: {getDateFromISOstring(data.dates[1])}</p>
|
||||
{!isCallExpired && !isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && (!data.confidi
|
||||
{!isCallExpired && !isCallScheduled && !isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && (!data.confidi
|
||||
|| (data.confidi && data.id === 6 && REACT_APP_HUB_ID === 'p4lk3bcx1RStqTaIVVbXs'))
|
||||
? <Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{__('Partecipa', 'gepafin')}
|
||||
</Button> : null}
|
||||
{isCallExpired
|
||||
? <p>{__('È scaduto', 'gepafin')}</p> : null}
|
||||
{isCallExpired || (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && data.confidi
|
||||
? <p><Badge value={__('È scaduto', 'gepafin')} severity="danger"></Badge></p> : null}
|
||||
{isCallScheduled
|
||||
? <p><Badge value={sprintf(__('È programmato. Inizia: %s %s', 'gepafin'), getDateFromISOstring(data.dates[0]), data.startTime)}></Badge></p> : null}
|
||||
{isCallExpired || isCallScheduled || (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && data.confidi
|
||||
&& (data.id !== 6 || (data.id === 6 && REACT_APP_HUB_ID !== 'p4lk3bcx1RStqTaIVVbXs')))
|
||||
? <Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{__('Mostra', 'gepafin')}
|
||||
|
||||
@@ -685,7 +685,10 @@ const BandoApplication = () => {
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
//console.log('validations', validations, o.name)
|
||||
|
||||
/*if (o.name === 'table') {
|
||||
console.log('value:', values[o.id] ? values[o.id] : '')
|
||||
}*/
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div key={o.id}>
|
||||
@@ -695,6 +698,7 @@ const BandoApplication = () => {
|
||||
</div>
|
||||
: <FormField
|
||||
key={o.id}
|
||||
disabled={isExpired}
|
||||
readOnly={formula && !isEmpty(formula.value)}
|
||||
type={o.name}
|
||||
fieldName={o.id}
|
||||
|
||||
@@ -27,6 +27,9 @@ import { storeSet } from '../../../../store';
|
||||
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
||||
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
|
||||
import formatDateString from '../../../../helpers/formatDateString';
|
||||
import EvaluationFormsService from '../../../../service/evaluation-forms-service';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, getFormErrors, status }, ref) {
|
||||
const navigate = useNavigate();
|
||||
@@ -50,7 +53,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
const values = getValues();
|
||||
const toast = useRef(null);
|
||||
|
||||
const onSubmit = () => {};
|
||||
const onSubmit = () => {
|
||||
};
|
||||
|
||||
const onSaveDraft = () => {
|
||||
trigger();
|
||||
@@ -115,7 +119,12 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
const values = getValues();
|
||||
if (!values.id && data.data.id) {
|
||||
navigate(`/bandi/${data.data.id}`);
|
||||
storeSet.main.setAsyncRequest();
|
||||
const sampleFormData = {
|
||||
label: `Evaluation form for call #${data.data.id}`,
|
||||
content: []
|
||||
}
|
||||
EvaluationFormsService.createFormForCall(data.data.id, sampleFormData, createFormCallback, errCreateFormCallback)
|
||||
} else {
|
||||
setFormInitialData(data.data);
|
||||
setInitialData(data.data);
|
||||
@@ -135,6 +144,18 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const createFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
navigate(`/bandi/${resp.data.callId}`);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errCreateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
navigate(`/bandi/${values.id}/preview`);
|
||||
}
|
||||
@@ -180,7 +201,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
![
|
||||
'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold',
|
||||
'aimedTo', 'criteria', 'docs', 'checklist', 'faq', 'amount', 'amountMin', 'amountMax',
|
||||
'email', 'phoneNumber', 'checkList', 'images'
|
||||
'email', 'phoneNumber', 'checkList', 'images', 'numberOfCheck', 'productId'
|
||||
].includes(fieldName)
|
||||
}
|
||||
|
||||
@@ -459,6 +480,35 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="appForm__cols">
|
||||
<FormField
|
||||
type="numberinput"
|
||||
disabled={shouldDisableField('numberOfCheck')}
|
||||
fieldName="numberOfCheck"
|
||||
label={__('Quantità dei checklist per creare un soccorso', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
defaultValue={values['numberOfCheck']}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
}}
|
||||
/>
|
||||
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <FormField
|
||||
type="numberinput"
|
||||
disabled={shouldDisableField('productId')}
|
||||
fieldName="productId"
|
||||
label={__('Prodotto ID dentro Odessa', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
defaultValue={values['productId']}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
}}
|
||||
/> : null}
|
||||
</div>
|
||||
|
||||
<FormFieldRepeaterFaq
|
||||
data={values['faq']}
|
||||
disabled={shouldDisableField('faq')}
|
||||
|
||||
@@ -94,7 +94,11 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
delete formData.endDate;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
BandoService.updateBandoStep2(formData.id, formData, createCallback, errCreateCallback);
|
||||
if (values.evaluationVersion === 'V1') {
|
||||
BandoService.updateBandoStep2(formData.id, formData, createCallback, errCreateCallback);
|
||||
} else if (values.evaluationVersion === 'V2') {
|
||||
BandoService.updateBandoStep2V2(formData.id, formData, createCallback, errCreateCallback);
|
||||
}
|
||||
}
|
||||
|
||||
const createCallback = (data) => {
|
||||
@@ -221,7 +225,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
return (
|
||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
<UnsavedChangesDetector getValuesFn={getValues}/>
|
||||
<FormFieldRepeaterCriteria
|
||||
{values.evaluationVersion === 'V1'
|
||||
? <FormFieldRepeaterCriteria
|
||||
data={values}
|
||||
disabled={shouldDisableField('criteria')}
|
||||
setDataFn={setValue}
|
||||
@@ -238,7 +243,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
.filter(o => isEmpty(o.value) || isEmpty(o.score)).length === 0
|
||||
|| __('Non lasciare il valore vuoto', 'gepafin')
|
||||
}
|
||||
}}/>
|
||||
}}/> : null}
|
||||
|
||||
<FormField
|
||||
type="fileuploadasync"
|
||||
@@ -275,7 +280,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
multiple={false}
|
||||
/>
|
||||
|
||||
<FormFieldRepeater
|
||||
{values.evaluationVersion === 'V1'
|
||||
? <FormFieldRepeater
|
||||
data={values['checkList']}
|
||||
disabled={shouldDisableField('checkList')}
|
||||
setDataFn={setValue}
|
||||
@@ -292,7 +298,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
.filter(o => isEmpty(o.value)).length === 0 || __('Non lasciare il valore vuoto', 'gepafin')
|
||||
}
|
||||
}}
|
||||
/>
|
||||
/> : null}
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
|
||||
149
src/pages/BandoEdit/components/BandoEditFormStep3/index.js
Normal file
149
src/pages/BandoEdit/components/BandoEditFormStep3/index.js
Normal file
@@ -0,0 +1,149 @@
|
||||
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { klona } from 'klona';
|
||||
import { DndProvider } from 'react-dnd';
|
||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
|
||||
// api
|
||||
import EvaluationFormsService from '../../../../service/evaluation-forms-service';
|
||||
import FormsService from '../../../../service/forms-service';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
||||
|
||||
// components
|
||||
import BandoEditFormActions from '../BandoEditFormActions';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import FormBuilder from '../../../BandoFormsEdit/components/FormBuilder';
|
||||
//import { elementItems } from '../../../../tempData';
|
||||
|
||||
|
||||
const BandoEditFormStep3 = forwardRef(function () {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams();
|
||||
const [formName, setFormName] = useState('');
|
||||
const [bandoStatus, setBandoStatus] = useState('');
|
||||
const toast = useRef(null);
|
||||
|
||||
const getBandoId = () => {
|
||||
const parsed = parseInt(id)
|
||||
return !isNaN(parsed) ? parsed : 0;
|
||||
}
|
||||
|
||||
const onSaveDraft = () => {
|
||||
const content = storeGet.main.formElements();
|
||||
const formId = storeGet.main.formId();
|
||||
const formData = {
|
||||
label: formName,
|
||||
content
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
EvaluationFormsService.updateForm(formId, formData, updateFormCallback, errUpdateFormCallback)
|
||||
}
|
||||
|
||||
const updateFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setBandoStatus(resp.data.callStatus);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('Il bando è stato aggiornato correttamente!', 'gepafin')
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errUpdateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
const bandoId = getBandoId();
|
||||
navigate(`/bandi/${bandoId}/preview`);
|
||||
}
|
||||
|
||||
const openPreviewEvaluation = () => {
|
||||
const bandoId = getBandoId();
|
||||
navigate(`/bandi/${bandoId}/preview-evaluation`);
|
||||
}
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetElementItemsCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.formId(resp.data.id);
|
||||
storeSet.main.formLabel(resp.data.label);
|
||||
setFormName(resp.data.label);
|
||||
setBandoStatus(resp.data.callStatus);
|
||||
const elements = klona(resp.data.content);
|
||||
storeSet.main.formElements(elements);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
EvaluationFormsService.getFormForCall(id, getFormCallback, errGetFormCallback)
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formId(0);
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="appForm">
|
||||
<div className="appPageSection">
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<FormBuilder callStatus={bandoStatus} context="call"/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<Toast ref={toast} />
|
||||
<BandoEditFormActions
|
||||
id={id}
|
||||
status={bandoStatus}
|
||||
submitFn={onSaveDraft}
|
||||
openPreview={openPreview}
|
||||
openPreviewEvaluation={openPreviewEvaluation}/>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
export default BandoEditFormStep3;
|
||||
@@ -23,6 +23,7 @@ import { Messages } from 'primereact/messages';
|
||||
import FormsService from '../../service/forms-service';
|
||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import BandoEditFormStep3 from './components/BandoEditFormStep3';
|
||||
|
||||
const BandoEdit = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
@@ -35,28 +36,45 @@ const BandoEdit = () => {
|
||||
const bandoMsgs = useRef(null);
|
||||
const toast = useRef(null);
|
||||
|
||||
const stepItems = [
|
||||
{
|
||||
label: __('Testi', 'gepafin'),
|
||||
command: () => {
|
||||
if (activeStep === 0) {
|
||||
return false
|
||||
const stepItems = (evalProcessVer) => {
|
||||
let steps = [
|
||||
{
|
||||
label: __('Testi', 'gepafin'),
|
||||
command: () => {
|
||||
if (activeStep === 0) {
|
||||
return false
|
||||
}
|
||||
bandoMsgs.current.clear();
|
||||
goToStep(0);
|
||||
}
|
||||
bandoMsgs.current.clear();
|
||||
goToStep(0);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: __('Gestione', 'gepafin'),
|
||||
command: () => {
|
||||
if (activeStep === 1) {
|
||||
return false
|
||||
},
|
||||
{
|
||||
label: __('Gestione', 'gepafin'),
|
||||
command: () => {
|
||||
if (activeStep === 1) {
|
||||
return false
|
||||
}
|
||||
bandoMsgs.current.clear();
|
||||
goToStep(1);
|
||||
}
|
||||
bandoMsgs.current.clear();
|
||||
goToStep(1);
|
||||
}
|
||||
];
|
||||
|
||||
if (evalProcessVer === 'V2') {
|
||||
steps.push({
|
||||
label: __('Valutazione', 'gepafin'),
|
||||
command: () => {
|
||||
if (activeStep === 2) {
|
||||
return false
|
||||
}
|
||||
bandoMsgs.current.clear();
|
||||
goToStep(2);
|
||||
}
|
||||
})
|
||||
}
|
||||
];
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
const goToStep = (step) => {
|
||||
setActiveStep(step);
|
||||
@@ -238,7 +256,8 @@ const BandoEdit = () => {
|
||||
|
||||
if (bandoId === 0) {
|
||||
setData({
|
||||
status: null
|
||||
status: null,
|
||||
evaluationVersion: 'V2'
|
||||
});
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
|
||||
@@ -274,7 +293,7 @@ const BandoEdit = () => {
|
||||
|
||||
{!isEmpty(data)
|
||||
? <Steps
|
||||
model={stepItems}
|
||||
model={stepItems(data.evaluationVersion)}
|
||||
activeIndex={activeStep}
|
||||
readOnly={isNil(data.status)}/>
|
||||
: null}
|
||||
@@ -293,6 +312,9 @@ const BandoEdit = () => {
|
||||
{activeStep === 1
|
||||
? <BandoEditFormStep2 initialData={data} setInitialData={setData} ref={formRef} status={data.status}/>
|
||||
: null}
|
||||
{activeStep === 2 && data.evaluationVersion === 'V2'
|
||||
? <BandoEditFormStep3/>
|
||||
: null}
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Crea o modifica il Form compilabile dal Beneficiario', 'gepafin')}</h2>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useDrag, useDrop } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import uniqid from '../../../../helpers/uniqid';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
import { Tag } from 'primereact/tag';
|
||||
@@ -14,11 +18,14 @@ import BuilderElementProperLabel from '../BuilderElementProperLabel';
|
||||
|
||||
const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const draggingElementId = useStore().main.draggingElementId();
|
||||
const selectedElement = useStore().main.selectedElement();
|
||||
const ref = useRef(null);
|
||||
const elements = useStore().main.formElements();
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
const [isFormula, setIsFormula] = useState('secondary');
|
||||
const [variableName, setVariableName] = useState('secondary');
|
||||
const [formulaName, setFormulaName] = useState('secondary');
|
||||
const [isRequestedAmount, setIsRequestedAmount] = useState(false);
|
||||
const [isDelegation, setIsDelegation] = useState(false);
|
||||
|
||||
@@ -93,11 +100,33 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
storeSet.main.moveElement(dragIndex, hoverIndex, item);
|
||||
}
|
||||
|
||||
const openSettings = (id) => {
|
||||
const openSettings = () => {
|
||||
storeSet.main.activeElement(id);
|
||||
}
|
||||
|
||||
const remove = (id) => {
|
||||
const selectElement = () => {
|
||||
storeSet.main.selectedElement(id);
|
||||
}
|
||||
|
||||
const duplicateElement = useCallback(() => {
|
||||
const duplicatedElement = head(elements.filter(o => o.id === id));
|
||||
|
||||
if (duplicatedElement) {
|
||||
const copyElement = klona(duplicatedElement);
|
||||
copyElement.settings = copyElement.settings.map((o) => {
|
||||
if (o.name === 'label') {
|
||||
o.value = `Copy - ${o.value}`
|
||||
}
|
||||
return o;
|
||||
})
|
||||
copyElement.id = uniqid();
|
||||
const originalIndex = elements.map(o => o.id).indexOf(id);
|
||||
const newElements = [...elements].toSpliced(originalIndex + 1, 0, copyElement);
|
||||
storeSet.main.formElements(newElements);
|
||||
}
|
||||
}, [elements]);
|
||||
|
||||
const remove = () => {
|
||||
storeSet.main.removeElement(id);
|
||||
}
|
||||
|
||||
@@ -112,10 +141,12 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
setIsVariable('warning');
|
||||
setVariableName(variable.value)
|
||||
}
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
setIsFormula('warning');
|
||||
setFormulaName(formula.value)
|
||||
}
|
||||
|
||||
if (isRequestedAmount && !isEmpty(isRequestedAmount.value) && isRequestedAmount.value) {
|
||||
@@ -132,14 +163,18 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
? <div ref={ref} className="formBuilder__elementNew">
|
||||
{__('lascia qui', 'gepafin')}
|
||||
</div>
|
||||
: <div ref={ref} className="formBuilder__element" style={{ opacity }} data-handler-id={handlerId}>
|
||||
: <div ref={ref}
|
||||
className={`formBuilder__element${selectedElement === id ? ' selected' : ''}`}
|
||||
style={{ opacity }}
|
||||
onClick={selectElement}
|
||||
data-handler-id={handlerId}>
|
||||
<div className="meta">
|
||||
<div className="tagHeader">
|
||||
<Tag value={label} severity="info"/>
|
||||
{['numberinput', 'criteria_table'].includes(name)
|
||||
? <Tag value="var" severity={isVariable}/> : null}
|
||||
? <Tag value="var" severity={isVariable} title={variableName}/> : null}
|
||||
{name === 'numberinput'
|
||||
? <Tag value="f(x)" severity={isFormula}/> : null}
|
||||
? <Tag value="f(x)" severity={isFormula} title={formulaName}/> : null}
|
||||
{isRequestedAmount
|
||||
? <Tag value="importo" severity={isRequestedAmount}/> : null}
|
||||
{isDelegation
|
||||
@@ -148,8 +183,9 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<Button icon="pi pi-cog" onClick={() => openSettings(id)} outlined severity="info"/>
|
||||
<Button icon="pi pi-trash" disabled={bandoStatus === 'PUBLISH'} onClick={() => remove(id)} outlined severity="danger"/>
|
||||
<Button icon="pi pi-clone" onClick={duplicateElement} outlined severity="success"/>
|
||||
<Button icon="pi pi-cog" onClick={openSettings} outlined severity="info"/>
|
||||
<Button icon="pi pi-trash" disabled={bandoStatus === 'PUBLISH'} onClick={remove} outlined severity="danger"/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -36,7 +36,8 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
table_columns: '',
|
||||
criteria_table_columns: '',
|
||||
variable: __('Variabile (lettere, cifre e "_"; il primo carattere deve essere una lettera!)', 'gepafin'),
|
||||
formula: __('Formula di calcolo automatico', 'gepafin')
|
||||
formula: __('Formula di calcolo automatico', 'gepafin'),
|
||||
isChecklistItem: __('Fa parte di "checklist"?', 'gepafin'),
|
||||
}
|
||||
|
||||
const settingDescription = {
|
||||
@@ -104,7 +105,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
name={setting.name}
|
||||
bandoStatus={bandoStatus}
|
||||
setDataFn={updateDataFn}/>
|
||||
} else if (['isRequestedAmount', 'isDelegation'].includes(setting.name)) {
|
||||
} else if (['isRequestedAmount', 'isDelegation', 'isChecklistItem'].includes(setting.name)) {
|
||||
return <InputSwitch
|
||||
checked={setting.value}
|
||||
onChange={(e) => changeFn(e.value, setting.name)}/>
|
||||
|
||||
@@ -277,14 +277,14 @@ const ElementSettingCriteriaTableColumns = ({
|
||||
<>
|
||||
<div className="formElementSettings__repeater">
|
||||
{stateFieldData.length > 0
|
||||
? <div className="formElementSettings__repeaterItem">
|
||||
? <div className="formElementSettings__repeaterItem tableRow">
|
||||
<div>{__('Colonne', 'gepafin')}</div>
|
||||
<div>{__('Tipo', 'gepafin')}</div>
|
||||
<div>{__('Calcola', 'gepafin')}</div>
|
||||
<div>{__('Predefinito?', 'gepafin')}</div>
|
||||
<div></div>
|
||||
</div> : null}
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem">
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem tableRow">
|
||||
{properFields(o, i)}
|
||||
</div>)}
|
||||
<Button
|
||||
|
||||
@@ -268,14 +268,14 @@ const ElementSettingTableColumns = ({
|
||||
<>
|
||||
<div className="formElementSettings__repeater">
|
||||
{stateFieldData.length > 0
|
||||
? <div className="formElementSettings__repeaterItem">
|
||||
? <div className="formElementSettings__repeaterItem tableRow">
|
||||
<div>{__('Colonne', 'gepafin')}</div>
|
||||
<div>{__('Tipo', 'gepafin')}</div>
|
||||
<div>{__('Calcola', 'gepafin')}</div>
|
||||
<div>{__('Predefinito?', 'gepafin')}</div>
|
||||
<div></div>
|
||||
</div> : null}
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem">
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem tableRow">
|
||||
{properFields(o, i)}
|
||||
</div>)}
|
||||
<Button
|
||||
|
||||
@@ -19,7 +19,7 @@ import { MultiSelect } from 'primereact/multiselect';
|
||||
|
||||
import { dynamicDataOptions } from '../../../../configData';
|
||||
|
||||
const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
const BuilderElementSettings = ({ closeSettingsFn, callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
const criteriaOptions = useStore().main.bandoCriteria();
|
||||
@@ -123,6 +123,10 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
});
|
||||
}
|
||||
|
||||
settings = settings.filter(o => context === 'call'
|
||||
? !['isRequestedAmount', 'isDelegation', ''].includes(o.name)
|
||||
: !['isChecklistItem'].includes(o.name));
|
||||
|
||||
if (chosen) {
|
||||
setActiveElementData(klona(chosen));
|
||||
setSettings(settings);
|
||||
@@ -149,11 +153,11 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
.map((o) => <ElementSetting
|
||||
key={o.name}
|
||||
setting={o}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
changeFn={onChange}
|
||||
updateDataFn={onUpdateOptions}/>)
|
||||
: null}
|
||||
{!isNil(dynamicDataOptions[activeElementData.name])
|
||||
{!isNil(dynamicDataOptions[activeElementData.name]) && context === 'application'
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor="dynamicData">{__('Dati dinamici', 'gepafin')}</label>
|
||||
<Dropdown
|
||||
@@ -220,7 +224,8 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
</div> : null}
|
||||
</div>) : null}
|
||||
</TabPanel> : null}
|
||||
<TabPanel header={__('Criteri', 'gepafin')}>
|
||||
{context === 'application'
|
||||
? <TabPanel header={__('Criteri', 'gepafin')}>
|
||||
<div className="formElementSettings__field">
|
||||
<label htmlFor="criteria">{__('Criteri di valutazione', 'gepafin')}</label>
|
||||
<MultiSelect
|
||||
@@ -233,7 +238,7 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
display="chip"
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
</div>
|
||||
</TabPanel>
|
||||
</TabPanel> : null}
|
||||
{settings
|
||||
&& settings
|
||||
.filter(o => ['variable', 'formula'].includes(o.name)).length > 0
|
||||
@@ -244,7 +249,7 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
.map((o) => <ElementSetting
|
||||
key={o.name}
|
||||
setting={o}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
changeFn={onChange}
|
||||
updateDataFn={onUpdateOptions}/>)
|
||||
: null}
|
||||
|
||||
@@ -13,7 +13,7 @@ import BuilderElementSettings from '../BuilderElementSettings';
|
||||
import BuilderDropzone from '../BuilderDropzone';
|
||||
import BlockingOverlay from '../../../../components/BlockingOverlay';
|
||||
|
||||
const FormBuilder = ({ bandoStatus }) => {
|
||||
const FormBuilder = ({ callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const elementItems = useStore().main.elementItems();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
@@ -27,10 +27,10 @@ const FormBuilder = ({ bandoStatus }) => {
|
||||
id={field.id}
|
||||
label={field.label}
|
||||
name={field.name}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
/>
|
||||
)
|
||||
}, [bandoStatus]);
|
||||
}, [callStatus]);
|
||||
|
||||
const renderItem = useCallback((item) => {
|
||||
return (
|
||||
@@ -58,7 +58,9 @@ const FormBuilder = ({ bandoStatus }) => {
|
||||
<>
|
||||
<Sidebar visible={!isEmpty(activeElement)} onHide={closeSettings} dismissable={false} className="formBuilder__elementSettings">
|
||||
<h2>{__('Impostazioni del campo modulo', 'gepafin')}</h2>
|
||||
{!isEmpty(activeElement) ? <BuilderElementSettings closeSettingsFn={closeSettings} bandoStatus={bandoStatus}/> : null}
|
||||
{!isEmpty(activeElement)
|
||||
? <BuilderElementSettings closeSettingsFn={closeSettings} callStatus={callStatus} context={context}/>
|
||||
: null}
|
||||
</Sidebar>
|
||||
<div className="formBuilder">
|
||||
<div className="formBuilder__main">
|
||||
|
||||
@@ -24,7 +24,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import BandoService from '../../service/bando-service';
|
||||
|
||||
// TODO temp data
|
||||
import { elementItems } from '../../tempData';
|
||||
//import { elementItems } from '../../tempData';
|
||||
|
||||
const BandoFormsEdit = () => {
|
||||
const { id, formId } = useParams();
|
||||
@@ -110,7 +110,6 @@ const BandoFormsEdit = () => {
|
||||
|
||||
const formCreateCallback = (data, shouldRedirect) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
const bandoId = getBandoId();
|
||||
if (shouldRedirect) {
|
||||
navigate(`/bandi/${bandoId}/forms/${data.data.id}/preview`);
|
||||
@@ -127,6 +126,7 @@ const BandoFormsEdit = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errFormCreateCallback = (data) => {
|
||||
@@ -215,13 +215,15 @@ const BandoFormsEdit = () => {
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(data.data
|
||||
.filter(o => o.id !== 22)
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetElementItemsCallbacks = (data) => {
|
||||
const errGetElementItemsCallback = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -261,7 +263,7 @@ const BandoFormsEdit = () => {
|
||||
const bandoFormId = !isNaN(parsedFormId) ? parsedFormId : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallback);
|
||||
|
||||
if (bandoFormId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
@@ -276,6 +278,8 @@ const BandoFormsEdit = () => {
|
||||
storeSet.main.formLabel('');
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.bandoCriteria([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
}
|
||||
}, [id, formId]);
|
||||
|
||||
@@ -317,7 +321,7 @@ const BandoFormsEdit = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<FormBuilder bandoStatus={bandoStatus}/>
|
||||
<FormBuilder callStatus={bandoStatus} context="application"/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
import isDateTimeInPast from '../../helpers/isDateTimeInPast';
|
||||
|
||||
// api
|
||||
import BandoService from '../../service/bando-service';
|
||||
import FaqItemService from '../../service/faq-item-service';
|
||||
import ApplicationService from '../../service/application-service';
|
||||
import PreferredBandoService from '../../service/preferred-bando-service';
|
||||
|
||||
// components
|
||||
import { Skeleton } from 'primereact/skeleton';
|
||||
@@ -28,8 +30,6 @@ import { Message } from 'primereact/message';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import { Editor } from 'primereact/editor';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import PreferredBandoService from '../../service/preferred-bando-service';
|
||||
import isDateTimeInPast from '../../helpers/isDateTimeInPast';
|
||||
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ const Dashboard = () => {
|
||||
currency: 'EUR',
|
||||
currencyDisplay: 'symbol'
|
||||
}}
|
||||
locales="en-US"/></span>
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,12 +31,14 @@ const DashboardPreInstructor = () => {
|
||||
|
||||
const errGetStats = () => {}
|
||||
|
||||
const getStatValue = (key, fallback = '') => {
|
||||
return pathOr(fallback, [key], mainStats);
|
||||
const getStatValue = (keys = [], fallback = '') => {
|
||||
return pathOr(fallback, keys, mainStats);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
DashboardService.getEvaluationsStats(getStats, errGetStats);
|
||||
DashboardService.getInstructorAmendmentsStats(getStats, errGetStats, [
|
||||
['userId', userData.id]
|
||||
]);
|
||||
}, []);
|
||||
|
||||
return(
|
||||
@@ -49,49 +51,57 @@ const DashboardPreInstructor = () => {
|
||||
|
||||
<div className="appPageSection statsBigBadges">
|
||||
<h2>{__('Riepilogo', 'gepafin')}</h2>
|
||||
<div className="statsBigBadges__grid applStats">
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Totale domande', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfAssignedApplication', 0)}
|
||||
<div className="statsBigBadges__grid doubleStatsItems">
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Domande da valutare', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['assignedApplication', 'totalAssignedApplication'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span
|
||||
className="badge">{getStatValue(['assignedApplication', 'additionalApplicationPercentage'], 0)}%</span>
|
||||
{__('da ieri', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('In soccorso', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationInAmendmentState', 0)}
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Domande valutate', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['evaluatedApplication', 'evaluatedApplication'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span
|
||||
className="badge">{getStatValue(['evaluatedApplication', 'dailyAverage'], 0)}</span>
|
||||
{__('media giornaliera', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('In valutazione', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationInOpenState', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Completate', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationInCloseState', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Tempo medio di valutazione', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('averageEvaluationDays', 0)}
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Tempo medio valutazione', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['averageEvaluationDays', 'averageEvlauationDaysRating'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
suffix={` ${__('giorni', 'gepafin')}`}
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span className="badge">{getStatValue(['averageEvaluationDays', 'timeDifferenceFromAverage'], 0)}</span>
|
||||
{__('rispetto alla media', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Domande in scadenza (48h)', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationExpiringIn48Hours', 0)}
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Soccorsi istruttori in corso', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['amendmentInProgress', 'totalAmendmentInProgress'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="en-US"/></span>
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span className="badge">{getStatValue(['amendmentInProgress', 'expiringToday'], 0)}</span>
|
||||
{__('in scadenza oggi', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isNil } from 'ramda';
|
||||
|
||||
// components
|
||||
import DownloadApplicationArchive from '../DownloadApplicationArchive';
|
||||
import DownloadSignedApplication from '../DownloadSignedApplication';
|
||||
import DownloadCompanyDelegation from '../DownloadCompanyDelegation';
|
||||
|
||||
const ApplicationDownloadFiles = ({ id }) => {
|
||||
return (
|
||||
!isNil(id)
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Scarica documenti della domanda', 'gepafin')}</h2>
|
||||
<div className="appPageSection__row autoFlow">
|
||||
<DownloadApplicationArchive applicationId={id}/>
|
||||
<DownloadSignedApplication applicationId={id}/>
|
||||
<DownloadCompanyDelegation applicationId={id}/>
|
||||
</div>
|
||||
</div> : null
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationDownloadFiles;
|
||||
@@ -0,0 +1,70 @@
|
||||
import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isNil } from 'ramda';
|
||||
|
||||
// tools
|
||||
import getDateTimeFromISOstring from '../../../../helpers/getDateTimeFromISOstring';
|
||||
import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
|
||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const ApplicationInfo = ({ data }) => {
|
||||
return (
|
||||
!isNil(data)
|
||||
? <div className="appPageSection__withBorder columns">
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('ID domanda', 'gepafin')}</span>
|
||||
<span>{data.applicationId}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Protocollo', 'gepafin')}</span>
|
||||
<span>{data.protocolNumber}</span>
|
||||
</p>
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('NDG', 'gepafin')}</span>
|
||||
<span>{data.ndg}</span>
|
||||
</p> : null}
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('Appuntamento', 'gepafin')}</span>
|
||||
<span>{data.appointmentId}</span>
|
||||
</p> : null}
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Bando', 'gepafin')}</span>
|
||||
<span>{data.callName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Referente Aziendale', 'gepafin')}</span>
|
||||
<span>{data.beneficiary}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Azienda Beneficiaria', 'gepafin')}</span>
|
||||
<span>{data.companyName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data ricezione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.submissionDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data assegnazione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.assignedAt)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Aassegnato a', 'gepafin')}</span>
|
||||
<span>{data.assignedUserName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Scadenza Valutazione', 'gepafin')}</span>
|
||||
<span>{getDateFromISOstring(data.evaluationEndDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Stato', 'gepafin')}</span>
|
||||
<span>{getBandoLabel(data.applicationStatus)}</span>
|
||||
</p>
|
||||
</div> : null
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationInfo;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty, pathOr } from 'ramda';
|
||||
import { isEmpty } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet } from '../../store';
|
||||
|
||||
@@ -36,7 +36,7 @@ const Profile = () => {
|
||||
const onSubmit = (formData) => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
|
||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
|
||||
const updateCallback = (data) => {
|
||||
@@ -109,6 +109,7 @@ const Profile = () => {
|
||||
<FormField
|
||||
type="textinput"
|
||||
fieldName="email"
|
||||
disabled={true}
|
||||
label={__('Email', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
|
||||
@@ -36,7 +36,7 @@ const ProfileBeneficiario = () => {
|
||||
const onSubmit = (formData) => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
|
||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
|
||||
const updateCallback = (data) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
@@ -22,9 +22,9 @@ const SoccorsoIstruttorioPreInstructor = () => {
|
||||
|
||||
const errGetStats = () => {}
|
||||
|
||||
const getStatValue = (key, fallback = '') => {
|
||||
const getStatValue = useCallback((key, fallback = '') => {
|
||||
return pathOr(fallback, [key], mainStats);
|
||||
}
|
||||
}, [mainStats]);
|
||||
|
||||
useEffect(() => {
|
||||
DashboardService.getAmendmentsStats(getStats, errGetStats);
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { is, isEmpty, uniq } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
|
||||
// tools
|
||||
import getNumberWithCurrency from '../../../../helpers/getNumberWithCurrency';
|
||||
|
||||
// components
|
||||
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
|
||||
const BeneficiarioUltimeDomandeTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const [items, setItems] = useState(null);
|
||||
// eslint-disable-next-line
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
// eslint-disable-next-line
|
||||
const [statuses, setStatuses] = useState([]);
|
||||
const perPage = 5;
|
||||
|
||||
const getPaginationQuery = (status = 'DRAFT', curPage = 1) => {
|
||||
return {
|
||||
"globalFilters": {
|
||||
//"year": 0,
|
||||
"page": curPage,
|
||||
//"search": "",
|
||||
"limit": perPage,
|
||||
},
|
||||
//"daysRange": 0,
|
||||
"status": status
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && !localAsyncRequest) {
|
||||
const bodyParams = getPaginationQuery(
|
||||
['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT'],
|
||||
1
|
||||
);
|
||||
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.getApplicationsPaginated(bodyParams, getApplCallback, errGetApplCallback, [
|
||||
['companyId', chosenCompanyId],
|
||||
['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT']] // 'NDG', 'ADMISSIBLE', 'APPOINTMENT'
|
||||
]);
|
||||
}
|
||||
}, [chosenCompanyId]);
|
||||
|
||||
const getApplCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data && is(Array, resp.data.body)) {
|
||||
setItems(getFormattedBandiData(resp.data.body));
|
||||
setStatuses(uniq(items.map(o => o.status)))
|
||||
initFilters();
|
||||
}
|
||||
}
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errGetApplCallback = () => {
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
return [...(data || [])].map((d) => {
|
||||
d.callEndDate = new Date(d.callEndDate);
|
||||
d.modifiedDate = new Date(d.modifiedDate);
|
||||
d.submissionDate = new Date(d.submissionDate);
|
||||
|
||||
return d;
|
||||
});
|
||||
};
|
||||
|
||||
const formatDate = (value) => {
|
||||
return value.toLocaleDateString('it-IT', {
|
||||
year: 'numeric'
|
||||
});
|
||||
};
|
||||
|
||||
const initFilters = () => {
|
||||
setFilters({
|
||||
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
||||
callTitle: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }]
|
||||
},
|
||||
companyName: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }]
|
||||
},
|
||||
modifiedDate: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
|
||||
},
|
||||
callEndDate: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const dateSubmissionBodyTemplate = (rowData) => {
|
||||
return formatDate(rowData.submissionDate);
|
||||
};
|
||||
|
||||
const importoBodyTemplate = (rowData) => {
|
||||
return getNumberWithCurrency(rowData.amountRequested);
|
||||
};
|
||||
|
||||
const statusBodyTemplate = (rowData) => {
|
||||
return <ProperBandoLabel status={rowData.status}/>;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
<DataTable value={items} showGridlines rows={5} loading={localAsyncRequest} dataKey="id"
|
||||
stripedRows
|
||||
emptyMessage={translationStrings.emptyMessage}>
|
||||
<Column field="callTitle" header={__('Bando', 'gepafin')}
|
||||
style={{ minWidth: '8rem' }}/>
|
||||
<Column header={__('Anno', 'gepafin')} dataType="date"
|
||||
style={{ minWidth: '8rem' }}
|
||||
body={dateSubmissionBodyTemplate}/>
|
||||
<Column field="amountRequested"
|
||||
header={__('Importo finanziato', 'gepafin')}
|
||||
style={{ minWidth: '7rem' }}
|
||||
body={importoBodyTemplate}/>
|
||||
<Column field="status" header={__('Stato progetto', 'gepafin')}
|
||||
style={{ minWidth: '7rem' }} body={statusBodyTemplate}/>
|
||||
</DataTable>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BeneficiarioUltimeDomandeTable;
|
||||
112
src/pages/StatsBeneficiary/index.js
Normal file
112
src/pages/StatsBeneficiary/index.js
Normal file
@@ -0,0 +1,112 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty, pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
|
||||
// components
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
import ChartDomandePerStato from '../../components/ChartDomandePerStato';
|
||||
import ChartRichiesteVsApprovate from '../../components/ChartRichiesteVsApprovate';
|
||||
import BeneficiarioUltimeDomandeTable from './components/BeneficiarioUltimeDomandeTable';
|
||||
|
||||
const StatsBeneficiary = () => {
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const [chartStats, setChartStats] = useState({});
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
|
||||
const getStats = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setMainStats(resp.data.applicationWidget);
|
||||
setChartStats(resp.data.applicationWidgetBars);
|
||||
}
|
||||
}
|
||||
|
||||
const errGetStats = () => {}
|
||||
|
||||
const getStatValue = useCallback((key, fallback = '') => {
|
||||
return pathOr(fallback, [key], mainStats);
|
||||
}, [mainStats]);
|
||||
|
||||
useEffect(() => {
|
||||
DashboardService.getBeneficiaryStatsPage(chosenCompanyId, getStats, errGetStats);
|
||||
}, [chosenCompanyId]);
|
||||
|
||||
return(
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
<h1>{__('Statistiche', 'gepafin')}</h1>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection statsBigBadges">
|
||||
<h2>{__('Riepilogo', 'gepafin')}</h2>
|
||||
<div className="statsBigBadges__grid doubleStatsItems">
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Domande presentate', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('submittedApplication', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Tasso di successo', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('waitingForResponseAmendments', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
suffix={` ${__('%', 'gepafin')}`}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Domande approvate', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('approvedApplication', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Importo totale finanziato', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('averageResponseDays', 0)}
|
||||
format={{
|
||||
notation: 'compact',
|
||||
compactDisplay: 'short',
|
||||
roundingMode: 'trunc',
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
currencyDisplay: 'symbol'
|
||||
}}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
{chartStats && !isEmpty(chartStats)
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Statistiche di sistema', 'gepafin')}</h2>
|
||||
<div className="appPageSection columns">
|
||||
<ChartRichiesteVsApprovate
|
||||
title={__('Importi Richiesti VS Approvati', 'gepafin')}
|
||||
data={chartStats.requestedVsApprovedAmount}/>
|
||||
<ChartDomandePerStato
|
||||
title={__('Domande per stato', 'gepafin')}
|
||||
data={chartStats.applicationPerStatus}/>
|
||||
</div>
|
||||
</div> : null}
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Ultime richieste di finanziamento', 'gepafin')}</h2>
|
||||
<BeneficiarioUltimeDomandeTable/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default StatsBeneficiary;
|
||||
Reference in New Issue
Block a user