From 5c8e35ba7d6fb162f66b7e5cb74a775ee64c53d7 Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Mon, 1 May 2023 15:31:24 +0100 Subject: [PATCH] Front: Navigation: Add key to routes + logout button on profile error --- front/Navigation.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/front/Navigation.tsx b/front/Navigation.tsx index 0a0f167..5426a26 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -18,6 +18,9 @@ import { LoadingView } from './components/Loading'; import ProfileView from './views/ProfileView'; import useColorScheme from './hooks/colorScheme'; import { Button, Center, VStack } from 'native-base'; +import { useDispatch } from 'react-redux'; +import { unsetAccessToken } from './state/UserSlice'; +import TextButton from './components/TextButton'; const protectedRoutes = () => ({ @@ -59,8 +62,9 @@ const RouteToScreen = (component: Route['component']) => (pro const routesToScreens = (routes: Partial>) => Object.entries(routes) - .map(([name, route]) => ( + .map(([name, route], routeIndex) => ( >) = )) const ProfileErrorView = (props: { onTryAgain: () => any }) => { + const dispatch = useDispatch(); return
- + dispatch(unsetAccessToken())} + colorScheme="error" variant='outline' + translate={{ translationKey: 'signOutBtn' }} + />
}