feat: Sprint 3 — Territory management (list, add, edit, delete, detail), GPS tagging, territory tab

This commit is contained in:
root
2026-02-18 16:41:47 +08:00
parent 419865e8cf
commit 9bd02b1a17
9 changed files with 425 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ export function EditContactSheet({ contact, visible, onClose, onSaved }: Props)
const [status, setStatus] = useState(contact.status);
const [category, setCategory] = useState(contact.category);
const [notes, setNotes] = useState(contact.notes ?? '');
const [territoryCode, setTerritoryCode] = useState(contact.territoryCode ?? '');
const [loading, setLoading] = useState(false);
useEffect(() => {
@@ -30,6 +31,7 @@ export function EditContactSheet({ contact, visible, onClose, onSaved }: Props)
setStatus(contact.status);
setCategory(contact.category);
setNotes(contact.notes ?? '');
setTerritoryCode(contact.territoryCode ?? '');
}, [contact]);
async function handleSave() {
@@ -39,8 +41,8 @@ export function EditContactSheet({ contact, visible, onClose, onSaved }: Props)
const db = await getDatabase();
const now = Math.floor(Date.now() / 1000);
await db.runAsync(
'UPDATE contacts SET full_name=?, address=?, status=?, category=?, notes=?, updated_at=? WHERE id=?',
[fullName.trim(), address.trim() || null, status, category, notes.trim() || null, now, contact.id]
'UPDATE contacts SET full_name=?, address=?, status=?, category=?, notes=?, territory_code=?, updated_at=? WHERE id=?',
[fullName.trim(), address.trim() || null, status, category, notes.trim() || null, territoryCode.trim().toUpperCase() || null, now, contact.id]
);
onSaved();
} finally {
@@ -76,6 +78,8 @@ export function EditContactSheet({ contact, visible, onClose, onSaved }: Props)
</TouchableOpacity>
))}
</View>
{/* Territory Code */}
<Input label="Territory Code" placeholder="e.g. T-01" value={territoryCode} onChangeText={setTerritoryCode} autoCapitalize="characters" />
<Input label="Notes" value={notes} onChangeText={setNotes} multiline numberOfLines={3} />
<View className="h-8" />
</ScrollView>