From fee33b22050717351d8b2abd5c4f4c86647871d9 Mon Sep 17 00:00:00 2001 From: Bagus Prabowo Date: Wed, 29 Sep 2021 21:48:01 +0700 Subject: [PATCH 1/3] Refactor: Forgot Password Firebase Function --- src/screens/auth/InputForgotPassword.tsx | 3 ++- src/service/firebase/auth.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/screens/auth/InputForgotPassword.tsx b/src/screens/auth/InputForgotPassword.tsx index 2776b37..a307c9a 100644 --- a/src/screens/auth/InputForgotPassword.tsx +++ b/src/screens/auth/InputForgotPassword.tsx @@ -10,6 +10,7 @@ import { MaterialIcons } from "@expo/vector-icons"; import MainButton from "../../components/button/MainButton"; import firebase from "firebase"; import { validateEmail } from "../../helpers/Validators"; +import { forgotPassword } from "../../service/firebase/auth"; export default function InputForgotPassword({ navigation, @@ -47,7 +48,7 @@ export default function InputForgotPassword({ colors={"Primary"} onPress={() => { if (validateEmail(email)) { - firebase.auth().sendPasswordResetEmail(email); + forgotPassword(email); nav.navigate("Auth", { screen: "ForgotPasswordDone" }); } }} diff --git a/src/service/firebase/auth.ts b/src/service/firebase/auth.ts index 0dca517..417b8ab 100644 --- a/src/service/firebase/auth.ts +++ b/src/service/firebase/auth.ts @@ -35,3 +35,7 @@ export const changePassword = async (password: string) => { export const signUpAuth = async (email: string, password: string) => { return await firebase.auth().createUserWithEmailAndPassword(email, password); }; + +export const forgotPassword = async (email: string) => { + return await firebase.auth().sendPasswordResetEmail(email); +}; -- GitLab From 7ea63dca2d2fff32719ff28174ac3d0e0534ed5b Mon Sep 17 00:00:00 2001 From: Bagus Prabowo Date: Wed, 29 Sep 2021 22:03:25 +0700 Subject: [PATCH 2/3] Refactor: Error handling for forgot password --- src/screens/auth/InputForgotPassword.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/screens/auth/InputForgotPassword.tsx b/src/screens/auth/InputForgotPassword.tsx index a307c9a..53b55b1 100644 --- a/src/screens/auth/InputForgotPassword.tsx +++ b/src/screens/auth/InputForgotPassword.tsx @@ -1,7 +1,7 @@ import { useNavigation } from "@react-navigation/core"; import React from "react"; import { useState } from "react"; -import { StyleSheet, View, Text } from "react-native"; +import { StyleSheet, View, Text, Alert } from "react-native"; import Colors from "../../constants/Colors"; import { RootTabScreenProps } from "../../types/navigation"; import PlainForm from "../../components/Forms/PlainForm"; @@ -47,10 +47,16 @@ export default function InputForgotPassword({ text={"Reset Password"} colors={"Primary"} onPress={() => { - if (validateEmail(email)) { - forgotPassword(email); - nav.navigate("Auth", { screen: "ForgotPasswordDone" }); - } + forgotPassword(email) + .then(() => + nav.navigate("Auth", { screen: "ForgotPasswordDone" }) + ) + .catch((e) => + Alert.alert( + "Email tidak ditemukan", + "Silahkan masukkan email yang terdaftar" + ) + ); }} /> -- GitLab From 6eba9b4453ca987a91fb09cca9767f17c34cc00e Mon Sep 17 00:00:00 2001 From: Bagus Prabowo Date: Wed, 29 Sep 2021 22:58:47 +0700 Subject: [PATCH 3/3] Refactor: Dropdown Form Page Debug --- src/components/Forms/DropdownForm.tsx | 1 + src/screens/auth/RegisterScreen.tsx | 169 +++++++++++++------------- 2 files changed, 83 insertions(+), 87 deletions(-) diff --git a/src/components/Forms/DropdownForm.tsx b/src/components/Forms/DropdownForm.tsx index ab3fbf8..3554f48 100644 --- a/src/components/Forms/DropdownForm.tsx +++ b/src/components/Forms/DropdownForm.tsx @@ -36,6 +36,7 @@ const DropdownForm = ({ } return ( ) => { }; return ( - - - - Selamat Datang! - - - - nav.navigate("Auth", { screen: "RegisterGoogle" })} - /> - - - - nav.navigate("Auth", { screen: "RegisterGoogle" })} - /> - - - - - Silakan isi formulir berikut untuk membuat akun Click - - - - - - - - - - - - - - - - - - - - - - - + + + Selamat Datang! + + + + nav.navigate("Auth", { screen: "RegisterGoogle" })} + /> + + + + nav.navigate("Auth", { screen: "RegisterGoogle" })} + /> + + + + + Silakan isi formulir berikut untuk membuat akun Click + + + + + + + + + + + + + + + + + + + + + + @@ -161,18 +159,15 @@ const RegisterScreen = ({ navigation }: RootTabScreenProps<"TabOne">) => { - - + + ); }; const styles = StyleSheet.create({ container: { - flex: 1, - fontStyle: "normal", - display: "flex", + padding: 24, backgroundColor: Colors.background, - paddingHorizontal: 24, }, titleText: { fontSize: 32, -- GitLab