- updated dependencies;
- fixed displaying delega; - fixed switching companies; - added toast for profile and company profile; - fixed registration 'deby/allow all' func;
This commit is contained in:
20839
package-lock.json
generated
20839
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -4,24 +4,24 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
||||
"@babel/preset-react": "7.24.7",
|
||||
"@babel/preset-react": "7.25.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",
|
||||
"@wordpress/i18n": "5.9.0",
|
||||
"@wordpress/react-i18n": "4.9.0",
|
||||
"@xyflow/react": "12.3.1",
|
||||
"codice-fiscale-js": "2.3.22",
|
||||
"deep-object-diff": "1.1.9",
|
||||
"dompurify": "3.1.7",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"html-react-parser": "5.1.16",
|
||||
"html-react-parser": "5.1.18",
|
||||
"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",
|
||||
"primereact": "10.8.4",
|
||||
"quill": "2.0.2",
|
||||
"ramda": "0.30.1",
|
||||
"react": "18.3.1",
|
||||
@@ -30,27 +30,27 @@
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "7.53.0",
|
||||
"react-router-dom": "6.26.2",
|
||||
"react-scripts": "5.0.1",
|
||||
"react-scripts": "^3.0.1",
|
||||
"validate.js": "0.13.1",
|
||||
"zustand": "4.5.4",
|
||||
"zustand-x": "3.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.25.6",
|
||||
"@babel/core": "7.25.2",
|
||||
"@babel/plugin-syntax-jsx": "7.24.7",
|
||||
"@wordpress/babel-plugin-makepot": "6.8.0",
|
||||
"@babel/cli": "7.25.7",
|
||||
"@babel/core": "7.25.7",
|
||||
"@babel/plugin-syntax-jsx": "7.25.7",
|
||||
"@wordpress/babel-plugin-makepot": "6.9.0",
|
||||
"babel-plugin-macros": "3.1.0",
|
||||
"sass": "1.79.3",
|
||||
"sass": "1.79.4",
|
||||
"sass-loader": "16.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "GENERATE_SOURCEMAP=false react-scripts start",
|
||||
"start:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && PORT=8000 react-scripts start",
|
||||
"start:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts start",
|
||||
"start:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && PORT=8000 react-scripts start --mode development",
|
||||
"start:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts start --mode production",
|
||||
"build": "react-scripts build",
|
||||
"build:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && react-scripts build",
|
||||
"build:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts build",
|
||||
"build:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && react-scripts build --mode development",
|
||||
"build:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts build --mode production",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
|
||||
17
src/App.js
17
src/App.js
@@ -17,7 +17,6 @@ function App() {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
|
||||
const callback = (data) => {
|
||||
//console.log('app /me', data);
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
} else {
|
||||
@@ -27,36 +26,20 @@ function App() {
|
||||
}
|
||||
|
||||
const errCallback = (data) => {
|
||||
//storeSet.main.doLogout();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
/*const companyCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.companies(data.data);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errCompanyCallback = (data) => {
|
||||
storeSet.main.doLogout();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}*/
|
||||
|
||||
useEffect(() => {
|
||||
if (role === 'ROLE_BENEFICIARY') {
|
||||
//storeSet.main.setAsyncRequest();
|
||||
const userData = storeGet.main.userData();
|
||||
if (userData.companies) {
|
||||
storeSet.main.companies(userData.companies);
|
||||
}
|
||||
//CompanyService.getCompanyForUser(userData.id, companyCallback, errCompanyCallback)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
//console.log('app loaded, initiate call to /me');
|
||||
AuthenticationService.me(callback, errCallback);
|
||||
|
||||
fetch('/languages/en_US.json')
|
||||
|
||||
@@ -177,6 +177,7 @@
|
||||
.appForm__switchFieldWrapper {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
margin-bottom: 20px;
|
||||
|
||||
.appForm__field.switch {
|
||||
width: 90px;
|
||||
@@ -184,7 +185,9 @@
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@
|
||||
color: var(--primary-text);
|
||||
}
|
||||
|
||||
&[data-active="false"] {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
i {
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ const FileuploadDelega = ({
|
||||
}
|
||||
|
||||
const itemTemplate = (file) => {
|
||||
console.log('file', file)
|
||||
return (
|
||||
<div className="appForm__fileUploadItem">
|
||||
<div>
|
||||
@@ -128,8 +127,10 @@ const FileuploadDelega = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
inputRef.current.setUploadedFiles(multiple ? defaultValue : [defaultValue]);
|
||||
console.log('inputRef.current', inputRef.current, multiple ? defaultValue : [defaultValue])
|
||||
const properValue = multiple
|
||||
? defaultValue
|
||||
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||
inputRef.current.setUploadedFiles(properValue);
|
||||
}
|
||||
}, [defaultValue]);
|
||||
|
||||
|
||||
@@ -152,6 +152,15 @@ const Fileupload = ({
|
||||
register(fieldName, config)
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
const properValue = multiple
|
||||
? defaultValue
|
||||
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||
inputRef.current.setUploadedFiles(properValue);
|
||||
}
|
||||
}, [defaultValue]);
|
||||
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||
|
||||
@@ -153,6 +153,15 @@ const FileuploadAsync = ({
|
||||
register(fieldName, config)
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
const properValue = multiple
|
||||
? defaultValue
|
||||
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||
inputRef.current.setUploadedFiles(properValue);
|
||||
}
|
||||
}, [defaultValue]);
|
||||
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||
|
||||
@@ -19,8 +19,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
const [companyItems, setCompanyItems] = useState([]);
|
||||
const renderCompanyItem = (item) => (
|
||||
<span className="topBar__menuCompanyItem"
|
||||
onClick={chosenCompanyId === item.companyId ? () => {
|
||||
} : () => switchCompany(item.companyId)}
|
||||
onClick={() => switchCompany(item.companyId)}
|
||||
data-id={item.companyId}
|
||||
data-active={chosenCompanyId === item.companyId}>
|
||||
<i className="pi pi-building-columns"></i>
|
||||
@@ -83,7 +82,9 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
].filter(o => o.enable);
|
||||
|
||||
const switchCompany = (id) => {
|
||||
console.log('switchCompany');
|
||||
if (chosenCompanyId !== id) {
|
||||
storeSet.main.chosenCompanyId(id);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -93,7 +94,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
template: renderCompanyItem
|
||||
}));
|
||||
setCompanyItems(items)
|
||||
}, [companies])
|
||||
}, [companies, chosenCompanyId])
|
||||
|
||||
return <>
|
||||
<Menu model={items} popup ref={menuLeftRef} id="topBar_profileMenu" className="topBar__menuProfile"/>
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
import React, { useMemo, useRef } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
|
||||
// components
|
||||
import { Messages } from 'primereact/messages';
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import FormField from '../../components/FormField';
|
||||
import { Button } from 'primereact/button';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Toast } from 'primereact/toast';
|
||||
|
||||
// api
|
||||
import UserService from '../../service/user-service';
|
||||
|
||||
// tools
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
|
||||
const Profile = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const userData = useStore().main.userData();
|
||||
const infoMsgs = useRef(null);
|
||||
const toast = useRef(null);
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
setValue
|
||||
formState: { errors }
|
||||
} = useForm({
|
||||
defaultValues: useMemo(() => {
|
||||
return userData;
|
||||
@@ -33,7 +34,6 @@ const Profile = () => {
|
||||
});
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
infoMsgs.current.clear();
|
||||
storeSet.main.setAsyncRequest();
|
||||
|
||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||
@@ -41,7 +41,14 @@ const Profile = () => {
|
||||
|
||||
const updateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
//setData(getFormattedBandiData(data.data));
|
||||
storeSet.main.userData(data.data);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('L\'utente è stato aggiornato!', 'gepafin')
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -58,7 +65,7 @@ const Profile = () => {
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
<Messages ref={infoMsgs}/>
|
||||
<Toast ref={toast}/>
|
||||
|
||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
|
||||
@@ -124,6 +131,38 @@ const Profile = () => {
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Consensi', 'gepafin')}</h2>
|
||||
|
||||
<div className="appForm__switchFieldWrapper">
|
||||
<FormField
|
||||
type="switch"
|
||||
disabled={true}
|
||||
fieldName="privacy"
|
||||
label={''}
|
||||
control={control}
|
||||
errors={errors}
|
||||
onLabel={''}
|
||||
offLabel={''}
|
||||
/>
|
||||
<div>
|
||||
{__('Dichiaro di aver preso visione, prima dell\'accesso al portale https://bandi.gepafin.it, dell\' "Informativa Privacy" all\'interno dell\'Appendice 10 dell\'Avviso secondo il Regolamento UE 2016/679 relativo alla protezione delle persone fisiche con riguardo al trattamento dei dati personale, nonché alla libera circolazione di tali dati e che abroga la Direttiva 95/46 CE.', 'gepafin')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="appForm__switchFieldWrapper">
|
||||
<FormField
|
||||
type="switch"
|
||||
disabled={true}
|
||||
fieldName="terms"
|
||||
label={''}
|
||||
control={control}
|
||||
errors={errors}
|
||||
onLabel={''}
|
||||
offLabel={''}
|
||||
/>
|
||||
<div>
|
||||
{__('Termini e condizioni', 'gepafin')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="appForm__switchFieldWrapper">
|
||||
<FormField
|
||||
type="switch"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty, pathOr, head } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore, storeGet } from '../../store';
|
||||
@@ -18,10 +19,10 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import { Messages } from 'primereact/messages';
|
||||
import FormField from '../../components/FormField';
|
||||
import { Button } from 'primereact/button';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import FileuploadDelega from '../../components/FileuploadDelega';
|
||||
import { Toast } from 'primereact/toast';
|
||||
|
||||
const ProfileCompany = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
@@ -32,6 +33,7 @@ const ProfileCompany = () => {
|
||||
const [delegaData, setDelegaData] = useState({});
|
||||
const [delega, setDelega] = useState({});
|
||||
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
|
||||
const toast = useRef(null);
|
||||
|
||||
const {
|
||||
control,
|
||||
@@ -39,6 +41,7 @@ const ProfileCompany = () => {
|
||||
formState: { errors },
|
||||
setValue,
|
||||
watch,
|
||||
reset
|
||||
} = useForm({
|
||||
defaultValues: useMemo(() => {
|
||||
return formInitialData;
|
||||
@@ -82,6 +85,14 @@ const ProfileCompany = () => {
|
||||
}
|
||||
|
||||
storeSet.main.companies(newCompanies);
|
||||
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('L\'azienda è stata aggiornata!', 'gepafin')
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -142,12 +153,10 @@ const ProfileCompany = () => {
|
||||
}
|
||||
|
||||
const setDelegaFile = (name, value) => {
|
||||
console.log('setDelegaFile', value)
|
||||
setDelega(value);
|
||||
}
|
||||
|
||||
const getDellegaCallback = (data) => {
|
||||
console.log(data)
|
||||
if (data.data) {
|
||||
setDelega(data.data);
|
||||
}
|
||||
@@ -155,6 +164,7 @@ const ProfileCompany = () => {
|
||||
}
|
||||
|
||||
const errDellegaCallback = () => {
|
||||
setDelega({});
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -190,6 +200,7 @@ const ProfileCompany = () => {
|
||||
}, [formInitialData]);
|
||||
|
||||
useEffect(() => {
|
||||
reset();
|
||||
let chosenCompany = {};
|
||||
|
||||
if (chosenCompanyId) {
|
||||
@@ -218,6 +229,7 @@ const ProfileCompany = () => {
|
||||
contactEmail,
|
||||
isLegalRepresentant
|
||||
}
|
||||
|
||||
setFormInitialData(companyData);
|
||||
}, [chosenCompanyId, companies]);
|
||||
|
||||
@@ -236,6 +248,7 @@ const ProfileCompany = () => {
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
<Messages ref={infoMsgs}/>
|
||||
<Toast ref={toast}/>
|
||||
|
||||
<form id="companyForm" className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
||||
|
||||
@@ -108,13 +108,13 @@ const Registration = () => {
|
||||
const disableAllChecks = () => {
|
||||
setValue('marketing', false);
|
||||
setValue('offers', false);
|
||||
setValue('thirdparty', false);
|
||||
setValue('thirdParty', false);
|
||||
}
|
||||
|
||||
const enableAllChecks = () => {
|
||||
setValue('marketing', true);
|
||||
setValue('offers', true);
|
||||
setValue('thirdparty', true);
|
||||
setValue('thirdParty', true);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const zustandXOpts = {
|
||||
devtools: {
|
||||
enabled: true
|
||||
enabled: process.env.NODE_ENV !== 'production'
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
|
||||
Reference in New Issue
Block a user