feat: Sprint 2 — Visit history, topic selector, date picker, home dashboard with stats and FAB

This commit is contained in:
root
2026-02-18 16:04:34 +08:00
parent 5ddfa9722b
commit 419865e8cf
6 changed files with 549 additions and 22 deletions

40
lib/visitHelpers.ts Normal file
View File

@@ -0,0 +1,40 @@
import * as Crypto from 'expo-crypto';
export interface Visit {
id: string;
contactId: string;
visitedByName: string;
visitedById: string;
visitDate: number;
topic?: string;
response?: string;
remarks?: string;
nextVisitDate?: number;
createdAt: number;
updatedAt: number;
}
export function dbToVisit(row: any): Visit {
return {
id: row.id,
contactId: row.contact_id,
visitedByName: row.visited_by_name,
visitedById: row.visited_by_id,
visitDate: row.visit_date,
topic: row.topic,
response: row.response,
remarks: row.remarks,
nextVisitDate: row.next_visit_date,
createdAt: row.created_at,
updatedAt: row.updated_at,
};
}
export function newVisitId(): string {
return Crypto.randomUUID();
}
export function formatDate(timestamp: number): string {
const d = new Date(timestamp * 1000);
return d.toLocaleDateString('en-PH', { year: 'numeric', month: 'short', day: 'numeric' });
}