Browse Source

fix: navigate to app on register

Oleksandr Honcharov 1 year ago
parent
commit
27d93e42ff
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/screens/RegisterScreen/EditAccount/index.tsx

+ 10 - 0
src/screens/RegisterScreen/EditAccount/index.tsx

@@ -2,6 +2,7 @@ import React from 'react';
 import { View, ScrollView } from 'react-native';
 import { Formik } from 'formik';
 import * as yup from 'yup';
+import { CommonActions, useNavigation } from '@react-navigation/native';
 
 import { AvatarPicker, BigText, Button, Header, Input, PageWrapper } from '../../../components';
 import { InputDatePicker } from '../../../components/Calendar/InputDatePicker';
@@ -10,6 +11,7 @@ import { useRegisterMutation } from '../../../modules/auth/api/queries/use-post-
 import { storageSet } from '../../../storage';
 
 import store from '../../../storage/zustand';
+import { NAVIGATION_PAGES } from '../../../types';
 
 const SignUpSchema = yup.object({
   first_name: yup.string().required(),
@@ -21,6 +23,8 @@ const SignUpSchema = yup.object({
 //TODO: formik avatar | date and flatlist error shown
 
 const EditAccount = () => {
+  const { dispatch } = useNavigation();
+
   const [user] = store((state) => [state.registration.user]);
 
   const { data, error, mutate: userRegister } = useRegisterMutation();
@@ -28,6 +32,12 @@ const EditAccount = () => {
   if (data) {
     if (data.token) {
       storageSet('token', data.token);
+      dispatch(
+        CommonActions.reset({
+          index: 1,
+          routes: [{ name: NAVIGATION_PAGES.IN_APP }]
+        })
+      );
     }
   }