From 28b8352ff1f8bccf8ff571c59d4c92f227a3e988 Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Mon, 25 Sep 2023 14:28:37 +0000
Subject: [PATCH] chore: fix double alert on login failed

---
 src/App.tsx                              |  5 +---
 src/components/Layout/Layout.tsx         | 14 ----------
 src/components/Layout/layout.module.scss | 22 ---------------
 src/components/Loader/loader.scss        |  1 +
 src/components/Routes/Router.tsx         | 34 +++++++++++++-----------
 src/styles/index.scss                    | 19 +++++++++++++
 6 files changed, 40 insertions(+), 55 deletions(-)
 delete mode 100644 src/components/Layout/Layout.tsx
 delete mode 100644 src/components/Layout/layout.module.scss

diff --git a/src/App.tsx b/src/App.tsx
index d91139a0..a4e01a83 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -3,7 +3,6 @@ import { QueryClient, QueryClientProvider } from 'react-query'
 import { BrowserRouter } from 'react-router-dom'
 import { ToastContainer } from 'react-toastify'
 import 'react-toastify/dist/ReactToastify.css'
-import Layout from './components/Layout/Layout'
 import Router from './components/Routes/Router'
 import { theme } from './components/UI/theme'
 
@@ -14,9 +13,7 @@ function App() {
     <BrowserRouter>
       <ThemeProvider theme={theme}>
         <QueryClientProvider client={queryClient}>
-          <Layout>
-            <Router />
-          </Layout>
+          <Router />
           <ToastContainer theme="colored" />
         </QueryClientProvider>
       </ThemeProvider>
diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx
deleted file mode 100644
index 672c2eaf..00000000
--- a/src/components/Layout/Layout.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from 'react'
-import SideBar from '../SideBar/SideBar'
-import styles from './layout.module.scss'
-
-const Layout: React.FC = ({ children }) => {
-  return (
-    <div className={styles.root}>
-      <SideBar />
-      <main className={styles.wrapper}>{children}</main>
-    </div>
-  )
-}
-
-export default Layout
diff --git a/src/components/Layout/layout.module.scss b/src/components/Layout/layout.module.scss
deleted file mode 100644
index 8735c26f..00000000
--- a/src/components/Layout/layout.module.scss
+++ /dev/null
@@ -1,22 +0,0 @@
-@import '../../styles/config/colors';
-@import '../../styles/config/breakpoints';
-
-.root {
-  display: flex;
-  background: $dark-bg;
-  height: 100vh;
-}
-
-.wrapper {
-  flex: 1;
-  box-shadow:
-    0px 5px 5px rgb(0 0 0 / 20%),
-    0px 3px 14px rgb(0 0 0 / 12%),
-    0px 8px 10px rgb(0 0 0 / 14%);
-  overflow-y: scroll;
-
-  @media screen and (max-width: $width-tablet) {
-    margin-left: 0;
-    padding-bottom: 5rem;
-  }
-}
diff --git a/src/components/Loader/loader.scss b/src/components/Loader/loader.scss
index 0f9e2144..982003b1 100644
--- a/src/components/Loader/loader.scss
+++ b/src/components/Loader/loader.scss
@@ -3,6 +3,7 @@
 .loader-container {
   display: flex;
   height: 100%;
+  flex: 1;
   overflow: hidden;
 }
 .loader {
diff --git a/src/components/Routes/Router.tsx b/src/components/Routes/Router.tsx
index 7a723f12..64c8f6cb 100644
--- a/src/components/Routes/Router.tsx
+++ b/src/components/Routes/Router.tsx
@@ -6,6 +6,7 @@ import Login from '../Login/Login'
 import Newsletter from '../Newsletter/Newsletter'
 import Popups from '../Popups/Popups'
 import Prices from '../Prices/Prices'
+import SideBar from '../SideBar/SideBar'
 
 export const links: Record<
   string,
@@ -43,21 +44,24 @@ const Router = () => {
 
   if (user) {
     return (
-      <Routes>
-        <>
-          <Route path={links.newsletter.path} element={<Newsletter />} />
-          <Route path={links.prices.path} element={<Prices />} />
-          <Route path="/popups" element={<Popups />} />
-          {user.isAdmin && (
-            <Route path={links.consents.path} element={<Consents />} />
-          )}
-          <Route path="/login" element={<Login />} />
-          <Route
-            path="*"
-            element={<Navigate replace to={links.newsletter.path} />}
-          />
-        </>
-      </Routes>
+      <>
+        <SideBar />
+        <main className="wrapper">
+          <Routes>
+            <Route path={links.newsletter.path} element={<Newsletter />} />
+            <Route path={links.prices.path} element={<Prices />} />
+            <Route path="/popups" element={<Popups />} />
+            {user.isAdmin && (
+              <Route path={links.consents.path} element={<Consents />} />
+            )}
+            <Route path="/login" element={<Login />} />
+            <Route
+              path="*"
+              element={<Navigate replace to={links.newsletter.path} />}
+            />
+          </Routes>
+        </main>
+      </>
     )
   }
 
diff --git a/src/styles/index.scss b/src/styles/index.scss
index 9ddc1f56..e634f95d 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -9,6 +9,25 @@
   color: $text-grey;
 }
 
+#root {
+  display: flex;
+  background: $dark-bg;
+  height: 100vh;
+}
+
+.wrapper {
+  flex: 1;
+  box-shadow:
+    0px 5px 5px rgb(0 0 0 / 20%),
+    0px 3px 14px rgb(0 0 0 / 12%),
+    0px 8px 10px rgb(0 0 0 / 14%);
+  overflow-y: scroll;
+
+  @media screen and (max-width: $width-tablet) {
+    padding-bottom: 5rem;
+  }
+}
+
 h1 {
   color: #fafafa;
   @include text-large();
-- 
GitLab