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" + /> + + + + + +