feat: Sprint 0 — project scaffold, DB schema, Zustand stores, base UI components
This commit is contained in:
42
store/useContactStore.ts
Normal file
42
store/useContactStore.ts
Normal 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) })),
|
||||
}));
|
||||
Reference in New Issue
Block a user