- merged with master;

- fixed registartion form - added hub id;
- fixed bando view for beneficiario after switching company;
This commit is contained in:
Vitalii Kiiko
2024-10-23 12:24:34 +02:00
10 changed files with 49 additions and 24 deletions

View File

@@ -40,6 +40,7 @@ import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
import { defaultMaxFileSize } from '../../configData';
const BandoApplication = () => {
const chosenCompanyId = useStore().main.chosenCompanyId();
const { id } = useParams();
const [formData, setFormData] = useState([]);
const [formInitialData, setFormInitialData] = useState(null);
@@ -165,7 +166,7 @@ const BandoApplication = () => {
fieldVal = tzAwareDate.toISOString().substring(0, 19);
}
fieldVal = !fieldVal ? null : fieldVal;
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
if (formField && formField.name === 'fileupload') {
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
}
@@ -450,7 +451,7 @@ const BandoApplication = () => {
storeSet.main.setAsyncRequest();
ApplicationService.getApplicationForm(applId, getApplFormCallback, errGetApplFormCallbacks);
}
}, [id]);
}, [id, chosenCompanyId]);
return (
<div className="appPage">

View File

@@ -64,6 +64,13 @@ const ElementSetting = ({ setting, changeFn, updateDataFn }) => {
onTextChange={(e) => changeFn(e.htmlValue, setting.name)}
style={{ height: 80 * 4 }}
/>
} else if (setting.name === 'step') {
return <InputText id={setting.name}
keyfilter="int"
aria-describedby={`${setting.name}-help`}
placeholder="0"
value={setting.value}
onChange={(e) => changeFn(e.target.value, setting.name)}/>
} else if (setting.name === 'table_columns') {
return <ElementSettingTableColumns
value={is(Object, setting.value) ? setting.value : {}}

View File

@@ -26,7 +26,7 @@ const BuilderElementSettings = ({ closeSettingsFn }) => {
const [validators, setValidators] = useState({});
const [dynamicData, setDynamicData] = useState('');
const [criteria, setCriteria] = useState([]);
const textBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength', 'pattern'];
const numberBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength'];
const customValidationOptions = [
{ value: 'isPIVA', label: 'isPIVA' },
{ value: 'isCodiceFiscale', label: 'isCodiceFiscale' },
@@ -99,7 +99,7 @@ const BuilderElementSettings = ({ closeSettingsFn }) => {
newValidators[name] = value;
setValidators(newValidators);
}
const onChangeCriteriaData = (value) => {
setCriteria(value);
}
@@ -191,7 +191,7 @@ const BuilderElementSettings = ({ closeSettingsFn }) => {
onChange={(e) => toggleRequired(e.value, k)}/>
</div>
: null}
{textBasedValidatorFields.includes(k) || 'custom' === k
{numberBasedValidatorFields.includes(k) || 'pattern' === k || 'custom' === k
? <div className="formElementSettings__field">
<label htmlFor={`enable_${k}`}>{sprintf(__('Set %s', 'gepafin'), k)}</label>
<InputSwitch
@@ -212,13 +212,23 @@ const BuilderElementSettings = ({ closeSettingsFn }) => {
placeholder={__('Scegli', 'gepafin')}/>
</div>
: null}
{textBasedValidatorFields.includes(k) && !isNil(validators[k])
{'pattern' === k && !isNil(validators[k])
? <div className="formElementSettings__field">
<label htmlFor={k}>{k}</label>
<InputText id={k} aria-describedby={`${k}-help`}
value={validators[k]}
onChange={(e) => onChangeValidator(e.target.value, k)}/>
</div> : null}
{numberBasedValidatorFields.includes(k) && !isNil(validators[k])
? <div className="formElementSettings__field">
<label htmlFor={k}>{k}</label>
<InputText id={k}
aria-describedby={`${k}-help`}
value={validators[k]}
keyfilter="int"
placeholder="0"
onChange={(e) => onChangeValidator(e.target.value, k)}/>
</div> : null}
</div>) : null}
</TabPanel> : null}
<TabPanel header={__('Criteri', 'gepafin')}>

View File

@@ -130,11 +130,11 @@ const BandoViewBeneficiario = () => {
'isVisible': false
}
storeSet.main.setAsyncRequest();
FaqItemService.addQuestion(id, obj, createCallBack, errCreateCallback, [['companyId', chosenCompanyId]])
FaqItemService.addQuestion(id, obj, createQuestionBack, errCreateQuestionCallback, [['companyId', chosenCompanyId]])
}
}
const createCallBack = (data) => {
const createQuestionBack = (data) => {
if (data.status === 'SUCCESS') {
setNewQuestion('');
if (toast.current) {
@@ -148,7 +148,7 @@ const BandoViewBeneficiario = () => {
storeSet.main.unsetAsyncRequest();
}
const errCreateCallback = (data) => {
const errCreateQuestionCallback = (data) => {
if (toast.current && data.message) {
toast.current.show({
severity: 'error',
@@ -219,8 +219,11 @@ const BandoViewBeneficiario = () => {
const bandoId = getBandoId();
storeSet.main.setAsyncRequest();
BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback);
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [['callId', bandoId]])
}, [id]);
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
['callId', bandoId],
['companyId', chosenCompanyId]
])
}, [id, chosenCompanyId]);
return (
<div className="appPage">

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { __ } from '@wordpress/i18n';
import { uniq } from 'ramda';
import { uniq, is } from 'ramda';
// tools
import getBandoLabel from '../../../../helpers/getBandoLabel';
@@ -26,6 +26,7 @@ import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse
const MyLatestSubmissionsTable = () => {
const chosenCompanyId = useStore().main.chosenCompanyId();
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
const [items, setItems] = useState(null);
const [filters, setFilters] = useState(null);
@@ -34,12 +35,14 @@ const MyLatestSubmissionsTable = () => {
useEffect(() => {
setLocalAsyncRequest(true);
ApplicationService.getApplications(getApplCallback, errGetApplCallback)
}, []);
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
['companyId', chosenCompanyId]
])
}, [chosenCompanyId]);
const getApplCallback = (data) => {
if (data.status === 'SUCCESS') {
if (data.data.length) {
if (is(Array, data.data)) {
setItems(getFormattedBandiData(data.data));
setStatuses(uniq(items.map(o => o.status)))
initFilters();

View File

@@ -23,6 +23,8 @@ import { Panel } from 'primereact/panel';
import { Dialog } from 'primereact/dialog';
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
const Registration = () => {
const token = useStore().main.token();
const [loading, setLoading] = useState(false);
@@ -47,7 +49,8 @@ const Registration = () => {
setLoading(true);
const newFormData = {
...formData,
dateOfBirth: originalDateOfBirth
dateOfBirth: originalDateOfBirth,
hubUuid: APP_HUB_ID
}
AuthenticationService.registerUser(newFormData, regCallback, regError, [