From 61df566dcf142dd0022ffe0f36619a7b7488c167 Mon Sep 17 00:00:00 2001 From: Laurian-Dufrechou Date: Thu, 18 May 2023 17:31:54 +0200 Subject: [PATCH] fix(disconnect from map issue): require to be connected to reach /map --- src/components/Navbar.tsx | 82 ++++++++++--------- .../layout/profile/CustomFalseEditable.tsx | 28 +++++-- src/pages/map.tsx | 2 +- src/pages/profile.tsx | 2 +- 4 files changed, 65 insertions(+), 49 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 87af49a..3e9a778 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -6,70 +6,76 @@ import { Button, Image, Link, -} from '@chakra-ui/react'; -import {useRouter} from 'next/router'; -import {signOut, useSession} from 'next-auth/react'; +} from "@chakra-ui/react"; +import { useRouter } from "next/router"; +import { signOut, useSession } from "next-auth/react"; type Props = { - variant: 'static' | 'fixed'; + variant: "static" | "fixed"; }; -export default function Navbar({variant = 'fixed'}: Props) { +export default function Navbar({ variant = "fixed" }: Props) { const router = useRouter(); - const {data: session, status} = useSession(); + const { data: session, status } = useSession(); const MiddleSection = () => { const authenticatedLinks = ( - <> - Tableau de bord - Profile - Carte - + <> + Tableau de bord + Profile + Carte + ); return ( - - {status === 'authenticated' && authenticatedLinks} - + + {status === "authenticated" && authenticatedLinks} + ); }; const RightSection = () => { - const authenticatedButtons = ( - + ); const unauthenticatedButtons = ( - <> - - - + <> + + + ); return ( - - - {status === 'authenticated' - ? authenticatedButtons - : unauthenticatedButtons - } - - + + + {status === "authenticated" + ? authenticatedButtons + : unauthenticatedButtons} + + ); }; return ( - - - - - + + + + + - - - - + + + + ); } diff --git a/src/components/layout/profile/CustomFalseEditable.tsx b/src/components/layout/profile/CustomFalseEditable.tsx index 6a15e10..e82edda 100644 --- a/src/components/layout/profile/CustomFalseEditable.tsx +++ b/src/components/layout/profile/CustomFalseEditable.tsx @@ -5,7 +5,8 @@ import { FormHelperText, FormLabel, UseEditableProps, -} from '@chakra-ui/react'; + Link, +} from "@chakra-ui/react"; type CustomEditableProps = { id: string; @@ -14,16 +15,25 @@ type CustomEditableProps = { } & UseEditableProps; export default function CustomEditable(props: CustomEditableProps) { - const {label, id, helperText = '', ...UseEditableProps} = props; + const { label, id, helperText = "", ...UseEditableProps } = props; return ( - - {label} - - - + + + {label} + + + + + {helperText} - + + ); } diff --git a/src/pages/map.tsx b/src/pages/map.tsx index 4090d99..5a5e4e0 100644 --- a/src/pages/map.tsx +++ b/src/pages/map.tsx @@ -23,7 +23,7 @@ export default function Map() { ]); const [geolocationError, setGeolocationError] = useState(false); - const { data: session, status } = useSession(); + const { data: session, status } = useSession({ required: true }); const [listBars, setListBars] = useState({} as unknown as any); const { diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index 8f7450d..4f4be58 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -244,7 +244,7 @@ export default function UserProfile() { } label={"Adresse :"} helperText={ - "Ce champ est modifié automatiquement depuis la carte" + "Ce champ est automatiquement modifié depuis la carte" } />