- updated copies;
- test for spid login;
This commit is contained in:
@@ -20,11 +20,13 @@ function App() {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
} else {
|
||||
console.log('logout 1', data)
|
||||
storeSet.main.doLogout();
|
||||
}
|
||||
}
|
||||
|
||||
const errCallback = (data) => {
|
||||
console.log('logout 2', data)
|
||||
storeSet.main.doLogout();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -37,6 +39,7 @@ function App() {
|
||||
}
|
||||
|
||||
const errCompanyCallback = (data) => {
|
||||
console.log('logout 3', data)
|
||||
storeSet.main.doLogout();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import React, { useState, useCallback } from 'react';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { Controller } from 'react-hook-form';
|
||||
import { Checkbox } from 'primereact/checkbox';
|
||||
import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
import { maxChecks, minChecks } from '../../../../helpers/validators';
|
||||
|
||||
const Checkboxes = ({
|
||||
fieldName,
|
||||
@@ -29,11 +33,23 @@ const Checkboxes = ({
|
||||
updateFn(data);
|
||||
}, [fieldVal]);
|
||||
|
||||
const properConfig = (config) => {
|
||||
let newConfig = klona(config);
|
||||
if (config.minLength) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'minChecks'], (v) => minChecks(v, config.minLength)).value();
|
||||
}
|
||||
if (config.maxLength) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'maxChecks'], (v) => maxChecks(v, config.maxLength)).value();
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
const input = <Controller
|
||||
name={fieldName}
|
||||
control={control}
|
||||
defaultValue={fieldVal}
|
||||
rules={config}
|
||||
rules={properConfig(config)}
|
||||
render={({ field, fieldState }) =>
|
||||
options.map(o => <div className="appForm__fieldItem" key={o.name}>
|
||||
<Checkbox
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import validate from 'validate.js';
|
||||
import { match, isEmpty } from 'ramda';
|
||||
import { match, isEmpty, is } from 'ramda';
|
||||
import CodiceFiscale from 'codice-fiscale-js';
|
||||
|
||||
export const isPIVA = (v) => {
|
||||
@@ -57,4 +57,12 @@ export const isUrl = (v) => {
|
||||
export const isMarcaDaBollo = (v) => {
|
||||
const regexp = new RegExp(/^[0-9]{14}$/);
|
||||
return !isEmpty(match(regexp, String(v)));
|
||||
}
|
||||
|
||||
export const minChecks = (v, num) => {
|
||||
return is(Array, v) ? v.length >= parseInt(num) : false;
|
||||
}
|
||||
|
||||
export const maxChecks = (v, num) => {
|
||||
return is(Array, v) ? v.length <= parseInt(num) : false;
|
||||
}
|
||||
@@ -91,6 +91,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
|
||||
const errSubmitApplicationCallback = (data) => {
|
||||
console.log(data)
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
@@ -103,6 +104,17 @@ const BandoApplication = () => {
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else if (data.status === 'EXCEPTION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
{
|
||||
id: '99',
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
set404FromErrorResponse(data);
|
||||
}
|
||||
@@ -184,6 +196,17 @@ const BandoApplication = () => {
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else if (data.status === 'EXCEPTION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
{
|
||||
id: '99',
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
set404FromErrorResponse(data);
|
||||
}
|
||||
@@ -317,14 +340,15 @@ const BandoApplication = () => {
|
||||
if (['min', 'max', 'minLength', 'maxLength', 'maxSize'].includes(cur)) {
|
||||
acc[cur] = parseInt(o.validators[cur]);
|
||||
} else if ('pattern' === cur) {
|
||||
acc[cur] = new RegExp(o.validators[cur])
|
||||
acc[cur] = new RegExp(o.validators[cur]);
|
||||
} else if ('isRequired' === cur) {
|
||||
acc[cur] = o.validators[cur]
|
||||
//acc[cur] = o.validators[cur];
|
||||
acc['required'] = true;
|
||||
} else if ('custom' === cur && validationFns[o.validators[cur]]) {
|
||||
if (!acc.validate) {
|
||||
acc.validate = {}
|
||||
acc.validate = {};
|
||||
}
|
||||
acc.validate[cur] = validationFns[o.validators[cur]]
|
||||
acc.validate[cur] = validationFns[o.validators[cur]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +356,7 @@ const BandoApplication = () => {
|
||||
}, {});
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div className="appForm__content">{renderHtmlContent(text.value)}</div>
|
||||
? <div className="appForm__content" key={o.id}>{renderHtmlContent(text.value)}</div>
|
||||
: <FormField
|
||||
key={o.id}
|
||||
type={o.name}
|
||||
@@ -375,6 +399,7 @@ const BandoApplication = () => {
|
||||
outlined
|
||||
label={__('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/>
|
||||
{activeStep < totalSteps
|
||||
//&& activeStep === completedSteps
|
||||
? <Button
|
||||
type="button"
|
||||
onClick={goForward}
|
||||
|
||||
@@ -288,7 +288,7 @@ const BandoEdit = () => {
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Publicca il Form', 'gepafin')}</h2>
|
||||
<h2>{__('Pubblica il form', 'gepafin')}</h2>
|
||||
|
||||
<div className="row">
|
||||
<Button
|
||||
|
||||
@@ -734,7 +734,7 @@ export const elementItems = [
|
||||
],
|
||||
validators: {}
|
||||
},
|
||||
/*{
|
||||
{
|
||||
id: 20,
|
||||
sortOrder: 20,
|
||||
name: 'table',
|
||||
@@ -744,8 +744,12 @@ export const elementItems = [
|
||||
{
|
||||
name: "label",
|
||||
value: "Tabella"
|
||||
},
|
||||
{
|
||||
name: "table_columns",
|
||||
value: "Tabella"
|
||||
}
|
||||
],
|
||||
validators: {}
|
||||
}*/
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user