feat: Sprint 4 — Map View (OSM tiles, pins, status colors, territory filter, no-GPS list)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user