27 lines
673 B
TypeScript
27 lines
673 B
TypeScript
import { Contact } from '@/store/useContactStore';
|
|
import * as Crypto from 'expo-crypto';
|
|
|
|
export function dbToContact(row: any): Contact {
|
|
return {
|
|
id: row.id,
|
|
ownerId: row.owner_id,
|
|
fullName: row.full_name,
|
|
address: row.address,
|
|
householdCount: row.household_count ?? 1,
|
|
gender: row.gender,
|
|
category: row.category,
|
|
status: row.status,
|
|
tags: JSON.parse(row.tags ?? '[]'),
|
|
notes: row.notes,
|
|
territoryCode: row.territory_code,
|
|
latitude: row.latitude,
|
|
longitude: row.longitude,
|
|
createdAt: row.created_at,
|
|
updatedAt: row.updated_at,
|
|
};
|
|
}
|
|
|
|
export function newContactId(): string {
|
|
return Crypto.randomUUID();
|
|
}
|