0eccfe3a4d7e18ed03cf93d1addcb9f06b929fba
Phase 10 Plan 1: Schema, validators, and query layer for CRM leads + activities + reminders Schema Changes: - Expand leads table: +phone, company, status (6 pipeline stages), last_contact_date, next_action, next_action_date, notes, updated_at - Add activities table: immutable interaction history (call/email/meeting/note) - Add reminders table: follow-up scheduling with due dates - Relations: leads ↔ activities, leads ↔ reminders (cascade delete) - Indexes: on status, last_contact_date, activity_date, due_date for query performance Validators (lead-validators.ts): - LEAD_STAGES enum: contacted → qualified → proposal_sent → negotiating → won → lost - ACTIVITY_TYPES enum: call, email, meeting, note - 5 Zod schemas: createLead, updateLead, createActivity, createReminder, updateLeadStage - Italian error messages Service Layer (lead-service.ts): - 14 query functions: getAllLeads, getLeadById, getLeadsByStage, getLeadsNeedingFollowUp - Activity: getActivityLog, createActivity (with auto-update of last_contact_date) - Reminders: getUpcomingReminders, getOverdueReminders, createReminder, completeReminder - Utilities: searchLeads, updateLead, updateLeadStage, getQuotesByLeadId Migration: - 0005_phase_10_crm_leads_activities_reminders.sql: ALTER leads + CREATE activities + CREATE reminders - Additive-only (backward compatible) - Indexes created for performance TypeScript: - Activity, NewActivity, Reminder, NewReminder types exported - Full type safety throughout Build: npm run build PASSED (0 errors) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Description
ClientHub portale clienti
Languages
TypeScript
99.1%
CSS
0.7%