From 9585491f21571d5da0d2de0b2c39b25a4e4ce621 Mon Sep 17 00:00:00 2001 From: G Date: Sat, 6 Sep 2025 21:44:23 +0000 Subject: [PATCH] refactor: UserProfileScreen. No more dependencies on Box/Text themes's components. Dispatch a redux action to disconnect the user. --- src/features/auth/slice.ts | 4 +++- src/screens/UserProfileScreen.tsx | 287 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 files changed, 132 insertions(+), 159 deletions(-) diff --git a/src/features/auth/slice.ts b/src/features/auth/slice.ts index aa5484a..a1d92bd 100644 --- a/src/features/auth/slice.ts +++ b/src/features/auth/slice.ts @@ -31,7 +31,9 @@ export const authSlice = createSlice({ state.token = action.payload.tokens; }, logout: (state) => { - state = initialState; + state.isAuthenticated = false; + state.token = {} as Token; + state.user = {} as UserData; }, }, }); diff --git a/src/screens/UserProfileScreen.tsx b/src/screens/UserProfileScreen.tsx index 099b94c..18b01d1 100644 --- a/src/screens/UserProfileScreen.tsx +++ b/src/screens/UserProfileScreen.tsx @@ -1,176 +1,147 @@ -import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext"; -import BarWithBeasyAndNotificationsIcon from "@components/BarWithBeasyAndNotificationsIcon"; -import Button from "@components/Button"; -import Box from "@components/bases/Box"; -import Text from "@components/bases/Text"; -import WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight from "@components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight"; +import { asp as g } from "@asp/asp"; +import { BarnoinPayBackground } from "@components/BarnoinPayBackground"; +import BeasyLogoIcon from "@components/BeasyLogoIcon"; +import * as Button from "@components/ButtonNew"; +import Ionicons from "@expo/vector-icons/Ionicons"; import { LOG } from "@logger"; -import Card from "@re-card"; +import { Text, View } from "react-native"; +import { useDispatch } from "react-redux"; +import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext"; +import { logout } from "@/features/auth/slice"; const log = LOG.extend("UserProfileScreen"); const UserProfileScreen = () => { log.verbose("UserProfileScreen"); - const { logout } = useUserAuthenticationContext(); + const dispatch = useDispatch(); const { userInformations } = useUserAuthenticationContext(); return ( - - <> - - - - - - - + + + + + + + + + + - - - {userInformations.first_name} {userInformations.last_name} - - {userInformations.email} - - - - - Utilisateur + + + {userInformations.first_name} {userInformations.last_name} - {userInformations.username} - - + {userInformations.email} + + + + Utilisateur + {userInformations.username} + + -