diff --git a/components/TransactionForm.tsx b/components/TransactionForm.tsx index 37e5fe9..cad0eac 100644 --- a/components/TransactionForm.tsx +++ b/components/TransactionForm.tsx @@ -6,6 +6,7 @@ import { TouchableOpacity, StyleSheet, ScrollView, + Alert, } from 'react-native'; import { COLORS, FONTS } from '../constants/theme'; import { Transaction, CATEGORIES } from '../types'; @@ -22,11 +23,20 @@ export const TransactionForm: React.FC = ({ onAdd }) => { const [category, setCategory] = useState('lainnya'); const handleSubmit = () => { - if (!amount || !description) return; + if (!amount || !description) { + Alert.alert('Error', 'Mohon isi jumlah dan deskripsi'); + return; + } + + const numAmount = parseInt(amount, 10); + if (isNaN(numAmount) || numAmount <= 0) { + Alert.alert('Error', 'Jumlah harus angka positif'); + return; + } const transaction: Transaction = { id: generateId(), - amount: parseInt(amount, 10), + amount: numAmount, description, type, category,