Created
August 27, 2021 19:14
-
-
Save Dexdot/5d310a3e543f35c7adfcb7f05011f50a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
import { Provider } from 'react-redux'; | |
import { BrowserRouter as Router } from 'react-router-dom'; | |
import { ThemeProvider } from '@material-ui/core/styles'; | |
import CssBaseline from '@material-ui/core/CssBaseline'; | |
import { Routes } from '@/components/Routes'; | |
import { theme } from '@/styles/theme'; | |
import { store } from '@/store/store'; | |
import { authActions } from '@/store/auth'; | |
import '@/styles/index.scss'; | |
import { NastavnikAPI } from './api/instance'; | |
function App() { | |
useEffect(() => { | |
const auth = localStorage.getItem('nastavnik-auth'); | |
if (auth) { | |
const parsedAuth = JSON.parse(auth); | |
NastavnikAPI.updateToken(parsedAuth.sess_token); | |
store.dispatch(authActions.set(parsedAuth)); | |
} | |
}, []); | |
return ( | |
<Router> | |
<Provider store={store}> | |
<ThemeProvider theme={theme}> | |
<CssBaseline> | |
<Routes /> | |
</CssBaseline> | |
</ThemeProvider> | |
</Provider> | |
</Router> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment