From c2bfaff4b41311cc3c1948a6a256d6746e6dab36 Mon Sep 17 00:00:00 2001 From: Ahmad Izzudin Alifyandra Date: Sun, 10 Oct 2021 22:48:57 +0700 Subject: [PATCH] fix: register transition bug --- src/redux/user/actions.tsx | 33 ++++++++++++----------------- src/screens/auth/RegisterScreen.tsx | 6 ++++-- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/redux/user/actions.tsx b/src/redux/user/actions.tsx index a9e458b..34d015d 100644 --- a/src/redux/user/actions.tsx +++ b/src/redux/user/actions.tsx @@ -73,24 +73,19 @@ export const signupUser = ( businessType: string ) => { return async (dispatch: Dispatch) => { - try { - const userAuth = await authService.signUpAuth(email, password); - const uid = userAuth.user.uid; - await userService.createUser(uid, { - firstName, - lastName, - email, - phone, - businessType, - pic: "", - }); - return dispatch({ - type: "SIGNUP", - payload: { email, firstName, lastName, id: uid, phone, businessType }, - }); - } catch (e) { - console.log(e); - return { error: e }; - } + const userAuth = await authService.signUpAuth(email, password); + const uid = userAuth.user.uid; + await userService.createUser(uid, { + firstName, + lastName, + email, + phone, + businessType, + pic: "", + }); + return dispatch({ + type: "SIGNUP", + payload: { email, firstName, lastName, id: uid, phone, businessType }, + }); }; }; diff --git a/src/screens/auth/RegisterScreen.tsx b/src/screens/auth/RegisterScreen.tsx index 48ead26..fd2b1b4 100644 --- a/src/screens/auth/RegisterScreen.tsx +++ b/src/screens/auth/RegisterScreen.tsx @@ -41,10 +41,12 @@ const RegisterScreen = ({ navigation }: RootTabScreenProps<"TabOne">) => { validateEmpty(password) && validateEmpty(picked) ) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access dispatch( signupUser(firstName, lastName, email, password, phoneNo, picked) - ).then(() => Alert.alert("Error", "Something went wrong")); + ) + .then(() => null) + .catch(() => Alert.alert("Error", "Something went wrong")); // .then((e: ActionErrorRes) => e.error && Alert.alert("Error", e.error)); } else { Alert.alert("Form Tidak Lengkap", "Silahkan isi form dengan benar"); -- GitLab