import { router } from 'expo-router'; import { StatusBar } from 'expo-status-bar'; import { useState } from 'react'; import { KeyboardAvoidingView, Platform, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { getDB } from '../db'; export default function AddGoalScreen() { const insets = useSafeAreaInsets(); const [name, setName] = useState(''); const [targetAmount, setTargetAmount] = useState(''); const [currentAmount, setCurrentAmount] = useState(''); const [deadline, setDeadline] = useState(''); const handleSave = async () => { if (!name || !targetAmount) { alert('Please fill in name and target amount'); return; } try { const db = getDB(); await db.runAsync( 'INSERT INTO goals (name, target_amount, current_amount, deadline) VALUES (?, ?, ?, ?)', [name, parseFloat(targetAmount), currentAmount ? parseFloat(currentAmount) : 0, deadline] ); router.back(); } catch (error) { console.error(error); alert('Failed to save goal'); } }; return ( New Goal {/* Target Amount Input */} Target Amount {/* Details Form */} Goal Name Current Savings (Optional) Deadline (Optional) Save Goal ); }