Skip to content
Snippets Groups Projects
Commit 6f0c6b09 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

remove suspense

parent c740ca34
Branches
No related tags found
1 merge request!116feat(login): stay on page after refresh
Pipeline #72891 canceled
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true, "source.fixAll.eslint": true,
"source.fixAll": true, "source.fixAll": true,
"source.organizeImports": false "source.organizeImports": true
}, },
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"peacock.color": "#2aa63d", "peacock.color": "#2aa63d",
......
...@@ -13,8 +13,8 @@ export const useWhoAmI = () => { ...@@ -13,8 +13,8 @@ export const useWhoAmI = () => {
queryKey: ['WhoAmI'], queryKey: ['WhoAmI'],
queryFn: fetchWhoAmI, queryFn: fetchWhoAmI,
retry: false, retry: false,
onError: () => { onError: error => {
console.log('error whoami') console.error('error whoami', error)
toast.error('Accès refusé, veuillez vous connecter') toast.error('Accès refusé, veuillez vous connecter')
}, },
refetchOnMount: false, refetchOnMount: false,
...@@ -22,6 +22,5 @@ export const useWhoAmI = () => { ...@@ -22,6 +22,5 @@ export const useWhoAmI = () => {
} }
export const fetchLogout = async () => { export const fetchLogout = async () => {
console.log('fetch logout')
return await axios.get('/Logout') return await axios.get('/Logout')
} }
...@@ -5,7 +5,6 @@ import 'react-toastify/dist/ReactToastify.css' ...@@ -5,7 +5,6 @@ import 'react-toastify/dist/ReactToastify.css'
import Layout from './components/Layout/Layout' import Layout from './components/Layout/Layout'
import Router from './components/Routes/Router' import Router from './components/Routes/Router'
// provide the default query function to your app with defaultOptions
const queryClient = new QueryClient() const queryClient = new QueryClient()
function App() { function App() {
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
.root { .root {
display: flex; display: flex;
background: $dark-bg;
height: 100vh;
} }
.wrapper { .wrapper {
...@@ -11,9 +13,7 @@ ...@@ -11,9 +13,7 @@
0px 5px 5px rgb(0 0 0 / 20%), 0px 5px 5px rgb(0 0 0 / 20%),
0px 3px 14px rgb(0 0 0 / 12%), 0px 3px 14px rgb(0 0 0 / 12%),
0px 8px 10px rgb(0 0 0 / 14%); 0px 8px 10px rgb(0 0 0 / 14%);
background: $dark-bg;
overflow-y: scroll; overflow-y: scroll;
height: 100vh;
@media screen and (max-width: $width-tablet) { @media screen and (max-width: $width-tablet) {
margin-left: 0; margin-left: 0;
......
@import '../../styles/config/colors.scss'; @import '../../styles/config/colors.scss';
.loader-container { .loader-container {
width: 100%;
height: 80vh;
display: flex; display: flex;
height: 100%;
overflow: hidden; overflow: hidden;
} }
.loader { .loader {
...@@ -23,7 +22,6 @@ ...@@ -23,7 +22,6 @@
background: -o-linear-gradient(left, $gold 10%, rgba(255, 255, 255, 0) 42%); background: -o-linear-gradient(left, $gold 10%, rgba(255, 255, 255, 0) 42%);
background: -ms-linear-gradient(left, $gold 10%, rgba(255, 255, 255, 0) 42%); background: -ms-linear-gradient(left, $gold 10%, rgba(255, 255, 255, 0) 42%);
background: linear-gradient(to right, $gold 10%, rgba(255, 255, 255, 0) 42%); background: linear-gradient(to right, $gold 10%, rgba(255, 255, 255, 0) 42%);
position: relative;
-webkit-animation: load3 1.4s infinite linear; -webkit-animation: load3 1.4s infinite linear;
animation: load3 1.4s infinite linear; animation: load3 1.4s infinite linear;
-webkit-transform: translateZ(0); -webkit-transform: translateZ(0);
......
import { Suspense } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { useWhoAmI } from '../../API' import { useWhoAmI } from '../../API'
import Consents from '../Consents/Consents' import Consents from '../Consents/Consents'
...@@ -38,37 +37,27 @@ export const routes = Object.keys(links).map(key => ({ ...@@ -38,37 +37,27 @@ export const routes = Object.keys(links).map(key => ({
})) }))
const Router = () => { const Router = () => {
const { data: user, error, isFetching } = useWhoAmI() const { data: user, isLoading } = useWhoAmI()
if (isFetching) return <Loader /> if (isLoading) return <Loader />
if (error) return <div>Une erreur est survenue</div>
if (user) { if (user) {
return ( return (
<Suspense <Routes>
fallback={ <>
<div className="loaderContainer"> <Route path={links.newsletter.path} element={<Newsletter />} />
<Loader /> <Route path={links.prices.path} element={<Prices />} />
</div> <Route path="/popups" element={<Popups />} />
} {user.isAdmin && (
> <Route path={links.consents.path} element={<Consents />} />
<Routes> )}
<> <Route path="/login" element={<Login />} />
<Route path={links.newsletter.path} element={<Newsletter />} /> <Route
<Route path={links.prices.path} element={<Prices />} /> path="*"
<Route path="/popups" element={<Popups />} /> element={<Navigate replace to={links.newsletter.path} />}
{user.isAdmin && ( />
<Route path={links.consents.path} element={<Consents />} /> </>
)} </Routes>
<Route path="/login" element={<Login />} />
<Route
path="*"
element={<Navigate replace to={links.newsletter.path} />}
/>
</>
</Routes>
</Suspense>
) )
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment