From 62b7da28df75641a1106fb0d58652610bd87862b Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 2 Oct 2024 10:41:15 +0200 Subject: [PATCH] - updated copies; - test for spid login; --- package-lock.json | 53 +++++++++++++++++++ package.json | 2 + src/App.js | 3 ++ .../FormField/components/Checkboxes/index.js | 18 ++++++- src/helpers/validators.js | 10 +++- src/pages/BandoApplication/index.js | 35 ++++++++++-- src/pages/BandoEdit/index.js | 2 +- src/tempData.js | 8 ++- yarn.lock | 25 +++++++++ 9 files changed, 146 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index cec91c8..e14be1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@babel/preset-react": "7.24.7", "@date-fns/tz": "1.1.2", "@emotion/styled": "11.13.0", + "@tanstack/react-table": "^8.20.5", "@wordpress/i18n": "5.8.0", "@wordpress/react-i18n": "4.8.0", "@xyflow/react": "12.3.1", @@ -23,6 +24,7 @@ "jwt-decode": "4.0.0", "klona": "2.0.6", "luxon": "3.5.0", + "object-path-immutable": "^4.1.2", "primeicons": "7.0.0", "primereact": "10.8.3", "quill": "2.0.2", @@ -3869,6 +3871,37 @@ "resolved": "https://registry.npmjs.org/@tannin/postfix/-/postfix-1.1.0.tgz", "integrity": "sha512-oocsqY7g0cR+Gur5jRQLSrX2OtpMLMse1I10JQBm8CdGMrDkh1Mg2gjsiquMHRtBs4Qwu5wgEp5GgIYHk4SNPw==" }, + "node_modules/@tanstack/react-table": { + "version": "8.20.5", + "resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.20.5.tgz", + "integrity": "sha512-WEHopKw3znbUZ61s9i0+i9g8drmDo6asTWbrQh8Us63DAk/M0FkmIqERew6P71HI75ksZ2Pxyuf4vvKh9rAkiA==", + "dependencies": { + "@tanstack/table-core": "8.20.5" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, + "node_modules/@tanstack/table-core": { + "version": "8.20.5", + "resolved": "https://registry.npmjs.org/@tanstack/table-core/-/table-core-8.20.5.tgz", + "integrity": "sha512-P9dF7XbibHph2PFRz8gfBKEXEY/HJPOhym8CHmjF8y3q5mWpKx9xtZapXQUWCgkqvsK0R46Azuz+VaxD4Xl+Tg==", + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -13174,6 +13207,26 @@ "node": ">= 0.4" } }, + "node_modules/object-path": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.8.tgz", + "integrity": "sha512-YJjNZrlXJFM42wTBn6zgOJVar9KFJvzx6sTWDte8sWZF//cnjl0BxHNpfZx+ZffXX63A9q0b1zsFiBX4g4X5KA==", + "engines": { + "node": ">= 10.12.0" + } + }, + "node_modules/object-path-immutable": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object-path-immutable/-/object-path-immutable-4.1.2.tgz", + "integrity": "sha512-Bfrox46OegMkQXL872EzEjofMyBxk/2hgiy99NkCkYFegn6Dm9FvV2jY2Tnp9qLj2QL0TLii12CuPpzonkjJrA==", + "dependencies": { + "is-plain-object": "^5.0.0", + "object-path": "^0.11.8" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object.assign": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", diff --git a/package.json b/package.json index 0afdca1..6421129 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@babel/preset-react": "7.24.7", "@date-fns/tz": "1.1.2", "@emotion/styled": "11.13.0", + "@tanstack/react-table": "^8.20.5", "@wordpress/i18n": "5.8.0", "@wordpress/react-i18n": "4.8.0", "@xyflow/react": "12.3.1", @@ -18,6 +19,7 @@ "jwt-decode": "4.0.0", "klona": "2.0.6", "luxon": "3.5.0", + "object-path-immutable": "^4.1.2", "primeicons": "7.0.0", "primereact": "10.8.3", "quill": "2.0.2", diff --git a/src/App.js b/src/App.js index e43aab2..d15ba88 100644 --- a/src/App.js +++ b/src/App.js @@ -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(); } diff --git a/src/components/FormField/components/Checkboxes/index.js b/src/components/FormField/components/Checkboxes/index.js index 527871b..ed330f6 100644 --- a/src/components/FormField/components/Checkboxes/index.js +++ b/src/components/FormField/components/Checkboxes/index.js @@ -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 = options.map(o =>
{ @@ -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; } \ No newline at end of file diff --git a/src/pages/BandoApplication/index.js b/src/pages/BandoApplication/index.js index 15ea3c1..8a4f057 100644 --- a/src/pages/BandoApplication/index.js +++ b/src/pages/BandoApplication/index.js @@ -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 - ?
{renderHtmlContent(text.value)}
+ ?
{renderHtmlContent(text.value)}
: { outlined label={__('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/> {activeStep < totalSteps + //&& activeStep === completedSteps ?