continue generating flow, add backend connection on main tabs

This commit is contained in:
Thomas Demirdjian
2025-08-28 17:18:28 +02:00
parent 0ca7544005
commit bb7b35626f
110 changed files with 1701 additions and 3408 deletions
+48 -24
View File
@@ -1,23 +1,50 @@
/* eslint-disable react/display-name */
import React from "reactn";
import React, { useState } from "react";
import { useGlobal } from "reactn";
import { Pressable, Text, View } from "react-native";
import Page from "../layouts/Page.js";
import { background } from "../assets/index.js";
import { background } from "../assets";
import { Input } from "../components/Input.js";
import GradientButton from "../components/GradientButton.js";
import Palette from "../styles/Palette.js";
import { FONT_FAMILY } from "../styles/Fonts.js";
import { navigate } from "../navigation/NavigationService.js";
import { Routes } from "../navigation/Routes.js";
import { Routes } from "../navigation";
import ItemContainer from "../components/ItemContainer/ItemContainer.js";
import firebase, { usersRef } from "../config/firebase";
export default ({ navigation }) => {
const [, setTooltip] = useGlobal("_tooltip");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);
const onLogin = async () => {
try {
setLoading(true);
await firebase.auth().signInWithEmailAndPassword(email.trim(), password);
const uid = firebase.auth().currentUser?.uid;
if (!uid) throw new Error("Aucun utilisateur après connexion");
const snap = await usersRef.doc(uid).get();
const hasUserName = !!snap.data()?.userName;
if (hasUserName) {
navigation.reset({ index: 0, routes: [{ name: Routes.BottomTab }] });
} else {
navigation.reset({ index: 0, routes: [{ name: Routes.CreatePseudo }] });
}
} catch (e) {
console.log("Login error", e?.message);
setTooltip({ text: e?.message || "Connexion impossible", type: "error" });
} finally {
setLoading(false);
}
};
return (
<Page
backgroundImg={background.homeBG}
headerType="NAVIGATION"
title="Connexion"
hideBackButton
>
<View style={{ flex: 1, paddingTop: 20 }}>
<ItemContainer height={490}>
@@ -30,7 +57,7 @@ export default ({ navigation }) => {
fontFamily: FONT_FAMILY.InterSemiBold,
}}
>
Bonjour, pseudo!
Bonjour !
</Text>
<Text
style={{
@@ -45,8 +72,11 @@ export default ({ navigation }) => {
</View>
<View style={{ gap: 20 }}>
<Input
placeholder="Adresse mail ou pseudo"
label="Adresse mail ou pseudo"
placeholder="Adresse mail"
label="Adresse mail"
type="email"
value={email}
setValue={setEmail}
isBlur
/>
<View style={{ gap: 4 }}>
@@ -54,9 +84,13 @@ export default ({ navigation }) => {
placeholder="Mot de passe"
label="Mot de passe"
type="password"
value={password}
setValue={setPassword}
isBlur
/>
<Pressable>
<Pressable
onPress={() => navigate(Routes.ForgotPassword)}
>
<Text
style={{
fontSize: 12,
@@ -70,12 +104,13 @@ export default ({ navigation }) => {
</View>
</View>
<GradientButton
title="Poursuivre la création"
title="Se connecter"
containerStyle={{
width: "80%",
alignSelf: "center",
}}
onPress={() => navigate(Routes.BottomTab)}
onPress={onLogin}
disabled={loading || !email || !password}
/>
<View
style={{
@@ -83,17 +118,6 @@ export default ({ navigation }) => {
gap: 4,
}}
>
<Text
style={{
fontSize: 12,
color: Palette.gray,
fontFamily: FONT_FAMILY.HelveticaNeueRegular,
textAlign: "center",
}}
>
En tinscrivant, tu acceptes nos conditions générales{"\n"}
dutilisation et notre politique de confidentialité.
</Text>
<Pressable onPress={() => navigate(Routes.Register)}>
<Text
style={{
@@ -102,13 +126,13 @@ export default ({ navigation }) => {
fontFamily: FONT_FAMILY.HelveticaNeueRegular,
}}
>
Tu as déjà un compte?{" "}
Pas encore de compte?{" "}
<Text
style={{
fontFamily: FONT_FAMILY.InterSemiBold,
}}
>
Se connecter
Créer un compte
</Text>
</Text>
</Pressable>