home, subscription and other fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useRef, useGlobal } from "reactn";
|
||||
import React, { useState, useGlobal } from "reactn";
|
||||
import { Text, KeyboardAvoidingView } from "react-native";
|
||||
import { responsiveHeight } from "../actions/responsiveSizes.js";
|
||||
|
||||
@@ -11,6 +11,10 @@ import { Fonts, Style } from "../styles";
|
||||
import Page from "../layouts/Page";
|
||||
import { background } from "../assets";
|
||||
import { isWeb } from "../hooks/useLayoutType";
|
||||
import {
|
||||
checkIfEmailIsValid,
|
||||
handleFirebaseError,
|
||||
} from "../actions/signupActions.js";
|
||||
|
||||
export default ({ navigation }) => {
|
||||
const [, setTooltip] = useGlobal("_tooltip");
|
||||
@@ -19,10 +23,27 @@ export default ({ navigation }) => {
|
||||
const [email, setEmail] = useState(__DEV__ ? "hello@minuit.agency" : "");
|
||||
|
||||
const onResetPassword = async () => {
|
||||
const trimmedEmail = (email || "").trim();
|
||||
if (!trimmedEmail?.length) {
|
||||
setTooltip({
|
||||
text: "Renseigne ton adresse e-mail.",
|
||||
type: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkIfEmailIsValid({ email: trimmedEmail })) {
|
||||
setTooltip({
|
||||
text: "Adresse e-mail invalide.",
|
||||
type: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
await firebase.auth().sendPasswordResetEmail(email);
|
||||
await firebase.auth().sendPasswordResetEmail(trimmedEmail);
|
||||
|
||||
setTooltip({
|
||||
text: "Email de réinitialisation envoyé!",
|
||||
@@ -31,9 +52,13 @@ export default ({ navigation }) => {
|
||||
|
||||
navigation.goBack();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log("ForgotPassword error", error?.message);
|
||||
const message =
|
||||
error?.code && error.code.startsWith("auth/")
|
||||
? handleFirebaseError(error.code)
|
||||
: error?.message || "Une erreur est survenue";
|
||||
setTooltip({
|
||||
text: "Une erreur est survenue",
|
||||
text: message,
|
||||
type: "error",
|
||||
});
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user