You need to sign in or sign up before continuing.
Commit ba50887e by G

when the credentials are good. make request to retrieve user informations before…

when the credentials are good. make request to retrieve user informations before navigating to the home page for authenticated user.
parent c304c1b9
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: <Axios error>
onError: (error: AxiosError<any>) => {
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment