feat: Sprint 0 — project scaffold, DB schema, Zustand stores, base UI components

This commit is contained in:
root
2026-02-18 06:21:22 +08:00
commit 8f66a4d4ed
22 changed files with 497 additions and 0 deletions

42
store/useContactStore.ts Normal file
View File

@@ -0,0 +1,42 @@
import { create } from 'zustand';
export type ContactCategory = 'Adult' | 'Teenager' | 'Kid';
export type ContactStatus = 'Active' | 'Return Visit' | 'Bible Study' | 'Not Interested' | 'Do Not Call';
export interface Contact {
id: string;
ownerId: string;
fullName: string;
address?: string;
householdCount: number;
gender?: string;
category: ContactCategory;
status: ContactStatus;
tags: string[];
notes?: string;
territoryCode?: string;
latitude?: number;
longitude?: number;
createdAt: number;
updatedAt: number;
}
interface ContactStore {
contacts: Contact[];
setContacts: (contacts: Contact[]) => void;
addContact: (contact: Contact) => void;
updateContact: (id: string, updates: Partial<Contact>) => void;
removeContact: (id: string) => void;
}
export const useContactStore = create<ContactStore>((set) => ({
contacts: [],
setContacts: (contacts) => set({ contacts }),
addContact: (contact) => set((state) => ({ contacts: [...state.contacts, contact] })),
updateContact: (id, updates) =>
set((state) => ({
contacts: state.contacts.map((c) => (c.id === id ? { ...c, ...updates } : c)),
})),
removeContact: (id) =>
set((state) => ({ contacts: state.contacts.filter((c) => c.id !== id) })),
}));