import { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, ScrollView, Alert, ActivityIndicator } from 'react-native'; import { router } from 'expo-router'; import { api } from '../../../services/api'; export default function SubmitRemittanceScreen() { const [amount, setAmount] = useState(''); const [notes, setNotes] = useState(''); const [loading, setLoading] = useState(false); const submit = async () => { if (!amount || isNaN(Number(amount))) return Alert.alert('Required', 'Enter a valid amount.'); setLoading(true); try { await api.post('/api/v1/remittances', { totalAmount: Number(amount), notes }); Alert.alert('Submitted', 'Remittance submitted successfully.', [{ text: 'OK', onPress: () => router.back() }]); } catch (e: any) { Alert.alert('Error', e?.response?.data?.message ?? 'Submission failed.'); } finally { setLoading(false); } }; return ( router.back()} className="mr-3"> Submit Remittance Total Collection (₱) Notes (optional) {loading ? : Submit Remittance} ); }