feat: add address field to lead form

This commit is contained in:
Nemo
2026-03-24 13:53:43 +08:00
parent 66cf8e01e8
commit dcff516375

View File

@@ -24,6 +24,7 @@ export default function LeadsScreen() {
const [showAdd, setShowAdd] = useState(false); const [showAdd, setShowAdd] = useState(false);
const [newName, setNewName] = useState(''); const [newName, setNewName] = useState('');
const [newPhone, setNewPhone] = useState(''); const [newPhone, setNewPhone] = useState('');
const [newAddress, setNewAddress] = useState('');
const [newNotes, setNewNotes] = useState(''); const [newNotes, setNewNotes] = useState('');
const [saving, setSaving] = useState(false); const [saving, setSaving] = useState(false);
@@ -47,10 +48,11 @@ export default function LeadsScreen() {
await api.post('/api/v1/leads', { await api.post('/api/v1/leads', {
firstName, lastName, firstName, lastName,
phone: newPhone.trim(), phone: newPhone.trim(),
...(newAddress.trim() ? { address: newAddress.trim() } : {}),
...(newNotes.trim() ? { notes: newNotes.trim() } : {}), ...(newNotes.trim() ? { notes: newNotes.trim() } : {}),
}); });
setShowAdd(false); setShowAdd(false);
setNewName(''); setNewPhone(''); setNewNotes(''); setNewName(''); setNewPhone(''); setNewAddress(''); setNewNotes('');
qc.invalidateQueries({ queryKey: ['leads'] }); qc.invalidateQueries({ queryKey: ['leads'] });
refetch(); refetch();
} catch (e: any) { } catch (e: any) {
@@ -169,6 +171,13 @@ export default function LeadsScreen() {
style={{ borderWidth: 1.5, borderColor: '#E2E8F0', borderRadius: 12, paddingHorizontal: 14, paddingVertical: 13, fontSize: 16, color: '#1E293B', marginBottom: 14 }} style={{ borderWidth: 1.5, borderColor: '#E2E8F0', borderRadius: 12, paddingHorizontal: 14, paddingVertical: 13, fontSize: 16, color: '#1E293B', marginBottom: 14 }}
/> />
<Text style={{ fontSize: 13, fontWeight: '600', color: '#64748B', marginBottom: 6 }}>Address (optional)</Text>
<TextInput
value={newAddress} onChangeText={setNewAddress}
placeholder="Sitio, Barangay, Municipality..."
style={{ borderWidth: 1.5, borderColor: '#E2E8F0', borderRadius: 12, paddingHorizontal: 14, paddingVertical: 13, fontSize: 16, color: '#1E293B', marginBottom: 14 }}
/>
<Text style={{ fontSize: 13, fontWeight: '600', color: '#64748B', marginBottom: 6 }}>Notes (optional)</Text> <Text style={{ fontSize: 13, fontWeight: '600', color: '#64748B', marginBottom: 6 }}>Notes (optional)</Text>
<TextInput <TextInput
value={newNotes} onChangeText={setNewNotes} value={newNotes} onChangeText={setNewNotes}