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