Merge pull request #42 from Kitzanos/updated-zustand
Updated React 19+ and Zustand store 5+
This commit is contained in:
47
package.json
47
package.json
@@ -7,54 +7,53 @@
|
||||
"@babel/preset-react": "7.26.3",
|
||||
"@date-fns/tz": "1.2.0",
|
||||
"@emailjs/browser": "4.4.1",
|
||||
"@emotion/styled": "11.14.0",
|
||||
"@number-flow/react": "0.5.5",
|
||||
"@sentry/browser": "8.51.0",
|
||||
"@stomp/stompjs": "7.0.0",
|
||||
"@tanstack/react-table": "8.20.6",
|
||||
"@wordpress/i18n": "5.16.0",
|
||||
"@wordpress/react-i18n": "4.16.0",
|
||||
"@number-flow/react": "0.5.9",
|
||||
"@sentry/browser": "9.11.0",
|
||||
"@stomp/stompjs": "7.1.1",
|
||||
"@tanstack/react-table": "8.21.2",
|
||||
"@wordpress/i18n": "5.21.0",
|
||||
"@wordpress/react-i18n": "4.21.0",
|
||||
"codice-fiscale-js": "2.3.22",
|
||||
"copy-to-clipboard": "3.3.3",
|
||||
"deep-object-diff": "1.1.9",
|
||||
"dompurify": "3.2.3",
|
||||
"dompurify": "3.2.5",
|
||||
"expression-language": "1.2.0",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"hotkeys-js": "3.13.9",
|
||||
"html-react-parser": "5.2.2",
|
||||
"html-react-parser": "5.2.3",
|
||||
"jwt-decode": "4.0.0",
|
||||
"klona": "2.0.6",
|
||||
"leader-line-new": "1.1.9",
|
||||
"luxon": "3.5.0",
|
||||
"mathjs": "14.0.1",
|
||||
"luxon": "3.6.1",
|
||||
"mathjs": "14.4.0",
|
||||
"mustache": "4.2.0",
|
||||
"object-path-immutable": "4.1.2",
|
||||
"primeicons": "7.0.0",
|
||||
"primereact": "10.9.2",
|
||||
"primereact": "10.9.4",
|
||||
"quill": "2.0.3",
|
||||
"ramda": "0.30.1",
|
||||
"react": "18.3.1",
|
||||
"react": "19.1.0",
|
||||
"react-dnd": "16.0.1",
|
||||
"react-dnd-html5-backend": "16.0.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "7.54.2",
|
||||
"react-router-dom": "7.1.3",
|
||||
"react-dom": "19.1.0",
|
||||
"react-hook-form": "7.55.0",
|
||||
"react-router-dom": "7.5.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"recharts": "2.15.0",
|
||||
"recharts": "2.15.2",
|
||||
"sockjs-client": "1.6.1",
|
||||
"validate.js": "0.13.1",
|
||||
"zustand": "4.5.4",
|
||||
"zustand-x": "3.0.4"
|
||||
"zustand": "5.0.3",
|
||||
"zustand-x": "6.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.26.4",
|
||||
"@babel/core": "7.26.7",
|
||||
"@babel/cli": "7.27.0",
|
||||
"@babel/core": "7.26.10",
|
||||
"@babel/plugin-syntax-jsx": "7.25.9",
|
||||
"@wordpress/babel-plugin-makepot": "6.16.0",
|
||||
"@wordpress/babel-plugin-makepot": "6.21.0",
|
||||
"babel-plugin-macros": "3.1.0",
|
||||
"node-wp-i18n": "1.2.7",
|
||||
"sass": "1.83.4",
|
||||
"sass-loader": "16.0.4"
|
||||
"sass": "1.86.3",
|
||||
"sass-loader": "16.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "GENERATE_SOURCEMAP=false react-scripts start",
|
||||
|
||||
58
src/App.js
58
src/App.js
@@ -1,58 +1,60 @@
|
||||
import { useEffect } from 'react';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import Routes from './routes';
|
||||
import { createI18n, setLocaleData } from '@wordpress/i18n';
|
||||
import { I18nProvider } from '@wordpress/react-i18n';
|
||||
import {
|
||||
//createI18n,
|
||||
setLocaleData } from '@wordpress/i18n';
|
||||
//import { I18nProvider } from '@wordpress/react-i18n';
|
||||
import './assets/scss/theme.scss';
|
||||
import { isEmpty, head } from 'ramda';
|
||||
import { addLocale, PrimeReactProvider } from 'primereact/api';
|
||||
|
||||
// store
|
||||
import { useStore, storeSet, storeGet } from './store';
|
||||
import { useStoreValue, storeSet, storeGet } from './store';
|
||||
|
||||
// api
|
||||
import AuthenticationService from './service/authentication-service';
|
||||
|
||||
const i18n = createI18n({}, 'gepafin');
|
||||
//const i18n = createI18n({}, 'gepafin');
|
||||
|
||||
function App() {
|
||||
const role = useStore().main.getRole();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const isRedirectedOnceNoCompany = useStore().main.isRedirectedOnceNoCompany();
|
||||
const role = useStoreValue('getRole');
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const isRedirectedOnceNoCompany = useStoreValue('isRedirectedOnceNoCompany');
|
||||
const value = {
|
||||
locale: 'it',
|
||||
};
|
||||
|
||||
const callback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
const callback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet('userData', resp.data);
|
||||
} else {
|
||||
storeSet.main.doLogout();
|
||||
storeSet('doLogout');
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
const errCallback = () => {
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (['ROLE_BENEFICIARY', 'ROLE_CONFIDI'].includes(role)) {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
if (userData.companies && !isEmpty(userData.companies)) {
|
||||
storeSet.main.companies(userData.companies);
|
||||
storeSet('companies', userData.companies);
|
||||
const company = head(userData.companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
if (!company) {
|
||||
storeSet.main.chosenCompanyId(userData.companies[0].id);
|
||||
storeSet('chosenCompanyId', userData.companies[0].id);
|
||||
}
|
||||
} else {
|
||||
storeSet.main.chosenCompanyId(0);
|
||||
storeSet('chosenCompanyId', 0);
|
||||
const { origin, href } = window.location;
|
||||
const url = `${origin}/agguingi-azienda`;
|
||||
|
||||
if (!isRedirectedOnceNoCompany && url !== href) {
|
||||
storeSet.main.isRedirectedOnceNoCompany(true);
|
||||
storeSet('isRedirectedOnceNoCompany', true);
|
||||
window.location.replace('/agguingi-azienda')
|
||||
}
|
||||
}
|
||||
@@ -60,7 +62,7 @@ function App() {
|
||||
}, [role]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AuthenticationService.me(callback, errCallback);
|
||||
|
||||
addLocale('it', {
|
||||
@@ -116,6 +118,17 @@ function App() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<PrimeReactProvider value={value}>
|
||||
<Routes role={role} chosenCompanyId={chosenCompanyId}/>
|
||||
</PrimeReactProvider>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
||||
/*
|
||||
<I18nProvider i18n={i18n}>
|
||||
<BrowserRouter>
|
||||
<PrimeReactProvider value={value}>
|
||||
@@ -123,7 +136,4 @@ function App() {
|
||||
</PrimeReactProvider>
|
||||
</BrowserRouter>
|
||||
</I18nProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
*/
|
||||
@@ -5,7 +5,7 @@ import SockJS from 'sockjs-client';
|
||||
import { Stomp } from '@stomp/stompjs';
|
||||
|
||||
// store
|
||||
import { storeGet, useStore } from '../../store';
|
||||
import { storeGet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import NotificationService from '../../service/notification-service';
|
||||
@@ -24,8 +24,8 @@ import PaginatorBasic from '../PaginatorBasic';
|
||||
const socketUrl = process.env.REACT_APP_API_ADDRESS_WS;
|
||||
|
||||
const NotificationsSidebar = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const userData = useStore().main.userData();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const userData = useStoreValue('userData');
|
||||
const [activeIndex, setActiveIndex] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [notificationsVisible, setNotificationsVisible] = useState(false);
|
||||
@@ -82,8 +82,8 @@ const NotificationsSidebar = () => {
|
||||
}
|
||||
|
||||
const fetchMessages = useCallback((status = 'UNREAD') => {
|
||||
const chosenCompanyId = storeGet.main.chosenCompanyId();
|
||||
const userData = storeGet.main.userData();
|
||||
const chosenCompanyId = storeGet('chosenCompanyId');
|
||||
const userData = storeGet('userData');
|
||||
const role = pathOr('', ['role', 'roleType'], userData);
|
||||
const bodyParams = getPaginationQuery(status, currentPage);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import { intersection } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore, useTrackedStore } from '../../store';
|
||||
import { storeSet, useStoreValue, useTrackedValue } from '../../store';
|
||||
|
||||
// components
|
||||
import { Menu } from 'primereact/menu';
|
||||
@@ -12,11 +12,11 @@ import { Toast } from 'primereact/toast';
|
||||
|
||||
const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
const navigate = useNavigate();
|
||||
const userData = useTrackedStore().main.userData();
|
||||
const userData = useTrackedValue('userData');
|
||||
const fulleName = `${userData.firstName} ${userData.lastName}`;
|
||||
const permissions = useStore().main.getPermissions();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId()
|
||||
const permissions = useStoreValue('getPermissions');
|
||||
const companies = useStoreValue('companies');
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId')
|
||||
const [companyItems, setCompanyItems] = useState([]);
|
||||
const toast = useRef(null);
|
||||
let items = [
|
||||
@@ -75,7 +75,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
label: __('Logout', 'gepafin'),
|
||||
icon: 'pi pi-sign-out',
|
||||
command: () => {
|
||||
storeSet.main.doLogout();
|
||||
storeSet('doLogout');
|
||||
window.location.reload();
|
||||
},
|
||||
enable: true
|
||||
@@ -84,7 +84,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
|
||||
const switchCompany = (id) => {
|
||||
if (chosenCompanyId !== id) {
|
||||
storeSet.main.chosenCompanyId(id);
|
||||
storeSet('chosenCompanyId', id);
|
||||
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
|
||||
@@ -52,7 +52,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => {
|
||||
formData.endTime = tzAwareDate.toISOString().substring(11, 16);
|
||||
}
|
||||
}
|
||||
const initial = storeGet.main.formInitialData();
|
||||
const initial = storeGet('formInitialData');
|
||||
|
||||
const isEqual = equal(initial, formData);
|
||||
// debug
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const set404FromErrorResponse = (data) => {
|
||||
if (data && data.status === 'NOT_FOUND') {
|
||||
//storeSet.main.isError404(true);
|
||||
//storeSet('isError404', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import { __ } from '@wordpress/i18n';
|
||||
import { intersection, is } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// components
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import HelpIcon from '../../../../icons/HelpIcon';
|
||||
|
||||
const AppSidebar = () => {
|
||||
const permissions = useStore().main.getPermissions();
|
||||
const permissions = useStoreValue('getPermissions');
|
||||
|
||||
const items = [
|
||||
{
|
||||
|
||||
@@ -7,13 +7,13 @@ import LogoIcon from '../../../../icons/LogoIcon';
|
||||
import { Button } from 'primereact/button';
|
||||
import TopBarProfileMenu from '../../../../components/TopBarProfileMenu';
|
||||
import NotificationsSidebar from '../../../../components/NotificationsSidebar';
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
import { head } from 'ramda';
|
||||
|
||||
const AppTopbar = () => {
|
||||
const menuLeft = useRef(null);
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStoreValue('companies');
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
const startContent = <Link to="/">
|
||||
|
||||
@@ -3,18 +3,18 @@ import { __ } from '@wordpress/i18n';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { useStore, storeSet, storeGet } from '../../store';
|
||||
import { useStoreValue, storeSet } from '../../store';
|
||||
|
||||
// components
|
||||
import AppSidebar from './components/AppSidebar';
|
||||
import AppTopbar from './components/AppTopbar';
|
||||
|
||||
const DefaultLayout = ({ children }) => {
|
||||
const isError404 = useStore().main.isError404();
|
||||
const isError404 = useStoreValue('isError404');
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.isError404(false);
|
||||
storeSet('isError404', false);
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useDebounce } from 'primereact/hooks';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore, storeGet } from '../../store';
|
||||
import { storeSet, useStoreValue, storeGet } from '../../store';
|
||||
|
||||
// components
|
||||
import { Messages } from 'primereact/messages';
|
||||
@@ -26,7 +26,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
|
||||
const AddCompany = () => {
|
||||
const navigate = useNavigate();
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const infoMsgs = useRef(null);
|
||||
const [, debouncedPivaValue, setInputPiva] = useDebounce('', 1000);
|
||||
const [vatCheckResponse, setVatCheckResponse] = useState({});
|
||||
@@ -61,7 +61,7 @@ const AddCompany = () => {
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
infoMsgs.current.clear();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const submitData = {
|
||||
...formData,
|
||||
vatCheckResponse
|
||||
@@ -73,7 +73,7 @@ const AddCompany = () => {
|
||||
const updateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const company = klona(data.data);
|
||||
const companies = storeGet.main.companies();
|
||||
const companies = storeGet('companies');
|
||||
const existingCompany = head(companies.filter(o => o.id === company.id));
|
||||
let newCompanies = [];
|
||||
|
||||
@@ -81,10 +81,10 @@ const AddCompany = () => {
|
||||
newCompanies = companies.map(o => o.id === company.id ? company : o)
|
||||
} else {
|
||||
newCompanies = [...companies, company];
|
||||
storeSet.main.chosenCompanyId(company.id);
|
||||
storeSet('chosenCompanyId', company.id);
|
||||
}
|
||||
|
||||
storeSet.main.companies(newCompanies);
|
||||
storeSet('companies', newCompanies);
|
||||
|
||||
if (company.isLegalRepresentant) {
|
||||
navigate('/');
|
||||
@@ -93,12 +93,12 @@ const AddCompany = () => {
|
||||
}
|
||||
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const updateError = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const checkVatNumber = (value) => {
|
||||
@@ -106,7 +106,7 @@ const AddCompany = () => {
|
||||
const isValid = isPIVA(value);
|
||||
|
||||
if (isValid) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
CompanyService.checkVat(checkVatCallback, errCheckVatCallback, [['vatNumber', value]])
|
||||
} else {
|
||||
setEmptyValues();
|
||||
@@ -139,13 +139,13 @@ const AddCompany = () => {
|
||||
setEmptyValues();
|
||||
}
|
||||
trigger();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCheckVatCallback = (data) => {
|
||||
setEmptyValues();
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
/*const shouldDisableFiscalCode = () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { wrap } from 'object-path-immutable';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../../../store';
|
||||
import { storeGet, storeSet, useStoreValue } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
@@ -36,9 +36,9 @@ import { Badge } from 'primereact/badge';
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [expandedRows, setExpandedRows] = useState(null);
|
||||
@@ -49,7 +49,7 @@ const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
if (existingCompany && !isAsyncRequest) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
BandoService.getBandi(getCallback, errGetCallbacks, [
|
||||
['companyId', chosenCompanyId],
|
||||
['onlyPreferredCall', showOnlyPreferred]
|
||||
@@ -62,12 +62,12 @@ const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||
setItems(getFormattedBandiData(data.data));
|
||||
setStatuses(uniq(data.data.map(o => o.status)))
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallbacks = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
@@ -124,7 +124,7 @@ const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||
};
|
||||
|
||||
const addToFavourites = (id, preferredId) => {
|
||||
const companyId = storeGet.main.chosenCompanyId()
|
||||
const companyId = storeGet('chosenCompanyId')
|
||||
const data = {
|
||||
companyId,
|
||||
callId: id
|
||||
|
||||
@@ -4,15 +4,15 @@ import { Link } from 'react-router-dom';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import AllBandiAccordion from './components/AllBandiAccordion';
|
||||
import ErrorBoundary from '../../components/ErrorBoundary';
|
||||
|
||||
const BandiBeneficiario = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
return (
|
||||
|
||||
@@ -5,7 +5,7 @@ import { wrap } from 'object-path-immutable';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../../../store';
|
||||
import { storeGet, storeSet, useStoreValue } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
@@ -29,9 +29,9 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
|
||||
const AllBandiPreferredAccordion = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [expandedRows, setExpandedRows] = useState(null);
|
||||
@@ -42,8 +42,8 @@ const AllBandiPreferredAccordion = () => {
|
||||
const existingCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
if (existingCompany) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
const userData = storeGet.main.userData();
|
||||
storeSet('setAsyncRequest');
|
||||
const userData = storeGet('userData');
|
||||
PreferredBandoService.getPreferredCalls(getCallback, errGetCallbacks, [
|
||||
['companyId', chosenCompanyId],
|
||||
['userId', userData.id]
|
||||
@@ -56,12 +56,12 @@ const AllBandiPreferredAccordion = () => {
|
||||
setItems(getFormattedBandiData(data.data));
|
||||
setStatuses(uniq(data.data.map(o => o.status)))
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallbacks = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
@@ -108,7 +108,7 @@ const AllBandiPreferredAccordion = () => {
|
||||
};
|
||||
|
||||
const addToFavourites = (id, preferredId) => {
|
||||
const companyId = storeGet.main.chosenCompanyId()
|
||||
const companyId = storeGet('chosenCompanyId')
|
||||
const data = {
|
||||
companyId,
|
||||
callId: id
|
||||
|
||||
@@ -4,14 +4,14 @@ import { Link } from 'react-router-dom';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import AllBandiAccordion from '../BandiBeneficiario/components/AllBandiAccordion';
|
||||
|
||||
const BandiPreferredBeneficiario = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
return (
|
||||
|
||||
@@ -10,7 +10,7 @@ import equal from 'fast-deep-equal';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, storeGet, useStore } from '../../store';
|
||||
import { storeSet, storeGet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../service/application-service';
|
||||
@@ -52,7 +52,7 @@ import { defaultMaxFileSize } from '../../configData';
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoApplication = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const { id } = useParams();
|
||||
const [isExpired, setIsExpired] = useState(false);
|
||||
const [formData, setFormData] = useState([]);
|
||||
@@ -68,7 +68,7 @@ const BandoApplication = () => {
|
||||
const [companyDocs, setCompanyDocs] = useState([]);
|
||||
const [personalDocs, setPersonalDocs] = useState([]);
|
||||
const [isRequestForApplData, setIsRequestForApplData] = useState(false);
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const previousStatus = useRef('');
|
||||
const toast = useRef(null);
|
||||
const formMsgs = useRef(null);
|
||||
@@ -111,7 +111,7 @@ const BandoApplication = () => {
|
||||
|
||||
const onSubmit = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.updateStatusApplication(applId, {}, submitApplicationCallback, errSubmitApplicationCallback, [
|
||||
@@ -125,11 +125,11 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'?
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errSubmitApplicationCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
@@ -179,7 +179,7 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.status);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errValidateApplicationCallback = (data) => {
|
||||
@@ -203,7 +203,7 @@ const BandoApplication = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const saveDraft = (saveAndMove = '') => {
|
||||
@@ -237,7 +237,7 @@ const BandoApplication = () => {
|
||||
|
||||
if (formId) {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.clear();
|
||||
@@ -255,7 +255,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
|
||||
const saveDraftCallback = (data, saveAndMove = '') => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -266,7 +266,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
if (!isEmpty(saveAndMove) && is(String, saveAndMove)) {
|
||||
if (['NEXT', 'PREVIOUS'].includes(saveAndMove)) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationService.getApplicationForm(data.data.id, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['formId', formId],
|
||||
['companyId', chosenCompanyId],
|
||||
@@ -274,7 +274,7 @@ const BandoApplication = () => {
|
||||
]);
|
||||
} else if (['VALIDATE'].includes(saveAndMove)) {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.validateApplication(applId, {}, validateApplicationCallback, errValidateApplicationCallback);
|
||||
@@ -288,7 +288,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
|
||||
const errSaveDraftCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (formMsgs.current) {
|
||||
formMsgs.current.show([
|
||||
@@ -338,7 +338,7 @@ const BandoApplication = () => {
|
||||
setIsExpired(isCallExpired);
|
||||
|
||||
const chosenCompanyId = data.data.companyId;
|
||||
const companies = storeGet.main.companies();
|
||||
const companies = storeGet('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
let formDataInitial = {};
|
||||
let dynamicData = {
|
||||
@@ -360,7 +360,7 @@ const BandoApplication = () => {
|
||||
}, dynamicData);
|
||||
}
|
||||
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
Object.keys(userData).reduce((acc, cur) => {
|
||||
if ([
|
||||
'email', 'firstName', 'lastName', 'phoneNumber', 'codiceFiscale'
|
||||
@@ -403,12 +403,12 @@ const BandoApplication = () => {
|
||||
reset();
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
setIsRequestForApplData(false);
|
||||
}
|
||||
|
||||
const errGetApplFormCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
setIsRequestForApplData(false);
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (toast.current) {
|
||||
@@ -467,7 +467,7 @@ const BandoApplication = () => {
|
||||
|
||||
const onDownloadApplicationPdf = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
ApplicationService.downloadApplicationPdf(applId, {}, getPdfCallback, errPdfCallback);
|
||||
}
|
||||
@@ -482,23 +482,23 @@ const BandoApplication = () => {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errPdfCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getSignedPdfCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setSignedPdfFile([data.data]);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errSignedPdfCallbacks = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const handleSetSignedDocumentFromFileupload = (fieldName, stateFieldData) => {
|
||||
@@ -511,7 +511,7 @@ const BandoApplication = () => {
|
||||
|
||||
const doChangeToDraft = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.updateStatusApplication(applId, {}, changeToDraftCallback, errChangeToDraftCallback, [
|
||||
@@ -525,11 +525,11 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.status);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errChangeToDraftCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
@@ -613,7 +613,7 @@ const BandoApplication = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationService.getApplicationForm(applId, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['companyId', chosenCompanyId]
|
||||
]);
|
||||
@@ -628,7 +628,7 @@ const BandoApplication = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationService.getApplicationSignedPdf(applId, getSignedPdfCallback, errSignedPdfCallbacks);
|
||||
}
|
||||
}
|
||||
@@ -646,7 +646,7 @@ const BandoApplication = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
setIsRequestForApplData(true);
|
||||
ApplicationService.getApplicationForm(applId, getApplFormCallback, errGetApplFormCallbacks, [
|
||||
['companyId', chosenCompanyId]
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form';
|
||||
import 'quill/dist/quill.core.css';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../service/application-service';
|
||||
@@ -50,9 +50,9 @@ const BandoApplicationPreview = () => {
|
||||
const [totalSteps, setTotalSteps] = useState(0);
|
||||
const [applicationStatus, setApplicationStatus] = useState('');
|
||||
const [activeStep, setActiveStep] = useState(1);
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const role = useStore().main.getRole();
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const role = useStoreValue('getRole');
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const toast = useRef(null);
|
||||
const formMsgs = useRef(null);
|
||||
const {
|
||||
@@ -90,7 +90,7 @@ const BandoApplicationPreview = () => {
|
||||
|
||||
const onValidate = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.validateApplication(applId, {}, validateApplicationCallback, errValidateApplicationCallback);
|
||||
@@ -107,7 +107,7 @@ const BandoApplicationPreview = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errValidateApplicationCallback = (data) => {
|
||||
@@ -118,7 +118,7 @@ const BandoApplicationPreview = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const saveDraft = (saveAndMove = '') => {
|
||||
@@ -131,7 +131,7 @@ const BandoApplicationPreview = () => {
|
||||
}
|
||||
|
||||
const goBackward = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const queryParams = 'ROLE_BENEFICIARY' === role
|
||||
? [
|
||||
['formId', formId],
|
||||
@@ -147,7 +147,7 @@ const BandoApplicationPreview = () => {
|
||||
}
|
||||
|
||||
const goForward = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const queryParams = 'ROLE_BENEFICIARY' === role
|
||||
? [
|
||||
['formId', formId],
|
||||
@@ -172,8 +172,8 @@ const BandoApplicationPreview = () => {
|
||||
setApplicationStatus(data.data.applicationStatus)
|
||||
setActiveStep(data.data.currentStep);
|
||||
|
||||
/*const chosenCompanyId = storeGet.main.chosenCompanyId();
|
||||
const companies = storeGet.main.companies();
|
||||
/*const chosenCompanyId = storeGet('chosenCompanyId');
|
||||
const companies = storeGet('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));*/
|
||||
let formDataInitial = {};
|
||||
let dynamicData = {
|
||||
@@ -206,11 +206,11 @@ const BandoApplicationPreview = () => {
|
||||
reset();
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetApplFormCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'VALIDATION_ERROR') {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -226,7 +226,7 @@ const BandoApplicationPreview = () => {
|
||||
|
||||
const onDownloadApplicationPdf = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
ApplicationService.downloadApplicationPdf(applId, {}, getPdfCallback, errPdfCallback);
|
||||
}
|
||||
@@ -241,12 +241,12 @@ const BandoApplicationPreview = () => {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errPdfCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const actionBtns = <div className="appPageSection__actions">
|
||||
@@ -327,7 +327,7 @@ const BandoApplicationPreview = () => {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const queryParams = ['ROLE_BENEFICIARY', 'ROLE_CONFIDI'].includes(role)
|
||||
? [
|
||||
['companyId', chosenCompanyId]
|
||||
|
||||
@@ -99,7 +99,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
delete formData.startDate;
|
||||
delete formData.endDate;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
if (!formData.id) {
|
||||
BandoService.createBando(formData, createCallback, errCreateCallback);
|
||||
} else {
|
||||
@@ -108,7 +108,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
|
||||
const createCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -119,7 +119,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
const values = getValues();
|
||||
if (!values.id && data.data.id) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const sampleFormData = {
|
||||
label: `Evaluation form for call #${data.data.id}`,
|
||||
content: []
|
||||
@@ -141,19 +141,19 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const createFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
navigate(`/bandi/${resp.data.callId}`);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCreateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
@@ -189,11 +189,11 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
});
|
||||
setFaqOptions(faqItems);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errLookupdataCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const shouldDisableField = (fieldName) => {
|
||||
@@ -223,7 +223,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}, [errors, isValid]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.formInitialData(initialData);
|
||||
storeSet('formInitialData', initialData);
|
||||
setFormInitialData(initialData);
|
||||
}, [initialData]);
|
||||
|
||||
@@ -256,7 +256,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
LookupdataService.getItems(lookupdataCallback, errLookupdataCallback, [['type', ['AIMED_TO', 'FAQ']]]);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formInitialData({});
|
||||
storeSet('formInitialData', {});
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
delete formData.startDate;
|
||||
delete formData.endDate;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
if (values.evaluationVersion === 'V1') {
|
||||
BandoService.updateBandoStep2(formData.id, formData, createCallback, errCreateCallback);
|
||||
} else if (values.evaluationVersion === 'V2') {
|
||||
@@ -102,7 +102,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
|
||||
const createCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
@@ -116,7 +116,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
|
||||
const errCreateCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
console.log('errCreateCallback', data);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}, [errors, isValid]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.formInitialData(initialData);
|
||||
storeSet('formInitialData', initialData);
|
||||
setFormInitialData(initialData);
|
||||
}, [initialData]);
|
||||
|
||||
@@ -205,7 +205,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
LookupdataService.getItems(lookupdataCallback, errLookupdataCallback, [['type', ['CHECKLIST', 'EVALUATION_CRITERIA']]]);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formInitialData({});
|
||||
storeSet('formInitialData', {});
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
}
|
||||
|
||||
const onSaveDraft = () => {
|
||||
const content = storeGet.main.formElements();
|
||||
const formId = storeGet.main.formId();
|
||||
const content = storeGet('formElements');
|
||||
const formId = storeGet('formId');
|
||||
const formData = {
|
||||
label: formName,
|
||||
content
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
EvaluationFormsService.updateForm(formId, formData, updateFormCallback, errUpdateFormCallback)
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
@@ -77,51 +77,52 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(
|
||||
//storeSet('elementItems', elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet(
|
||||
'elementItems',
|
||||
data.data
|
||||
.filter(o => !['fileselect'].includes(o.name))
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder)
|
||||
);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetElementItemsCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.formId(resp.data.id);
|
||||
storeSet.main.formLabel(resp.data.label);
|
||||
storeSet('formId', resp.data.id);
|
||||
storeSet('formLabel', resp.data.label);
|
||||
setFormName(resp.data.label);
|
||||
setBandoStatus(resp.data.callStatus);
|
||||
const elements = klona(resp.data.content);
|
||||
storeSet.main.formElements(elements);
|
||||
storeSet('formElements', elements);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
EvaluationFormsService.getFormForCall(id, getFormCallback, errGetFormCallback)
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formId(0);
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
storeSet('formId', 0);
|
||||
storeSet('formElements', []);
|
||||
storeSet('activeElement', '');
|
||||
storeSet('selectedElement', '');
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { is, isNil, isEmpty } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import BandoService from '../../service/bando-service';
|
||||
@@ -24,9 +24,10 @@ import FormsService from '../../service/forms-service';
|
||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import BandoEditFormStep3 from './components/BandoEditFormStep3';
|
||||
import { ConfirmPopup, confirmPopup } from 'primereact/confirmpopup';
|
||||
|
||||
const BandoEdit = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams();
|
||||
const [activeStep, setActiveStep] = useState(null)
|
||||
@@ -89,7 +90,7 @@ const BandoEdit = () => {
|
||||
}
|
||||
|
||||
const validateBando = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
bandoMsgs.current.clear();
|
||||
BandoService.validateBando(id, validateCallback, errValidateCallback);
|
||||
}
|
||||
@@ -115,12 +116,12 @@ const BandoEdit = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errValidateCallback = (resp) => {
|
||||
if (resp.status === 'VALIDATION_ERROR') {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (bandoMsgs.current) {
|
||||
bandoMsgs.current.show(resp.data.map((v, i) => ({
|
||||
id: i,
|
||||
@@ -142,7 +143,7 @@ const BandoEdit = () => {
|
||||
}
|
||||
|
||||
const publishBando = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
bandoMsgs.current.clear();
|
||||
BandoService.updateBandoStatus(id, publishCallback, errPublishCallback, [['status', 'PUBLISH']]);
|
||||
}
|
||||
@@ -172,7 +173,7 @@ const BandoEdit = () => {
|
||||
}
|
||||
setData(resp.data);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errPublishCallback = (resp) => {
|
||||
@@ -219,12 +220,12 @@ const BandoEdit = () => {
|
||||
}
|
||||
setData(resp.data);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const standardErrCallback = (resp) => {
|
||||
@@ -237,18 +238,70 @@ const BandoEdit = () => {
|
||||
}
|
||||
]);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormsCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setForms(resp.data);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const confirmDelete = (event) => {
|
||||
confirmPopup({
|
||||
target: event.currentTarget,
|
||||
message: __('Sei sicuro di mettere il bando in bozza?', 'gepafin'),
|
||||
acceptLabel: __('Si', 'gepafin'),
|
||||
icon: 'pi pi-info-circle',
|
||||
defaultFocus: 'reject',
|
||||
acceptClassName: 'p-button-danger',
|
||||
accept: unpublishBando,
|
||||
reject: () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const unpublishBando = () => {
|
||||
storeSet('setAsyncRequest');
|
||||
bandoMsgs.current.clear();
|
||||
BandoService.updateBandoStatus(id, unpublishCallback, errUnpublishCallback, [['status', 'DRAFT']]);
|
||||
}
|
||||
|
||||
const unpublishCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (bandoMsgs.current) {
|
||||
bandoMsgs.current.show([
|
||||
{
|
||||
id: '99',
|
||||
sticky: true, severity: 'success', summary: '',
|
||||
detail: __('Stato cambiato!', 'gepafin'),
|
||||
closable: false
|
||||
}
|
||||
]);
|
||||
}
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('Stato cambiato!', 'gepafin')
|
||||
});
|
||||
}
|
||||
if (resp.data.docs) {
|
||||
resp.data.docs = resp.data.docs
|
||||
.filter(o => o.source === 'CALL' && o.type === 'DOCUMENT');
|
||||
}
|
||||
setData(resp.data);
|
||||
}
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUnpublishCallback = (resp) => {
|
||||
standardErrCallback(resp);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
setActiveStep(0);
|
||||
|
||||
const parsed = parseInt(id)
|
||||
@@ -259,7 +312,7 @@ const BandoEdit = () => {
|
||||
status: null,
|
||||
evaluationVersion: 'V2'
|
||||
});
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
|
||||
if (bandoMsgs.current) {
|
||||
bandoMsgs.current.clear();
|
||||
@@ -307,10 +360,12 @@ const BandoEdit = () => {
|
||||
{!isEmpty(data)
|
||||
? <>
|
||||
{activeStep === 0
|
||||
? <BandoEditFormStep1 initialData={data} setInitialData={setData} ref={formRef} status={data.status}/>
|
||||
? <BandoEditFormStep1 initialData={data} setInitialData={setData} ref={formRef}
|
||||
status={data.status}/>
|
||||
: null}
|
||||
{activeStep === 1
|
||||
? <BandoEditFormStep2 initialData={data} setInitialData={setData} ref={formRef} status={data.status}/>
|
||||
? <BandoEditFormStep2 initialData={data} setInitialData={setData} ref={formRef}
|
||||
status={data.status}/>
|
||||
: null}
|
||||
{activeStep === 2 && data.evaluationVersion === 'V2'
|
||||
? <BandoEditFormStep3/>
|
||||
@@ -363,6 +418,14 @@ const BandoEdit = () => {
|
||||
disabled={!(data.status === 'READY_TO_PUBLISH')}
|
||||
onClick={publishBando}
|
||||
label={__('Publish', 'gepafin')}/>
|
||||
{'PUBLISH' === data.status
|
||||
? <>
|
||||
<ConfirmPopup/>
|
||||
<Button
|
||||
onClick={confirmDelete}
|
||||
disabled={isAsyncRequest}
|
||||
severity="warning"
|
||||
label={__('Mettere in bozza', 'gepafin')}/></> : null}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -177,7 +177,7 @@ const BandoFlowEdit = () => {
|
||||
}, [flowStructure, forms]);
|
||||
|
||||
const doSave = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const bandoId = getBandoId();
|
||||
|
||||
if (flowMsgs.current) {
|
||||
@@ -197,12 +197,12 @@ const BandoFlowEdit = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFlowCreateCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormsCallback = (data) => {
|
||||
@@ -212,15 +212,15 @@ const BandoFlowEdit = () => {
|
||||
setFormOptions([{ label: '', value: '' }, ...formOptions]);
|
||||
const bandoId = getBandoId();
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FlowService.getFlow(bandoId, (resp) => getFlowCallback(resp, data.data), errGetFlowCallback);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormsCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFlowCallback = (data, forms) => {
|
||||
@@ -261,12 +261,12 @@ const BandoFlowEdit = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFlowCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const setItemRef = (id, element) => {
|
||||
@@ -314,7 +314,7 @@ const BandoFlowEdit = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const bandoId = getBandoId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getFormsForCall(bandoId, getFormsCallback, errGetFormsCallback);
|
||||
}, [id]);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ const BandoForms = () => {
|
||||
const selectedFormArr = forms.filter(o => o.value === selectedForDuplicateForm);
|
||||
|
||||
if (!isEmpty(selectedFormArr)) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getFormById(selectedForDuplicateForm, getFormDuplicateCallback, errGetFormDuplicateCallbacks);
|
||||
}
|
||||
}
|
||||
@@ -81,17 +81,17 @@ const BandoForms = () => {
|
||||
errFormCreateCallback
|
||||
);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormDuplicateCallbacks = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const formCreateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -108,7 +108,7 @@ const BandoForms = () => {
|
||||
}
|
||||
|
||||
const errFormCreateCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
@@ -126,12 +126,12 @@ const BandoForms = () => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setBandoStatus(data.data.status);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormsCallback = (data) => {
|
||||
@@ -139,12 +139,12 @@ const BandoForms = () => {
|
||||
const forms = data.data.map(o => ({ label: o.label, value: o.id }))
|
||||
setForms(forms);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormsCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getAllBandiCallback = (data) => {
|
||||
@@ -171,7 +171,7 @@ const BandoForms = () => {
|
||||
|
||||
const doDuplicateFormOfAnotherBando = () => {
|
||||
if (selectedBandoIdForDuplicate !== 0 && selectedFormIdForDuplicate !== 0) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getFormById(selectedFormIdForDuplicate, getFormDuplicateCallback, errGetFormDuplicateCallbacks);
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ const BandoForms = () => {
|
||||
const parsed = parseInt(id)
|
||||
const bandoId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
BandoService.getBando(id, getCallback, errGetCallback);
|
||||
FormsService.getFormsForCall(bandoId, getFormsCallback, errGetFormsCallback);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const BuilderDropzone = () => {
|
||||
return item;
|
||||
},
|
||||
hover(item, monitor) {
|
||||
storeSet.main.moveElement(-1, 0, item);
|
||||
storeSet('moveElement', -1, 0, item);
|
||||
item.index = 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import { head, isEmpty, pathOr } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../../../store';
|
||||
import { storeSet, useStoreValue } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import uniqid from '../../../../helpers/uniqid';
|
||||
@@ -17,10 +17,10 @@ import { Tag } from 'primereact/tag';
|
||||
import BuilderElementProperLabel from '../BuilderElementProperLabel';
|
||||
|
||||
const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const draggingElementId = useStore().main.draggingElementId();
|
||||
const selectedElement = useStore().main.selectedElement();
|
||||
const draggingElementId = useStoreValue('draggingElementId');
|
||||
const selectedElement = useStoreValue('selectedElement');
|
||||
const ref = useRef(null);
|
||||
const elements = useStore().main.formElements();
|
||||
const elements = useStoreValue('formElements');
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const elementSettings = pathOr([], ['settings'], element);
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
@@ -38,7 +38,7 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
}
|
||||
},
|
||||
drop(item, monitor) {
|
||||
storeSet.main.draggingElementId(0);
|
||||
storeSet('draggingElementId', 0);
|
||||
return item;
|
||||
},
|
||||
hover(item, monitor) {
|
||||
@@ -98,15 +98,15 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
});
|
||||
|
||||
const move = (dragIndex, hoverIndex, item) => {
|
||||
storeSet.main.moveElement(dragIndex, hoverIndex, item);
|
||||
storeSet('moveElement', dragIndex, hoverIndex, item);
|
||||
}
|
||||
|
||||
const openSettings = () => {
|
||||
storeSet.main.activeElement(id);
|
||||
storeSet('activeElement', id);
|
||||
}
|
||||
|
||||
const selectElement = () => {
|
||||
storeSet.main.selectedElement(id);
|
||||
storeSet('selectedElement', id);
|
||||
}
|
||||
|
||||
const duplicateElement = useCallback(() => {
|
||||
@@ -123,12 +123,12 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
copyElement.id = uniqid();
|
||||
const originalIndex = elements.map(o => o.id).indexOf(id);
|
||||
const newElements = [...elements].toSpliced(originalIndex + 1, 0, copyElement);
|
||||
storeSet.main.formElements(newElements);
|
||||
storeSet('formElements', newElements);
|
||||
}
|
||||
}, [elements]);
|
||||
|
||||
const remove = () => {
|
||||
storeSet.main.removeElement(id);
|
||||
storeSet('removeElement', id);
|
||||
}
|
||||
|
||||
const opacity = isDragging ? 0 : 1;
|
||||
|
||||
@@ -12,7 +12,7 @@ const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
|
||||
type: ItemTypes.FIELD,
|
||||
item: () => {
|
||||
const newId = uniqid();
|
||||
storeSet.main.draggingElementId(newId);
|
||||
storeSet('draggingElementId', newId);
|
||||
return { name, dbId, id: newId, index: -1 }
|
||||
},
|
||||
end: (item, monitor) => {
|
||||
@@ -23,8 +23,8 @@ const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
|
||||
return item;
|
||||
}
|
||||
} else {
|
||||
storeSet.main.removeElement(item.id);
|
||||
storeSet.main.draggingElementId(0);
|
||||
storeSet('removeElement', item.id);
|
||||
storeSet('draggingElementId', 0);
|
||||
}
|
||||
},
|
||||
collect: (monitor) => ({
|
||||
|
||||
@@ -2,11 +2,11 @@ import { useState, useEffect } from 'react'
|
||||
import { head, pathOr } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
import renderHtmlContent from '../../../../helpers/renderHtmlContent';
|
||||
|
||||
const BuilderElementProperLabel = ({ id, defaultLabel }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const elements = useStoreValue('formElements');
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const [label, setLabel] = useState('');
|
||||
const isRequired = pathOr(false, ['validators', 'isRequired'], element);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { head, is, isEmpty, isNil, uniq } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeGet, useStore } from '../../../../../../store';
|
||||
import { storeGet, useStoreValue } from '../../../../../../store';
|
||||
|
||||
// tools
|
||||
import renderHtmlContent from '../../../../../../helpers/renderHtmlContent';
|
||||
@@ -23,7 +23,7 @@ import { mimeTypes } from '../../../../../../configData';
|
||||
|
||||
const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
const [existingVars, setExistingVars] = useState([]);
|
||||
const documentCategories = useStore().main.documentCategories();
|
||||
const documentCategories = useStoreValue('documentCategories');
|
||||
|
||||
const settingLabels = {
|
||||
label: __('Label', 'gepafin'),
|
||||
@@ -131,8 +131,8 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const elements = storeGet.main.formElements();
|
||||
const activeElement = storeGet.main.activeElement();
|
||||
const elements = storeGet('formElements');
|
||||
const activeElement = storeGet('activeElement');
|
||||
const vars = elements
|
||||
.filter(o => o.id !== activeElement)
|
||||
// eslint-disable-next-line
|
||||
|
||||
@@ -5,7 +5,7 @@ import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../../../store';
|
||||
import { storeGet, storeSet, useStoreValue } from '../../../../store';
|
||||
|
||||
// components
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
@@ -20,9 +20,9 @@ import { MultiSelect } from 'primereact/multiselect';
|
||||
import { dynamicDataOptions } from '../../../../configData';
|
||||
|
||||
const BuilderElementSettings = ({ closeSettingsFn, callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
const criteriaOptions = useStore().main.bandoCriteria();
|
||||
const elements = useStoreValue('formElements');
|
||||
const activeElement = useStoreValue('activeElement');
|
||||
const criteriaOptions = useStoreValue('bandoCriteria');
|
||||
const [activeElementData, setActiveElementData] = useState({});
|
||||
const [settings, setSettings] = useState([]);
|
||||
const [validators, setValidators] = useState({});
|
||||
@@ -77,7 +77,7 @@ const BuilderElementSettings = ({ closeSettingsFn, callStatus, context }) => {
|
||||
newActiveElementData = wrap(newActiveElementData).set(['criteria'], criteria).value();
|
||||
const newElements = elements.map(o => o.id === newActiveElementData.id ? newActiveElementData : o);
|
||||
|
||||
storeSet.main.formElements(newElements);
|
||||
storeSet('formElements', newElements);
|
||||
closeSettingsFn();
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ const BuilderElementSettings = ({ closeSettingsFn, callStatus, context }) => {
|
||||
|
||||
useEffect(() => {
|
||||
const chosen = head(elements.filter(o => o.id === activeElement));
|
||||
const elementItems = storeGet.main.elementItems();
|
||||
const elementItems = storeGet('elementItems');
|
||||
const chosenElementItemCfg = head(elementItems.filter(o => o.name === chosen.name));
|
||||
let settings = [];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../../../store';
|
||||
import { storeSet, useStoreValue } from '../../../../store';
|
||||
|
||||
// components
|
||||
import BuilderElement from '../BuilderElement';
|
||||
@@ -14,10 +14,10 @@ import BuilderDropzone from '../BuilderDropzone';
|
||||
import BlockingOverlay from '../../../../components/BlockingOverlay';
|
||||
|
||||
const FormBuilder = ({ callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const elementItems = useStore().main.elementItems();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const elements = useStoreValue('formElements');
|
||||
const elementItems = useStoreValue('elementItems');
|
||||
const activeElement = useStoreValue('activeElement');
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
|
||||
const renderField = useCallback((field, index) => {
|
||||
return (
|
||||
@@ -45,12 +45,12 @@ const FormBuilder = ({ callStatus, context }) => {
|
||||
}, []);
|
||||
|
||||
const closeSettings = () => {
|
||||
storeSet.main.activeElement('');
|
||||
storeSet('activeElement', '');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
storeSet.main.activeElement('');
|
||||
storeSet('activeElement', '');
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { klona } from 'klona';
|
||||
import { isEmpty, pathOr } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, storeGet, useStore } from '../../store';
|
||||
import { storeSet, storeGet, useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import FormBuilder from './components/FormBuilder';
|
||||
@@ -18,14 +18,16 @@ import { Toast } from 'primereact/toast';
|
||||
import { ConfirmDialog } from 'primereact/confirmdialog';
|
||||
import { Messages } from 'primereact/messages';
|
||||
|
||||
// tools
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
|
||||
// api
|
||||
import FormsService from '../../service/forms-service';
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import BandoService from '../../service/bando-service';
|
||||
import DocumentCategoryService from '../../service/document-category-service';
|
||||
|
||||
// TODO temp data
|
||||
import { elementItems } from '../../tempData';
|
||||
import DocumentCategoryService from '../../service/document-category-service';
|
||||
//import { elementItems } from '../../tempData';
|
||||
|
||||
const BandoFormsEdit = () => {
|
||||
const { id, formId } = useParams();
|
||||
@@ -33,7 +35,7 @@ const BandoFormsEdit = () => {
|
||||
const [formName, setFormName] = useState('');
|
||||
const [visibleConfirmation, setVisibleConfirmation] = useState(false);
|
||||
const [bandoStatus, setBandoStatus] = useState('');
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const formMsgs = useRef(null);
|
||||
const toast = useRef(null);
|
||||
|
||||
@@ -52,7 +54,7 @@ const BandoFormsEdit = () => {
|
||||
formMsgs.current.clear();
|
||||
}
|
||||
|
||||
const content = storeGet.main.formElements();
|
||||
const content = storeGet('formElements');
|
||||
|
||||
if (isEmpty(formName) || isEmpty(content)) {
|
||||
if (isEmpty(formName)) {
|
||||
@@ -90,7 +92,7 @@ const BandoFormsEdit = () => {
|
||||
content
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
if (bandoFormId === 0) {
|
||||
FormsService.createFormForCall(
|
||||
bandoId,
|
||||
@@ -127,11 +129,11 @@ const BandoFormsEdit = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errFormCreateCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'BAD_REQUEST') {
|
||||
setVisibleConfirmation(true);
|
||||
} else {
|
||||
@@ -146,7 +148,7 @@ const BandoFormsEdit = () => {
|
||||
}
|
||||
|
||||
const acceptModification = () => {
|
||||
const content = storeGet.main.formElements();
|
||||
const content = storeGet('formElements');
|
||||
const parsedFormId = parseInt(formId);
|
||||
const bandoFormId = !isNaN(parsedFormId) ? parsedFormId : 0;
|
||||
const formData = {
|
||||
@@ -154,7 +156,7 @@ const BandoFormsEdit = () => {
|
||||
content
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
FormsService.updateForm(
|
||||
bandoFormId,
|
||||
@@ -198,7 +200,7 @@ const BandoFormsEdit = () => {
|
||||
}*/
|
||||
|
||||
const doDelete = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.deleteForm(formId, formDeleteCallback, errFormDeleteCallback)
|
||||
}
|
||||
|
||||
@@ -207,42 +209,42 @@ const BandoFormsEdit = () => {
|
||||
const bandoId = getBandoId();
|
||||
navigate(`/bandi/${bandoId}/forms`);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errFormDeleteCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
/*storeSet.main.elementItems(data.data
|
||||
//storeSet('elementItems', elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet('elementItems', data.data
|
||||
.filter(o => o.id !== 22)
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder));*/
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetElementItemsCallback = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.formId(data.data.id);
|
||||
storeSet.main.formLabel(data.data.label);
|
||||
storeSet('formId', data.data.id);
|
||||
storeSet('formLabel', data.data.label);
|
||||
setFormName(data.data.label);
|
||||
setBandoStatus(data.data.callStatus);
|
||||
const elements = klona(data.data.content);
|
||||
storeSet.main.formElements(elements);
|
||||
storeSet('formElements', elements);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormCallbacks = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getBandoCallback = (data) => {
|
||||
@@ -250,7 +252,7 @@ const BandoFormsEdit = () => {
|
||||
setBandoStatus(data.data.status);
|
||||
const criteria = pathOr([], ['data', 'criteria'], data);
|
||||
const criteriaOptions = criteria.map(o => ({value: o.id, label: o.value}));
|
||||
storeSet.main.bandoCriteria(criteriaOptions);
|
||||
storeSet('bandoCriteria', criteriaOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +262,7 @@ const BandoFormsEdit = () => {
|
||||
|
||||
const getCategories = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.documentCategories(resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
storeSet('documentCategories', resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,11 +274,11 @@ const BandoFormsEdit = () => {
|
||||
const parsedFormId = parseInt(formId)
|
||||
const bandoFormId = !isNaN(parsedFormId) ? parsedFormId : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallback);
|
||||
|
||||
if (bandoFormId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getFormById(bandoFormId, getFormCallback, errGetFormCallbacks);
|
||||
}
|
||||
if (bandoId) {
|
||||
@@ -284,12 +286,12 @@ const BandoFormsEdit = () => {
|
||||
}
|
||||
|
||||
return () => {
|
||||
storeSet.main.formId(0);
|
||||
storeSet.main.formLabel('');
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.bandoCriteria([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
storeSet('formId', 0);
|
||||
storeSet('formLabel', '');
|
||||
storeSet('formElements', []);
|
||||
storeSet('bandoCriteria', []);
|
||||
storeSet('activeElement', '');
|
||||
storeSet('selectedElement', '');
|
||||
}
|
||||
}, [id, formId]);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { evaluate } from 'mathjs';
|
||||
import equal from 'fast-deep-equal';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import FormsService from '../../service/forms-service';
|
||||
@@ -41,7 +41,7 @@ const BandoFormsPreview = () => {
|
||||
const navigate = useNavigate();
|
||||
const [formData, setFormData] = useState([]);
|
||||
const [formName, setFormName] = useState('');
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
@@ -85,12 +85,12 @@ const BandoFormsPreview = () => {
|
||||
const elements = klona(data.data.content);
|
||||
setFormData(elements);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormCallbacks = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -135,7 +135,7 @@ const BandoFormsPreview = () => {
|
||||
const bandoFormId = !isNaN(parsedFormId) ? parsedFormId : 0;
|
||||
|
||||
if (bandoFormId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getFormById(bandoFormId, getFormCallback, errGetFormCallbacks);
|
||||
}
|
||||
}, [id, formId]);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { is, isEmpty, isNil } from 'ramda';
|
||||
import 'quill/dist/quill.core.css';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// tools
|
||||
import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
||||
@@ -25,7 +25,7 @@ import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoView = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -40,7 +40,7 @@ const BandoView = () => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setData(getFormattedBandiData(data.data));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
@@ -54,7 +54,7 @@ const BandoView = () => {
|
||||
]);
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { head, is, isEmpty, isNil } from 'ramda';
|
||||
import 'quill/dist/quill.core.css';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../store';
|
||||
import { storeGet, storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// tools
|
||||
import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
||||
@@ -34,8 +34,8 @@ import { Dialog } from 'primereact/dialog';
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoViewBeneficiario = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -73,7 +73,7 @@ const BandoViewBeneficiario = () => {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCallPdfCallback = (data) => {
|
||||
@@ -84,7 +84,7 @@ const BandoViewBeneficiario = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getBandoId = () => {
|
||||
@@ -144,7 +144,7 @@ const BandoViewBeneficiario = () => {
|
||||
}
|
||||
|
||||
const createApplCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
navigate(`/imieibandi/${data.data.id}`);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ const BandoViewBeneficiario = () => {
|
||||
}
|
||||
]);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
/*const saveToFavourites = () => {
|
||||
@@ -187,7 +187,7 @@ const BandoViewBeneficiario = () => {
|
||||
'response': '',
|
||||
'isVisible': false
|
||||
}
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FaqItemService.addQuestion(id, obj, createQuestionBack, errCreateQuestionCallback, [['companyId', chosenCompanyId]])
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ const BandoViewBeneficiario = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCreateQuestionCallback = (data) => {
|
||||
@@ -214,14 +214,14 @@ const BandoViewBeneficiario = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getBandoCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setData(getFormattedBandiData(data.data));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetBandoCallback = (data) => {
|
||||
@@ -233,7 +233,7 @@ const BandoViewBeneficiario = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
@@ -250,12 +250,12 @@ const BandoViewBeneficiario = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetApplCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const renderHeader = () => {
|
||||
@@ -279,7 +279,7 @@ const BandoViewBeneficiario = () => {
|
||||
const header = renderHeader();
|
||||
|
||||
const addToFavourites = () => {
|
||||
const companyId = storeGet.main.chosenCompanyId();
|
||||
const companyId = storeGet('chosenCompanyId');
|
||||
const bandoId = getBandoId();
|
||||
const formdData = {
|
||||
companyId,
|
||||
@@ -318,12 +318,12 @@ const BandoViewBeneficiario = () => {
|
||||
useEffect(() => {
|
||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0) {
|
||||
const bandoId = getBandoId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback, [
|
||||
['companyId', chosenCompanyId]
|
||||
]);
|
||||
if (REACT_APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
setApplicationObj(true);
|
||||
ApplicationService.getApplications(getApplCallback, errGetApplCallback, [
|
||||
['callId', bandoId],
|
||||
|
||||
@@ -5,7 +5,7 @@ import { is, isEmpty, isNil } from 'ramda';
|
||||
import 'quill/dist/quill.core.css';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// tools
|
||||
import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
||||
@@ -25,7 +25,7 @@ import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoViewPreInstructor = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const [data, setData] = useState({});
|
||||
const [newQuestion, setNewQuestion] = useState('');
|
||||
@@ -35,7 +35,7 @@ const BandoViewPreInstructor = () => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setData(getFormattedBandiData(data.data));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
@@ -49,7 +49,7 @@ const BandoViewPreInstructor = () => {
|
||||
]);
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -25,7 +25,7 @@ import { Link } from 'react-router-dom';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
const DraftApplicationsTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { is } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -26,7 +26,7 @@ import { Tag } from 'primereact/tag';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
const DraftApplicationsTableAsync = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||
|
||||
@@ -90,7 +90,7 @@ const LatestBandiBeneficiarioTableAsync = () => {
|
||||
};
|
||||
|
||||
const addToFavourites = (id, preferredId) => {
|
||||
const companyId = storeGet.main.chosenCompanyId()
|
||||
const companyId = storeGet('chosenCompanyId')
|
||||
const data = {
|
||||
companyId,
|
||||
callId: id
|
||||
|
||||
@@ -4,7 +4,7 @@ import { uniq, isEmpty, isNil } from 'ramda';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeGet, useStore } from '../../../../store';
|
||||
import { storeGet, useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import BandoService from '../../../../service/bando-service';
|
||||
@@ -25,7 +25,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
|
||||
const LatestBandiTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -54,7 +54,7 @@ const LatestBandiTable = () => {
|
||||
}
|
||||
|
||||
const addToFavourites = (id, preferredId) => {
|
||||
const companyId = storeGet.main.chosenCompanyId()
|
||||
const companyId = storeGet('chosenCompanyId')
|
||||
const data = {
|
||||
companyId,
|
||||
callId: id
|
||||
|
||||
@@ -7,7 +7,7 @@ import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -28,8 +28,8 @@ import { ConfirmPopup, confirmPopup } from 'primereact/confirmpopup';
|
||||
import isDateTimeInPast from '../../../../helpers/isDateTimeInPast';
|
||||
|
||||
const MyLatestSubmissionsTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Link } from 'react-router-dom';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -30,8 +30,8 @@ import { confirmPopup, ConfirmPopup } from 'primereact/confirmpopup';
|
||||
import { ProgressBar } from 'primereact/progressbar';
|
||||
|
||||
const MyLatestSubmissionsTableAsync = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { head, isEmpty, pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
@@ -19,8 +19,8 @@ import MyLatestSubmissionsTableAsync from './components/MyLatestSubmissionsTable
|
||||
const DashboardBeneficiario = () => {
|
||||
const navigate = useNavigate();
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStoreValue('companies');
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
const goToAllSubmissions = () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ import { Dropdown } from 'primereact/dropdown';
|
||||
import { Tag } from 'primereact/tag';
|
||||
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
import { klona } from 'klona';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
@@ -32,7 +32,7 @@ const InstructorManagerMieDomandeTable = ({ userId = null, statuses = [] }) => {
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [statusesForFilter, setStatusesForFilter] = useState([]);
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
useEffect(() => {
|
||||
if (!isNil(userId)) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
import AssignedApplicationService from '../../../../service/assigned-application-service';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||
@@ -32,7 +32,7 @@ const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const MieDomandeTableInstructorManagerAsync = ({ userId = null, statuses = [] }) => {
|
||||
const navigate = useNavigate();
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||
|
||||
@@ -9,7 +9,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
import AssignedApplicationService from '../../../../service/assigned-application-service';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||
@@ -32,7 +32,7 @@ const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const DomandeTablePreInstructorAsync = ({ userId = null, statuses = [] }) => {
|
||||
const navigate = useNavigate();
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||
|
||||
@@ -21,7 +21,7 @@ import { Dropdown } from 'primereact/dropdown';
|
||||
import { Tag } from 'primereact/tag';
|
||||
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
import { klona } from 'klona';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
@@ -32,7 +32,7 @@ const PreInstructorDomandeTable = ({ userId = null, statuses = [] }) => {
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [statusesForFilter, setStatusesForFilter] = useState([]);
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
useEffect(() => {
|
||||
if (!isNil(userId)) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import NumberFlow from '@number-flow/react';
|
||||
import { pathOr } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// service
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
@@ -17,7 +17,7 @@ import DomandeTablePreInstructorAsync from './components/DomandeTablePreInstruct
|
||||
const DashboardPreInstructor = () => {
|
||||
const navigate = useNavigate();
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
const goToAllEvaluations = () => {
|
||||
navigate('/domande');
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { head, is, uniq } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
@@ -25,8 +25,8 @@ import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import { confirmPopup, ConfirmPopup } from 'primereact/confirmpopup';
|
||||
|
||||
const DocumentsTable = ({ type, reload = 0 }) => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [docs, setDocs] = useState([]);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
@@ -4,8 +4,12 @@ import { classNames } from 'primereact/utils';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { head, isEmpty, isNil } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import DocumentCategoryService from '../../service/document-category-service';
|
||||
import CompanyDocumentsService from '../../service/company-documents-service';
|
||||
|
||||
// components
|
||||
import DocumentsTable from './components/DocumentsTable';
|
||||
@@ -13,20 +17,18 @@ import { Dialog } from 'primereact/dialog';
|
||||
import { Button } from 'primereact/button';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import { FileUpload } from 'primereact/fileupload';
|
||||
import formatDateString from '../../helpers/formatDateString';
|
||||
import CompanyDocumentsService from '../../service/company-documents-service';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
|
||||
const DocumentsBeneficiary = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [isVisibleAddNewDialog, setIsVisibleAddNewDialog] = useState(false);
|
||||
const documentCategories= useStore().main.documentCategories();
|
||||
const documentCategories= useStoreValue('documentCategories');
|
||||
const [newFileData, setNewFileData] = useState({});
|
||||
const [fileAttached, setFileAttached] = useState([]);
|
||||
const [reloadHash, setReloadHash] = useState(0);
|
||||
@@ -123,7 +125,7 @@ const DocumentsBeneficiary = () => {
|
||||
|
||||
const getCategories = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.documentCategories(resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
storeSet('documentCategories', resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import equal from 'fast-deep-equal';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../store';
|
||||
import { storeGet, storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import ApplicationEvaluationService from '../../service/application-evaluation-service';
|
||||
@@ -57,7 +57,7 @@ const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const DomandaEditInstructorManager = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -179,18 +179,18 @@ const DomandaEditInstructorManager = () => {
|
||||
const getVersion = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data.evaluationVersion === 'V1') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
} else if (resp.data.evaluationVersion === 'V2') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationV2ByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetVersion = (resp) => {
|
||||
@@ -202,7 +202,7 @@ const DomandaEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getCallback = (resp) => {
|
||||
@@ -233,7 +233,7 @@ const DomandaEditInstructorManager = () => {
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (resp) => {
|
||||
@@ -245,7 +245,7 @@ const DomandaEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
@@ -377,7 +377,7 @@ const DomandaEditInstructorManager = () => {
|
||||
afterUpdateCallback();
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateCallback = (data) => {
|
||||
@@ -389,7 +389,7 @@ const DomandaEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const doApprove = useCallback(() => {
|
||||
@@ -635,7 +635,7 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
|
||||
const doGetNDGRequest = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AppointmentService.getNdg(id, getNdgCallback, errGetNdgCallback);
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ const DomandaEditInstructorManager = () => {
|
||||
}));
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetNdgCallback = (data) => {
|
||||
@@ -667,7 +667,7 @@ const DomandaEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const doCreateAppointment = () => {
|
||||
@@ -709,7 +709,7 @@ const DomandaEditInstructorManager = () => {
|
||||
!isEmpty(appointmentData.title) && !isEmpty(appointmentData.text) && !isEmpty(appointmentData.amount)
|
||||
&& !isEmpty(appointmentData.duration) && appointmentData.duration !== 0 && appointmentData.amount !== 0
|
||||
) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const submitData = {
|
||||
'importoBreveTermine': appointmentData.amount,
|
||||
'durataMesiFinanziamento': appointmentData.duration,
|
||||
@@ -740,7 +740,7 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
}
|
||||
setIsVisibleAppointmentDialog(false);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetAppointemntCallback = (data) => {
|
||||
@@ -753,7 +753,7 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
setIsVisibleAppointmentDialog(false);
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const doMakeAdmisible = () => {
|
||||
@@ -771,7 +771,7 @@ const DomandaEditInstructorManager = () => {
|
||||
}, [isAdmissible]);
|
||||
|
||||
const evaluationBlockedForUser = (data = {}) => {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
return isAsyncRequest || userData.id !== data.assignedUserId;
|
||||
}
|
||||
|
||||
@@ -933,7 +933,7 @@ const DomandaEditInstructorManager = () => {
|
||||
const parsed = parseInt(id)
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
|
||||
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
|
||||
['statuses', ['AWAITING', 'RESPONSE_RECEIVED']]
|
||||
|
||||
@@ -20,7 +20,7 @@ import { InputText } from 'primereact/inputtext';
|
||||
import { Toast } from 'primereact/toast';
|
||||
|
||||
import { classificationType, protocolType } from '../../../../configData';
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
const ArchiveDocument = ({
|
||||
applicationId,
|
||||
@@ -36,7 +36,7 @@ const ArchiveDocument = ({
|
||||
const [types, setTypes] = useState([]);
|
||||
const [categories, setCategories] = useState([]);
|
||||
const toast = useRef(null);
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
const openArchivationModal = () => {
|
||||
setIsVisibleDialog(true);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { evaluate } from 'mathjs';
|
||||
import equal from 'fast-deep-equal';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../store';
|
||||
import { storeGet, storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import ApplicationEvaluationService from '../../service/application-evaluation-service';
|
||||
@@ -58,7 +58,7 @@ const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const DomandaEditPreInstructor = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -179,18 +179,18 @@ const DomandaEditPreInstructor = () => {
|
||||
const getVersion = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data.evaluationVersion === 'V1') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
} else if (resp.data.evaluationVersion === 'V2') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationV2ByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetVersion = (resp) => {
|
||||
@@ -202,7 +202,7 @@ const DomandaEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getCallback = (resp) => {
|
||||
@@ -233,7 +233,7 @@ const DomandaEditPreInstructor = () => {
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (resp) => {
|
||||
@@ -245,7 +245,7 @@ const DomandaEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
@@ -377,7 +377,7 @@ const DomandaEditPreInstructor = () => {
|
||||
afterUpdateCallback();
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateCallback = (data) => {
|
||||
@@ -389,7 +389,7 @@ const DomandaEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const doApprove = useCallback(() => {
|
||||
@@ -634,7 +634,7 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
|
||||
const doGetNDGRequest = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AppointmentService.getNdg(id, getNdgCallback, errGetNdgCallback);
|
||||
}
|
||||
|
||||
@@ -654,7 +654,7 @@ const DomandaEditPreInstructor = () => {
|
||||
}));
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetNdgCallback = (data) => {
|
||||
@@ -666,7 +666,7 @@ const DomandaEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const doCreateAppointment = () => {
|
||||
@@ -708,7 +708,7 @@ const DomandaEditPreInstructor = () => {
|
||||
!isEmpty(appointmentData.title) && !isEmpty(appointmentData.text) && !isEmpty(appointmentData.amount)
|
||||
&& !isEmpty(appointmentData.duration) && appointmentData.duration !== 0 && appointmentData.amount !== 0
|
||||
) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const submitData = {
|
||||
'importoBreveTermine': appointmentData.amount,
|
||||
'durataMesiFinanziamento': appointmentData.duration,
|
||||
@@ -739,7 +739,7 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
}
|
||||
setIsVisibleAppointmentDialog(false);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetAppointemntCallback = (data) => {
|
||||
@@ -752,7 +752,7 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
setIsVisibleAppointmentDialog(false);
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const doMakeAdmisible = () => {
|
||||
@@ -770,7 +770,7 @@ const DomandaEditPreInstructor = () => {
|
||||
}, [isAdmissible]);
|
||||
|
||||
const evaluationBlockedForUser = (data = {}) => {
|
||||
const userData = storeGet.main.userData()
|
||||
const userData = storeGet('userData')
|
||||
return isAsyncRequest || userData.id !== data.assignedUserId;
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ const DomandaEditPreInstructor = () => {
|
||||
const parsed = parseInt(id)
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
|
||||
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
|
||||
['statuses', ['AWAITING', 'RESPONSE_RECEIVED', 'CLOSE']]
|
||||
|
||||
@@ -92,7 +92,7 @@ const Domande = () => {
|
||||
|
||||
const saveEditDialog = () => {
|
||||
if (chosenUser !== 0 && chosenApplication !== 0) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AssignedApplicationService.assignApplication(chosenApplication, assignApplCallback, errAssignApplCallback, [
|
||||
['userId', chosenUser]
|
||||
]);
|
||||
@@ -111,7 +111,7 @@ const Domande = () => {
|
||||
}
|
||||
setUpdaterString(uniqid());
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errAssignApplCallback = (data) => {
|
||||
@@ -123,7 +123,7 @@ const Domande = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getStatValue = (key, fallback = '') => {
|
||||
|
||||
@@ -2,13 +2,13 @@ import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import DomandeTablePreInstructorAsync from '../DashboardPreInstructor/components/DomandeTablePreInstructorAsync';
|
||||
|
||||
const DomandeArchivePreInstructor = () => {
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
return (
|
||||
<div className="appPage">
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Link } from 'react-router-dom';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -27,8 +27,8 @@ import { Tag } from 'primereact/tag';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
|
||||
const AllDomandeBeneficiarioTableAsync = ({ statuses }) => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { head, is, uniq } from 'ramda';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -26,8 +26,8 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
|
||||
const BeneficiarioDomandeTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
|
||||
@@ -3,14 +3,14 @@ import { __ } from '@wordpress/i18n';
|
||||
import { head } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import AllDomandeBeneficiarioTableAsync from './components/AllDomandeBeneficiarioTableAsync';
|
||||
|
||||
const DomandeBeneficiario = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
return(
|
||||
|
||||
@@ -92,7 +92,7 @@ const DomandeInstructorManager = () => {
|
||||
|
||||
const saveEditDialog = () => {
|
||||
if (chosenUser !== 0 && chosenApplication !== 0) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AssignedApplicationService.assignApplication(chosenApplication, assignApplCallback, errAssignApplCallback, [
|
||||
['userId', chosenUser]
|
||||
]);
|
||||
@@ -111,7 +111,7 @@ const DomandeInstructorManager = () => {
|
||||
}
|
||||
setUpdaterString(uniqid());
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errAssignApplCallback = (data) => {
|
||||
@@ -123,7 +123,7 @@ const DomandeInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getStats = (data) => {
|
||||
|
||||
@@ -2,13 +2,13 @@ import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import MieDomandeTableInstructorManagerAsync from '../DashboardInstructorManager/components/MieDomandeTableInstructorManagerAsync';
|
||||
|
||||
const DomandeMieInstructorManager = () => {
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
return(
|
||||
<div className="appPage">
|
||||
|
||||
@@ -2,13 +2,13 @@ import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import DomandeTablePreInstructorAsync from '../DashboardPreInstructor/components/DomandeTablePreInstructorAsync';
|
||||
|
||||
const DomandePreInstructor = () => {
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
return(
|
||||
<div className="appPage">
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import { head } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
@@ -13,8 +13,8 @@ import MyLatestSubmissionsTableAsync from '../DashboardBeneficiario/components/M
|
||||
|
||||
const Imieibandi = () => {
|
||||
const navigate = useNavigate();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||
|
||||
const gotToBandiDisponibili = () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import hotkeys from 'hotkeys-js';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
@@ -22,7 +22,7 @@ const API_BASE_URL = process.env.REACT_APP_API_ADDRESS;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const Login = () => {
|
||||
const token = useStore().main.token();
|
||||
const token = useStoreValue('token');
|
||||
const errorMsgs = useRef(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [visibleCacheFaq, setVisibleCacheFaq] = useState(false);
|
||||
@@ -43,7 +43,7 @@ const Login = () => {
|
||||
const validateCallback = (data) => {
|
||||
//console.log('login validateCallback', data)
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.setAuthData({
|
||||
storeSet('setAuthData', {
|
||||
token: data.data.token,
|
||||
userData: data.data.user
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import FormField from '../../components/FormField';
|
||||
@@ -22,7 +22,7 @@ const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const LoginAdmin = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = useStore().main.token();
|
||||
const token = useStoreValue('token');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const errorMsgs = useRef(null);
|
||||
const {
|
||||
@@ -49,7 +49,7 @@ const LoginAdmin = () => {
|
||||
|
||||
const loginCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.setAuthData({
|
||||
storeSet('setAuthData', {
|
||||
token: data.data.token,
|
||||
userData: data.data.user
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import FormField from '../../components/FormField';
|
||||
@@ -22,7 +22,7 @@ const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const LoginConfidi = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = useStore().main.token();
|
||||
const token = useStoreValue('token');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const errorMsgs = useRef(null);
|
||||
const {
|
||||
@@ -49,7 +49,7 @@ const LoginConfidi = () => {
|
||||
|
||||
const loginCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.setAuthData({
|
||||
storeSet('setAuthData', {
|
||||
token: data.data.token,
|
||||
userData: data.data.user
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
@@ -18,8 +18,8 @@ import UserService from '../../service/user-service';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
|
||||
const Profile = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const userData = useStore().main.userData();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const userData = useStoreValue('userData');
|
||||
const toast = useRef(null);
|
||||
|
||||
const {
|
||||
@@ -34,14 +34,14 @@ const Profile = () => {
|
||||
});
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
|
||||
const updateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
storeSet('userData', data.data);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
@@ -50,12 +50,12 @@ const Profile = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const updateError = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
@@ -18,8 +18,8 @@ import UserService from '../../service/user-service';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
|
||||
const ProfileBeneficiario = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const userData = useStore().main.userData();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const userData = useStoreValue('userData');
|
||||
const toast = useRef(null);
|
||||
|
||||
const {
|
||||
@@ -34,14 +34,14 @@ const ProfileBeneficiario = () => {
|
||||
});
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
|
||||
const updateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
storeSet('userData', data.data);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
@@ -50,12 +50,12 @@ const ProfileBeneficiario = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const updateError = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useForm } from 'react-hook-form';
|
||||
//import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore, storeGet } from '../../store';
|
||||
import { storeSet, useStoreValue, storeGet } from '../../store';
|
||||
|
||||
// api
|
||||
import CompanyService from '../../service/company-service';
|
||||
@@ -34,9 +34,9 @@ import { useNavigate } from 'react-router-dom';
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const ProfileCompany = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const infoMsgs = useRef(null);
|
||||
const [formInitialData, setFormInitialData] = useState({});
|
||||
const [delegaData, setDelegaData] = useState({});
|
||||
@@ -77,7 +77,7 @@ const ProfileCompany = () => {
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
infoMsgs.current.clear();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
CompanyService.updateCompany(formData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
@@ -85,7 +85,7 @@ const ProfileCompany = () => {
|
||||
const updateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const company = klona(data.data);
|
||||
const companies = storeGet.main.companies();
|
||||
const companies = storeGet('companies');
|
||||
const existingCompany = head(companies.filter(o => o.id === company.id));
|
||||
let newCompanies = [];
|
||||
|
||||
@@ -93,10 +93,10 @@ const ProfileCompany = () => {
|
||||
newCompanies = companies.map(o => o.id === company.id ? company : o)
|
||||
} else {
|
||||
newCompanies = [...companies, company];
|
||||
storeSet.main.chosenCompanyId(company.id);
|
||||
storeSet('chosenCompanyId', company.id);
|
||||
}
|
||||
|
||||
storeSet.main.companies(newCompanies);
|
||||
storeSet('companies', newCompanies);
|
||||
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -106,12 +106,12 @@ const ProfileCompany = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const updateError = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const checkVatNumber = (e) => {
|
||||
@@ -119,7 +119,7 @@ const ProfileCompany = () => {
|
||||
const isValid = isPIVA(e.target.value);
|
||||
|
||||
if (isValid) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
CompanyService.checkVat(checkVatCallback, errCheckVatCallback, [['vatNumber', e.target.value]])
|
||||
} else {
|
||||
setEmptyValues();
|
||||
@@ -150,13 +150,13 @@ const ProfileCompany = () => {
|
||||
} else {
|
||||
setEmptyValues();
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCheckVatCallback = (data) => {
|
||||
setEmptyValues();
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const setDelegaFieldValue = (value, name) => {
|
||||
@@ -172,16 +172,16 @@ const ProfileCompany = () => {
|
||||
if (data.data) {
|
||||
setDelega([data.data]);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errDellegaCallback = () => {
|
||||
setDelega([]);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const downloadDelega = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const data = {
|
||||
codiceFiscale: delegaCodiceFiscale,
|
||||
firstName: delegaFirstName,
|
||||
@@ -199,11 +199,11 @@ const ProfileCompany = () => {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errDellegaDownloadCallback = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const confirmDelete = (event) => {
|
||||
@@ -231,7 +231,7 @@ const ProfileCompany = () => {
|
||||
}*/
|
||||
|
||||
/*const doRemoveCompany = () => {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
let chosenCompany = {};
|
||||
|
||||
if (chosenCompanyId) {
|
||||
@@ -276,32 +276,32 @@ const ProfileCompany = () => {
|
||||
}*/
|
||||
|
||||
const doRemoveCompanyAPI = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
CompanyService.deleteCompany(formInitialData.id, deleteCompanyCallback, errDeleteCompanyCallback)
|
||||
}
|
||||
|
||||
const deleteCompanyCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
const newCompanies = companies.filter(o => o.id !== chosenCompanyId);
|
||||
storeSet.main.companies(newCompanies);
|
||||
storeSet('companies', newCompanies);
|
||||
const newUserData = wrap(userData).set('companies', newCompanies).value();
|
||||
storeSet.main.userData(newUserData);
|
||||
storeSet('userData', newUserData);
|
||||
|
||||
if (!isEmpty(newCompanies)) {
|
||||
const newChosenCompanyId = newCompanies[0].id;
|
||||
storeSet.main.chosenCompanyId(newChosenCompanyId);
|
||||
storeSet('chosenCompanyId', newChosenCompanyId);
|
||||
} else {
|
||||
storeSet.main.chosenCompanyId(0);
|
||||
storeSet('chosenCompanyId', 0);
|
||||
navigate(`/`);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errDeleteCompanyCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -345,7 +345,7 @@ const ProfileCompany = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData.id) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
CompanyService.getCompanyDelega(getDellegaCallback, errDellegaCallback, [
|
||||
['companyId', formInitialData.id]
|
||||
]);
|
||||
|
||||
@@ -12,7 +12,7 @@ import AuthenticationService from '../../service/authentication-service';
|
||||
import { isEmail } from '../../helpers/validators';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import FormField from '../../components/FormField';
|
||||
@@ -26,7 +26,7 @@ import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const Registration = () => {
|
||||
const token = useStore().main.token();
|
||||
const token = useStoreValue('token');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [originalDateOfBirth, setOriginalDateOfBirth] = useState('')
|
||||
const [visibleTerms, setVisibleTerms] = useState(false);
|
||||
@@ -61,7 +61,7 @@ const Registration = () => {
|
||||
|
||||
const regCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.setAuthData({
|
||||
storeSet('setAuthData', {
|
||||
token: data.data.token,
|
||||
userData: data.data.user
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import FormField from '../../components/FormField';
|
||||
@@ -21,7 +21,7 @@ const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const ResetPassword = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = useStore().main.token();
|
||||
const token = useStoreValue('token');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [resetPassToken, setResetPassToken] = useState('');
|
||||
const [resetPassEmail, setResetPassEmail] = useState('');
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import FormField from '../../components/FormField';
|
||||
@@ -21,7 +21,7 @@ const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const ResetPasswordAdmin = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = useStore().main.token();
|
||||
const token = useStoreValue('token');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [resetPassToken, setResetPassToken] = useState('');
|
||||
const [resetPassEmail, setResetPassEmail] = useState('');
|
||||
|
||||
@@ -5,7 +5,7 @@ import { isEmpty } from 'ramda';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import AmendmentsService from '../../service/amendments-service';
|
||||
@@ -26,7 +26,7 @@ import ApplicationEvaluationService from '../../service/application-evaluation-s
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
|
||||
const SoccorsoAddInstructorManager = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -43,7 +43,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
const parsed = parseInt(id)
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallbackEvaluation, errGetCallback, [
|
||||
['applicationId', entityId]
|
||||
]);
|
||||
@@ -61,7 +61,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
setData(data.data);
|
||||
setFormData(getFormattedFormData(data.data));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
@@ -73,7 +73,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedFormData = (data) => {
|
||||
@@ -119,7 +119,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
}
|
||||
|
||||
const doCreate = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
AmendmentsService.createSoccorso(formData, createCallback, errCreateCallback, [
|
||||
['applicationEvaluationId', evaluationId]
|
||||
@@ -139,7 +139,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
navigate(`/mie-domande/${id}/soccorso/${data.data.id}`);
|
||||
}, 1000)
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCreateCallback = (data) => {
|
||||
@@ -151,7 +151,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const initCreationProcess = () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { isEmpty } from 'ramda';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import AmendmentsService from '../../service/amendments-service';
|
||||
@@ -26,7 +26,7 @@ import ApplicationEvaluationService from '../../service/application-evaluation-s
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
|
||||
const SoccorsoAddPreInstructor = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -43,7 +43,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
const parsed = parseInt(id)
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallbackEvaluation, errGetCallback, [
|
||||
['applicationId', entityId]
|
||||
]);
|
||||
@@ -61,7 +61,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
setData(data.data);
|
||||
setFormData(getFormattedFormData(data.data));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
@@ -73,7 +73,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedFormData = (data) => {
|
||||
@@ -119,7 +119,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
}
|
||||
|
||||
const doCreate = () => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
AmendmentsService.createSoccorso(formData, createCallback, errCreateCallback, [
|
||||
['applicationEvaluationId', evaluationId]
|
||||
@@ -139,7 +139,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
navigate(`/domande/${id}/soccorso/${data.data.id}`);
|
||||
}, 1000)
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCreateCallback = (data) => {
|
||||
@@ -151,7 +151,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const initCreationProcess = () => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import AmendmentsService from '../../service/amendments-service';
|
||||
@@ -31,7 +31,7 @@ import { Editor } from 'primereact/editor';
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const SoccorsoEditBeneficiario = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -82,7 +82,7 @@ const SoccorsoEditBeneficiario = () => {
|
||||
amendmentDocuments: amendmentObj.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
} else {
|
||||
ApplicationService.getApplication(id, getApplCallback, errGetCallback)
|
||||
}
|
||||
@@ -98,14 +98,14 @@ const SoccorsoEditBeneficiario = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getApplCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setDataAppl(getFormattedData(data.data));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
@@ -146,7 +146,7 @@ const SoccorsoEditBeneficiario = () => {
|
||||
}
|
||||
const amendmentId = data.id;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
|
||||
AmendmentsService.updateSoccorso(
|
||||
amendmentId,
|
||||
@@ -189,7 +189,7 @@ const SoccorsoEditBeneficiario = () => {
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateAmendmentCallback = (data) => {
|
||||
@@ -201,7 +201,7 @@ const SoccorsoEditBeneficiario = () => {
|
||||
});
|
||||
}
|
||||
//set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const updateNewAmendmentData = (value, path) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { klona } from 'klona';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import AmendmentsService from '../../service/amendments-service';
|
||||
@@ -31,7 +31,7 @@ import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/Socco
|
||||
|
||||
|
||||
const SoccorsoEditInstructorManager = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id, amendmentId } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -76,7 +76,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
@@ -88,7 +88,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
@@ -152,7 +152,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
amendmentNotes: data.amendmentNotes
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AmendmentsService.updateSoccorso(
|
||||
amendmentId,
|
||||
submitData,
|
||||
@@ -169,7 +169,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
const submitData = {
|
||||
internalNote
|
||||
}
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
|
||||
} else {
|
||||
if (toast.current) {
|
||||
@@ -192,7 +192,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateAmendmentCallback = (data) => {
|
||||
@@ -204,7 +204,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const openCloseAmendmentDialog = () => {
|
||||
@@ -247,7 +247,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
setIsVisibleCloseAmendDialog(false);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCloseAmendmentCallback = (data) => {
|
||||
@@ -259,7 +259,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const headerExtendRespDialog = () => {
|
||||
|
||||
@@ -130,14 +130,14 @@ const SoccorsoComunications = ({ amendmentId, soccorsoStatus }) => {
|
||||
}
|
||||
|
||||
const displayCommIcon = (comm) => {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
return userData.id === comm.senderUserId
|
||||
? <i className="pi pi-upload"></i>
|
||||
: <i className="pi pi-download"></i>;
|
||||
}
|
||||
|
||||
const getCommRowClass = (comm) => {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
return userData.id === comm.senderUserId ? 'outgoing' : 'incoming';
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { klona } from 'klona';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, useStoreValue } from '../../store';
|
||||
|
||||
// api
|
||||
import AmendmentsService from '../../service/amendments-service';
|
||||
@@ -31,7 +31,7 @@ import SoccorsoComunications from './components/SoccorsoComunications';
|
||||
|
||||
|
||||
const SoccorsoEditPreInstructor = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const { id, amendmentId } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [data, setData] = useState({});
|
||||
@@ -76,7 +76,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
@@ -88,7 +88,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
@@ -152,7 +152,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
amendmentNotes: data.amendmentNotes
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AmendmentsService.updateSoccorso(
|
||||
amendmentId,
|
||||
submitData,
|
||||
@@ -169,7 +169,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
const submitData = {
|
||||
internalNote
|
||||
}
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
|
||||
} else {
|
||||
if (toast.current) {
|
||||
@@ -192,7 +192,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateAmendmentCallback = (data) => {
|
||||
@@ -204,7 +204,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const openCloseAmendmentDialog = () => {
|
||||
@@ -247,7 +247,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
setIsVisibleCloseAmendDialog(false);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCloseAmendmentCallback = (data) => {
|
||||
@@ -259,7 +259,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const headerExtendRespDialog = () => {
|
||||
|
||||
@@ -6,11 +6,11 @@ import NumberFlow from '@number-flow/react';
|
||||
// components
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
import SoccorsiPreInstructorTableAsync from '../SoccorsoIstruttorioPreInstructor/components/SoccorsiPreInstructorTableAsync';
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
const SoccorsoIstruttorioInstructorManager = () => {
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
const getStats = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
|
||||
@@ -33,7 +33,7 @@ const InstructorManagerSoccorsiTable = () => {
|
||||
const [statuses, setStatuses] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
const userData = storeGet.main.userData();
|
||||
const userData = storeGet('userData');
|
||||
setLocalAsyncRequest(true);
|
||||
AmendmentsService.getSoccorsi(getCallback, errGetCallbacks, [
|
||||
['userId', userData.id]
|
||||
|
||||
@@ -2,13 +2,13 @@ import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import SoccorsiInstructorManagerMioTableAsync from './components/SoccorsiInstructorManagerMioTableAsync';
|
||||
|
||||
const SoccorsoIstruttorioMioInstructorManager = () => {
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
return(
|
||||
<div className="appPage">
|
||||
|
||||
@@ -4,7 +4,7 @@ import { pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
@@ -12,7 +12,7 @@ import SoccorsiPreInstructorTableAsync from './components/SoccorsiPreInstructorT
|
||||
|
||||
const SoccorsoIstruttorioPreInstructor = () => {
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const userData = useStore().main.userData();
|
||||
const userData = useStoreValue('userData');
|
||||
|
||||
const getStats = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { head, is } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
import { useStoreValue } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -20,8 +20,8 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
|
||||
const BeneficiarioUltimeDomandeTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [items, setItems] = useState(null);
|
||||
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { head, isEmpty, pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
import { useStoreValue } from '../../store';
|
||||
|
||||
// components
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
@@ -15,8 +15,8 @@ import BeneficiarioUltimeDomandeTable from './components/BeneficiarioUltimeDoman
|
||||
const StatsBeneficiary = () => {
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const [chartStats, setChartStats] = useState({});
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const companies = useStore().main.companies();
|
||||
const chosenCompanyId = useStoreValue('chosenCompanyId');
|
||||
const companies = useStoreValue('companies');
|
||||
|
||||
const getStats = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { uniq } from 'ramda';
|
||||
import copy from 'copy-to-clipboard';
|
||||
|
||||
// store
|
||||
import { useStore, storeSet } from '../../../../store';
|
||||
import { useStoreValue, storeSet } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
@@ -27,7 +27,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
const AllUsersTable = ({ updaterString = '' }) => {
|
||||
const users = useStore().main.users();
|
||||
const users = useStoreValue('users');
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [statuses, setStatuses] = useState([]);
|
||||
@@ -42,7 +42,7 @@ const AllUsersTable = ({ updaterString = '' }) => {
|
||||
|
||||
const getCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.users(getFormattedData(data.data));
|
||||
storeSet('users', getFormattedData(data.data));
|
||||
setStatuses(uniq(data.data.map(o => o.status)));
|
||||
setRoles(uniq(data.data.map(o => o.role.roleName)));
|
||||
initFilters();
|
||||
|
||||
@@ -92,8 +92,8 @@ const Users = () => {
|
||||
|
||||
const createUserCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const users = storeGet.main.users();
|
||||
storeSet.main.users([data.data.user, ...users]);
|
||||
const users = storeGet('users');
|
||||
storeSet('users', [data.data.user, ...users]);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
@@ -155,12 +155,12 @@ const Users = () => {
|
||||
}));
|
||||
setRoles(roles);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetRolesCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const isInvalidField = (data, key) => key === 'codiceFiscale'
|
||||
|
||||
@@ -9,12 +9,12 @@ const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
|
||||
export default class AuthenticationService {
|
||||
|
||||
static wasLoggedIn = () => {
|
||||
const token = storeGet.main.getToken();
|
||||
const token = storeGet('getToken');
|
||||
return token ?? false;
|
||||
};
|
||||
|
||||
static isExpired = () => {
|
||||
const token = storeGet.main.getToken();
|
||||
const token = storeGet('getToken');
|
||||
|
||||
if (!token) {
|
||||
return false;
|
||||
@@ -36,7 +36,7 @@ export default class AuthenticationService {
|
||||
};
|
||||
|
||||
static isLoggedIn = () => {
|
||||
const token = storeGet.main.getToken();
|
||||
const token = storeGet('getToken');
|
||||
|
||||
if (!token) {
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,7 @@ export class NetworkService {
|
||||
if (status === 500) {
|
||||
logMsgWithSentry(endpoint, status, resp);
|
||||
} else if (status === 403) {
|
||||
storeSet.main.token('');
|
||||
storeSet('token', '');
|
||||
const { pathname } = window.location;
|
||||
if (!['/login', '/registration', '/loginadmin', '/reset-password-admin', '/confidi', '/reset-password'].includes(pathname)) {
|
||||
window.location.replace('/login');
|
||||
@@ -40,7 +40,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
@@ -84,7 +84,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
//'Content-Type': 'multipart/form-data',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
body: body
|
||||
})
|
||||
@@ -128,7 +128,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
@@ -214,7 +214,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
@@ -262,7 +262,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
//signal: AbortSignal.timeout(5000)
|
||||
})
|
||||
@@ -309,7 +309,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
})
|
||||
.then(async response => {
|
||||
@@ -346,7 +346,7 @@ export class NetworkService {
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
'Authorization': 'Bearer ' + storeGet('getToken'),
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
|
||||
@@ -1,35 +1,41 @@
|
||||
import { head } from 'ramda';
|
||||
|
||||
export const actionsAlpha = (set, get, api) => ({
|
||||
export const actionsAlpha = ({ set, get }) => ({
|
||||
setAsyncRequest: () => {
|
||||
const num = get.isAsyncRequest();
|
||||
set.isAsyncRequest(num + 1);
|
||||
const num = get('isAsyncRequest');
|
||||
set('isAsyncRequest', num + 1);
|
||||
},
|
||||
unsetAsyncRequest: () => {
|
||||
const num = get.isAsyncRequest();
|
||||
set.isAsyncRequest(num - 1 < 0 ? 0 : num - 1);
|
||||
const num = get('isAsyncRequest');
|
||||
set('isAsyncRequest', num - 1 < 0 ? 0 : num - 1);
|
||||
},
|
||||
})
|
||||
|
||||
export const actionsBeta = (set, get, api) => ({
|
||||
export const actionsBeta = ({ set, get }) => ({
|
||||
setAuthData: ({ userData, token }) => {
|
||||
set.userData(userData);
|
||||
set.token(token);
|
||||
set('state', (draft) => {
|
||||
draft.userData = userData;
|
||||
draft.token = token;
|
||||
return draft;
|
||||
});
|
||||
},
|
||||
doLogout: () => {
|
||||
set.userData({});
|
||||
set.token('');
|
||||
set('state', (draft) => {
|
||||
draft.userData = {};
|
||||
draft.token = '';
|
||||
return draft;
|
||||
});
|
||||
},
|
||||
removeElement: (id) => {
|
||||
const elements = get.formElements();
|
||||
const elements = get('formElements');
|
||||
const newElements = elements.filter(o => o.id !== id);
|
||||
set.formElements(newElements);
|
||||
set('formElements', newElements);
|
||||
},
|
||||
moveElement: (dragIndex, hoverIndex, item) => {
|
||||
const prevFields = get.formElements();
|
||||
const prevFields = get('formElements');
|
||||
|
||||
if (dragIndex === -1) {
|
||||
const configs = get.elementItems();
|
||||
const configs = get('elementItems');
|
||||
const itemCfg = head(configs.filter(o => o.id === item.dbId));
|
||||
const newItem = {
|
||||
...itemCfg,
|
||||
@@ -37,11 +43,11 @@ export const actionsBeta = (set, get, api) => ({
|
||||
dbId: item.dbId
|
||||
}
|
||||
const newElements = prevFields.toSpliced(hoverIndex, 0, newItem);
|
||||
set.formElements(newElements);
|
||||
set('formElements', newElements);
|
||||
} else {
|
||||
let newFields = prevFields.toSpliced(dragIndex, 1);
|
||||
const newElements = newFields.toSpliced(hoverIndex, 0, prevFields[dragIndex]);
|
||||
set.formElements(newElements);
|
||||
set('formElements', newElements);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
import { mapValuesKey } from 'zustand-x';
|
||||
|
||||
// stores
|
||||
import { mainStore } from './main';
|
||||
import {
|
||||
useStoreValue as useStoreValueOriginal,
|
||||
useStoreState as useStoreStateOriginal,
|
||||
useTracked
|
||||
} from 'zustand-x';
|
||||
|
||||
// Global store - initial data
|
||||
const dashboardStore = {
|
||||
main: mainStore
|
||||
};
|
||||
// migration: useStore -> useStoreValue
|
||||
// old: useStore().main.getRole() -- new: useStoreValue('getRole')
|
||||
export const useStoreValue = (key, ...args) => useStoreValueOriginal(mainStore, key, ...args);
|
||||
|
||||
// Global hook selectors
|
||||
export const useStore = () => mapValuesKey('use', dashboardStore);
|
||||
// Global tracked hook selectors
|
||||
export const useTrackedStore = () => mapValuesKey('useTracked', dashboardStore);
|
||||
// Global getter selectors
|
||||
export const storeGet = mapValuesKey('get', dashboardStore);
|
||||
// Global actions
|
||||
export const storeSet = mapValuesKey('set', dashboardStore);
|
||||
export const useStoreState = (key, ...args) => useStoreStateOriginal(mainStore, key, ...args);
|
||||
|
||||
export default dashboardStore;
|
||||
// migration: useTrackedStore -> useTrackedValue
|
||||
export const useTrackedValue = (key) => useTracked(mainStore, key);
|
||||
|
||||
// old: storeGet.main.getRole() -- new: storeGet('getRole')
|
||||
export const storeGet = (key, ...args) => mainStore.get(key, ...args);
|
||||
|
||||
// old: storeSet.main.removeElement(id) -- new: storeSet('removeElement', id)
|
||||
export const storeSet = (key, ...args) => mainStore.set(key, ...args);
|
||||
|
||||
export default mainStore;
|
||||
@@ -5,7 +5,11 @@ import initialStore from './initial';
|
||||
import selectors from './selectors';
|
||||
import { actionsAlpha, actionsBeta } from './actions';
|
||||
|
||||
export const mainStore = createStore('main')(initialStore, zustandXOpts)
|
||||
export const mainStore = createStore(
|
||||
initialStore,
|
||||
{
|
||||
...zustandXOpts
|
||||
})
|
||||
.extendSelectors(selectors)
|
||||
.extendActions(actionsAlpha)
|
||||
.extendActions(actionsBeta);
|
||||
@@ -1,13 +1,13 @@
|
||||
const selectors = (state, get, api) => ({
|
||||
const selectors = ({ get }) => ({
|
||||
getToken: () => {
|
||||
return get.token();
|
||||
return get('token');
|
||||
},
|
||||
getRole: () => {
|
||||
const userData = get.userData();
|
||||
const userData = get('userData');
|
||||
return userData.role ? userData.role.roleType : '';
|
||||
},
|
||||
getPermissions: () => {
|
||||
const userData = get.userData();
|
||||
const userData = get('userData');
|
||||
return userData.role ? userData.role.permissions : [];
|
||||
},
|
||||
})
|
||||
|
||||
@@ -5,7 +5,6 @@ const zustandXOpts = {
|
||||
persist: {
|
||||
enabled: true,
|
||||
partialize: (state) => ({
|
||||
//userData: state.userData,
|
||||
token: state.token,
|
||||
chosenCompanyId: state.chosenCompanyId,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user