Files
alla-allaos-fullstack/docs/implementation/task-d.6.1-lead-create-form-ux-default-rules-2026-07-01.md
phaichayon 0a144f0f9e task-d.6.1
2026-07-01 10:29:00 +07:00

3.9 KiB

Task D.6.1 Implementation Report - 2026-07-01

Scope

  • Improve Create Lead UX so the first-step form only shows fields needed to open a new lead.
  • Enforce default create rules for lead status and marketing owner.
  • Add a persisted Lead Source field backed by master options.

Review Summary

Reviewed before implementation:

Changes

  • Added lead_channel to schema.ts and created 0001_lead_channel_and_status_default.sql.
  • Removed the old raw DB default for crm_leads.status and moved create-time default resolution into the lead service so new leads resolve new_job through master options.
  • Extended lead contracts in types.ts to carry leadChannel, leadChannelLabel, and leadChannels.
  • Extended lead.schema.ts with leadChannel and added a dedicated leadFormSchema for TanStack Form submit validation.
  • Updated service.ts to validate crm_lead_channel, return leadChannels reference data, map leadChannelLabel, and enforce create defaults for status, outcome, lost reason, and marketing owner.
  • Rebuilt lead-form.tsx so create mode hides Status, Lost Reason, and Marketing Owner, while edit mode still exposes the operational fields.
  • Updated lead-detail.tsx to display Lead Source.

Verification

  • npm run typecheck -> PASS
  • npm run build -> PASS
  • npm run audit:pdf -> PASS

Known Follow-up

  • Build still emits pre-existing Turbopack warnings about workspace root lockfiles and broad storage/template trace patterns.
  • I did not add Lead Source to lead table filters or listing columns in this phase because the task focused on create UX and default rules.

Outcome

Task D.6.1 now gives Create Lead a cleaner first-step UX, persists Lead Source through the lead domain, and enforces the intended default business rules from the server boundary instead of relying on client behavior alone.