- saving progress;
This commit is contained in:
25
src/App.js
25
src/App.js
@@ -4,11 +4,34 @@ import Routes from './routes';
|
||||
import { createI18n, setLocaleData } from '@wordpress/i18n';
|
||||
import { I18nProvider } from '@wordpress/react-i18n';
|
||||
import './assets/scss/theme.scss';
|
||||
import AuthenticationService from './service/authentication-service';
|
||||
|
||||
// store
|
||||
import { useStore, storeSet } from './store';
|
||||
|
||||
const i18n = createI18n({}, 'gepafin');
|
||||
|
||||
function App() {
|
||||
const role = useStore().main.getRole();
|
||||
|
||||
const callback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
} else {
|
||||
storeSet.main.doLogout();
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errCallback = (data) => {
|
||||
storeSet.main.doLogout();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
AuthenticationService.me(callback, errCallback);
|
||||
|
||||
fetch('/languages/en_US.json')
|
||||
.then((res) => res.json())
|
||||
.then(res => {
|
||||
@@ -19,7 +42,7 @@ function App() {
|
||||
return (
|
||||
<I18nProvider i18n={i18n}>
|
||||
<BrowserRouter>
|
||||
<Routes/>
|
||||
<Routes role={role}/>
|
||||
</BrowserRouter>
|
||||
</I18nProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user