From a8957c7ac75b0d73b6dd2f17e278fd9cfe60d172 Mon Sep 17 00:00:00 2001 From: ivic00 <102467664+ivic00@users.noreply.github.com> Date: Wed, 12 Feb 2025 00:05:39 +0100 Subject: [PATCH] birthday through qr, deleteFam function --- app/(unauth)/birthday_page.tsx | 117 +++++++++++ app/(unauth)/get_started.tsx | 2 +- .../user_settings_views/MyProfile.tsx | 18 +- firebase/functions/index.js | 80 ++++++++ hooks/firebase/useDeleteFamily.ts | 32 +++ .../react-native-big-calendar+4.15.1.patch | 194 ------------------ 6 files changed, 247 insertions(+), 196 deletions(-) create mode 100644 app/(unauth)/birthday_page.tsx create mode 100644 hooks/firebase/useDeleteFamily.ts delete mode 100644 patches/react-native-big-calendar+4.15.1.patch diff --git a/app/(unauth)/birthday_page.tsx b/app/(unauth)/birthday_page.tsx new file mode 100644 index 0000000..3800bc1 --- /dev/null +++ b/app/(unauth)/birthday_page.tsx @@ -0,0 +1,117 @@ +import { SafeAreaView } from "react-native-safe-area-context"; +import { Button, Text, View, DateTimePicker } from "react-native-ui-lib"; +import React, { useState } from "react"; +import { useRouter } from "expo-router"; +import { Platform, StyleSheet } from "react-native"; +import { useAuthContext } from "@/contexts/AuthContext"; +import firestore from "@react-native-firebase/firestore"; +import { useUpdateUserData } from "@/hooks/firebase/useUpdateUserData"; + +export default function BirthdayScreen() { + const router = useRouter(); + const { user } = useAuthContext(); + const [date, setDate] = useState(new Date()); + const { mutateAsync: updateUserData } = useUpdateUserData(); + + const onDateChange = (event: any, selectedDate?: Date) => { + const currentDate = selectedDate || date; + setDate(currentDate); + }; + + const handleContinue = async () => { + try { + updateUserData({ + newUserData: { + birthday: date, + }, + }).then(() => router.push("/(unauth)/cal_sync")); + } catch (error) { + console.error("Error saving birthday:", error); + } + }; + + const getMaxDate = () => { + const date = new Date(); + date.setFullYear(date.getFullYear() - 3); // Minimum age: 3 years + return date; + }; + + const getMinDate = () => { + const date = new Date(); + date.setFullYear(date.getFullYear() - 18); // Maximum age: 18 years + return date; + }; + + return ( + + + + + When's your birthday? + + + We'll use this to celebrate your special day! + + + + + { + if (date) { + const validDate = new Date(date); + if (!isNaN(validDate.getTime())) { + setDate(validDate); + } + } + }} + style={styles.textfield} + textAlign="center" + /> + + + + + +