From ba50887eb2e9204378945056baaf0cad260c6a93 Mon Sep 17 00:00:00 2001 From: G Date: Mon, 13 May 2024 17:01:00 +0000 Subject: [PATCH] when the credentials are good. make request to retrieve user informations before navigating to the home page for authenticated user. --- src/screens/UserLoginScreen.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/screens/UserLoginScreen.tsx b/src/screens/UserLoginScreen.tsx index 6a032a7..1a2f3aa 100644 --- a/src/screens/UserLoginScreen.tsx +++ b/src/screens/UserLoginScreen.tsx @@ -1,6 +1,7 @@ import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext"; import type { UnloggedUserStackScreenComponentProps } from "@/navigations/Types"; import authenticateUser from "@/utils/requests/authenticateUser"; +import getUserInformations from "@/utils/requests/userInformations"; import Button from "@components/Button"; import ContainerBorderTopCurved from "@components/ContainerBorderTopCurved"; import Input from "@components/Input"; @@ -31,7 +32,9 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen"> setAuthenticationData(data); // navigation.popToTop(); // navigation.replace("bottomTabs"); - navigation.navigate("bottomTabs"); + // navigation.navigate("bottomTabs"); + const userInformations = userInformationsMutation.mutate(data.access); + console.log(userInformations); }, // biome-ignore lint/suspicious/noExplicitAny: onError: (error: AxiosError) => { @@ -47,6 +50,19 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen"> }, }); + const userInformationsMutation = useMutation({ + mutationFn: (userAccessToken: string) => getUserInformations(userAccessToken), + onSuccess: (data) => { + console.log("Data userInformationsMutation", data); + + // TODO : Navigate to bottomTabs + navigation.navigate("bottomTabs"); + }, + onError: (error) => { + console.log("Error userInformationsMutation", error); + }, + }); + const submit = useCallback(() => { authenticationMutation.mutate({ username: email, -- libgit2 0.27.1