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
+24 -2
View File
@@ -1,5 +1,5 @@
/* eslint-disable react/display-name */
import React from "reactn";
import React, { useEffect, useGlobal } from "reactn";
import Page from "../../layouts/Page";
import { gutters, Palette, Style } from "../../styles";
import { background } from "../../assets";
@@ -8,11 +8,33 @@ import { responsiveHeight } from "react-native-responsive-dimensions";
import { BlurView } from "expo-blur";
import Switch from "../../components/Switch";
import { useState } from "react";
import firebase, { usersRef } from "../../config/firebase";
import { FONT_FAMILY } from "../../styles/Fonts";
export default (props) => {
const [currentUID] = useGlobal("currentUID");
const [currentUserData] = useGlobal("currentUserData");
const [, setTooltip] = useGlobal("_tooltip");
const [isSwitch, setIsSwitch] = useState(false);
useEffect(() => {
setIsSwitch(!!currentUserData?.notifications);
}, [currentUserData?.notifications]);
const onToggle = async (next) => {
try {
setIsSwitch(next);
const uid = currentUID || firebase.auth().currentUser?.uid;
if (!uid) return;
await usersRef.doc(uid).set({ notifications: next }, { merge: true });
setTooltip({ type: "success", text: "Préférence enregistrée" });
} catch (e) {
setIsSwitch(!next);
setTooltip({ type: "error", text: e?.message || "Enregistrement impossible" });
}
};
return (
<Page
headerType="NAVIGATE"
@@ -50,7 +72,7 @@ export default (props) => {
>
Notifications
</Text>
<Switch value={isSwitch} setValue={setIsSwitch} />
<Switch value={isSwitch} setValue={onToggle} />
</View>
<Text
style={{