feat: Sprint 4 — Map View (OSM tiles, pins, status colors, territory filter, no-GPS list)

This commit is contained in:
2026-02-18 17:09:30 +08:00
parent 9bd02b1a17
commit 123b21f4db
3 changed files with 597 additions and 6 deletions

View File

@@ -1,4 +1,6 @@
import * as SQLite from 'expo-sqlite';
import { Contact } from '@/store/useContactStore';
import { dbToContact } from '@/lib/contactHelpers';
let db: SQLite.SQLiteDatabase | null = null;
@@ -112,3 +114,21 @@ async function initSchema(database: SQLite.SQLiteDatabase): Promise<void> {
);
}
}
// ── Map helpers ──────────────────────────────────────────────────────────────
export async function getContactsWithGPS(): Promise<Contact[]> {
const database = await getDatabase();
const result = await database.getAllAsync<any>(
`SELECT * FROM contacts WHERE latitude IS NOT NULL AND longitude IS NOT NULL AND deleted_at IS NULL ORDER BY full_name`
);
return result.map(dbToContact);
}
export async function getAllContactsForMap(): Promise<Contact[]> {
const database = await getDatabase();
const result = await database.getAllAsync<any>(
`SELECT * FROM contacts WHERE deleted_at IS NULL ORDER BY full_name`
);
return result.map(dbToContact);
}