diff --git a/app/addCalendarEvents.tsx b/app/addCalendarEvents.tsx index 6397144..5b790f3 100644 --- a/app/addCalendarEvents.tsx +++ b/app/addCalendarEvents.tsx @@ -9,7 +9,7 @@ import { IPAddr } from './constants'; import { useNavigation } from '@react-navigation/native'; import axios from 'axios'; import { IPAddr } from './constants'; -import GenericForm from './addEventPage'; +import GenericAddPageForm from './addEventPage'; import { StackNavigationProp } from '@react-navigation/stack'; import { RootStackParamList } from '@/components/Types'; diff --git a/app/addEventPage.tsx b/app/addEventPage.tsx index b4fec6e..be971c6 100644 --- a/app/addEventPage.tsx +++ b/app/addEventPage.tsx @@ -12,7 +12,7 @@ interface FormProps { onCancel: () => void; } -const GenericForm: React.FC = ({ title, initialData, fields, onSave, onCancel }) => { +const GenericAddPageForm: React.FC = ({ title, initialData, fields, onSave, onCancel }) => { const [formData, setFormData] = useState(initialData); const handleChange = (name: string, value: any) => { setFormData({ ...formData, [name]: value }); @@ -115,4 +115,4 @@ const GenericForm: React.FC = ({ title, initialData, fields, onSave, ); }; -export default GenericForm; +export default GenericAddPageForm; diff --git a/app/addFinanceEvents.tsx b/app/addFinanceEvents.tsx index c367656..f36b40e 100644 --- a/app/addFinanceEvents.tsx +++ b/app/addFinanceEvents.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { useNavigation } from '@react-navigation/native'; import axios from 'axios'; import { IPAddr } from './constants'; -import GenericForm from './addEventPage'; +import GenericAddPageForm from './addEventPage'; import { StackNavigationProp } from '@react-navigation/stack'; import { RootStackParamList } from '@/components/Types'; @@ -52,7 +52,7 @@ export default function AddFinanceEvents() { return ( - { }; return ( - ([]); - type HealthProp = StackNavigationProp; - const navigation = useNavigation(); - useFocusEffect( useCallback(() => { getEvents(); }, []) ); - const getEvents = (() => { axios.get(IPAddr + '/get_health_events/1') .then(response => { @@ -38,69 +26,14 @@ export default function HealthTracker() { setTasks(events); }) .catch(error => console.error('Error fetching events:', error)); - }) - const handleDayPress = (day: { dateString: React.SetStateAction; }) => { - setSelectedDate(day.dateString); - }; - - const renderTask = ({ item }: { item: Task }) => ( - - - - - - - {item.title} - - { item.done = isChecked; }} /> - - - ); - return ( - - - Health Tracker - Upcoming Events - - - item.id} - /> - - Title - - - navigation.navigate('addHealthEvents')} - hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}> - - - New - - - + ); } diff --git a/app/mainPageTemplate.tsx b/app/mainPageTemplate.tsx new file mode 100644 index 0000000..2072445 --- /dev/null +++ b/app/mainPageTemplate.tsx @@ -0,0 +1,89 @@ +import React, { useState } from 'react'; +import { View, Text, FlatList, TouchableOpacity } from 'react-native'; +import BouncyCheckbox from "react-native-bouncy-checkbox"; +import { Calendar } from 'react-native-calendars'; +import { styles } from './styles'; +import { Ionicons } from "@expo/vector-icons"; +import { RootStackParamList, Task } from '../components/Types'; +import { useNavigation, useFocusEffect } from '@react-navigation/native'; +import { StackNavigationProp } from '@react-navigation/stack'; + +interface FormProps { + title: string; + page: keyof RootStackParamList; + nextPage: keyof RootStackParamList + tasks: Array; + } + +const GenericMainPageForm: React.FC = ({ title, page, nextPage, tasks }) => { + const [selectedDate, setSelectedDate] = useState(''); + + type Prop = StackNavigationProp; + const navigation = useNavigation(); + + const handleDayPress = (day: { dateString: React.SetStateAction; }) => { + setSelectedDate(day.dateString); + }; + + const renderTask = ({ item }: { item: Task }) => ( + + + + + + + {item.title} + + { item.done = isChecked; }} /> + + + ); + + return ( + + + {title} + Upcoming Events + + + item.id} + /> + + Title + + + + + navigation.navigate(nextPage)} + hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}> + + + New + + + + ); +} +export default GenericMainPageForm;