feat: Sprint 2 — Visit history, topic selector, date picker, home dashboard with stats and FAB
This commit is contained in:
40
lib/visitHelpers.ts
Normal file
40
lib/visitHelpers.ts
Normal 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' });
|
||||
}
|
||||
Reference in New Issue
Block a user