feat: lead → client conversion + client contact fields (email/phone)
Blocco A+B (milestone v2.3). Migration 0011 is additive (ADD COLUMN only): clients.email, clients.phone, leads.archived. - createClientCore() extracted from createClient and reused by conversion - clients.email/phone added to create + edit forms and shown on client header (never exposed on the public /client/[token] page) - convertLeadToClient(): reuses core, carries over lead transcripts (client_transcripts.client_id), links project.created_from_lead_id, archives the lead while keeping its "won" status; idempotent - "Converti in cliente" button on won leads; "Convertito → Apri cliente" once converted (clientId resolved via created_from_lead_id) - archived leads hidden from list/kanban; detail page fetches by id incl. archived Migration must be applied to the prod DB BEFORE this is deployed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,10 @@ export const clients = pgTable("clients", {
|
||||
name: text("name").notNull(),
|
||||
brand_name: text("brand_name").notNull(),
|
||||
brief: text("brief").notNull(),
|
||||
// Contact fields (Phase v2.3) — carried over from a converted lead and used
|
||||
// by the Email & Accesso (OTP) milestone. Admin-only, never exposed publicly.
|
||||
email: text("email"),
|
||||
phone: text("phone"),
|
||||
// token is SEPARATE from id — rotatable secret for client link access
|
||||
token: text("token")
|
||||
.notNull()
|
||||
@@ -454,6 +458,9 @@ export const leads = pgTable("leads", {
|
||||
next_action: text("next_action"),
|
||||
next_action_date: timestamp("next_action_date", { withTimezone: true }),
|
||||
notes: text("notes"),
|
||||
// Archive flag (v2.3) — a converted lead is hidden from the pipeline while
|
||||
// keeping its "won" status, so the board doesn't fill up over time.
|
||||
archived: boolean("archived").notNull().default(false),
|
||||
created_at: timestamp("created_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
|
||||
Reference in New Issue
Block a user