- added cache faq items;

- added terms pdf;
- added redirect to 'add company' for new users;
This commit is contained in:
Vitalii Kiiko
2024-10-11 12:51:15 +02:00
parent 8fb1551880
commit bd64a34347
26 changed files with 168 additions and 36 deletions

View File

@@ -4,7 +4,7 @@ import Routes from './routes';
import { createI18n, setLocaleData } from '@wordpress/i18n';
import { I18nProvider } from '@wordpress/react-i18n';
import './assets/scss/theme.scss';
import { isEmpty } from 'ramda'
import { isEmpty, head } from 'ramda'
// store
import { useStore, storeSet, storeGet } from './store';
@@ -17,6 +17,7 @@ const i18n = createI18n({}, 'gepafin');
function App() {
const role = useStore().main.getRole();
const chosenCompanyId = useStore().main.chosenCompanyId();
const isRedirectedOnceNoCompany = useStore().main.isRedirectedOnceNoCompany();
const callback = (data) => {
if (data.status === 'SUCCESS') {
@@ -36,9 +37,23 @@ function App() {
const userData = storeGet.main.userData();
if (userData.companies && !isEmpty(userData.companies)) {
storeSet.main.companies(userData.companies);
const company = head(userData.companies.filter(o => o.id === chosenCompanyId));
if (!company) {
storeSet.main.chosenCompanyId(userData.companies[0].id);
}
} else {
storeSet.main.chosenCompanyId(0);
const { origin, href } = window.location;
const url = `${origin}/agguingi-azienda`;
if (!isRedirectedOnceNoCompany && url !== href) {
storeSet.main.isRedirectedOnceNoCompany(true);
window.location.replace('/agguingi-azienda')
}
}
}
}, [role])
}, [role]);
useEffect(() => {
storeSet.main.setAsyncRequest();