feat(interests): wire yachtId, enforce ownership + stage-gate
- Add yachtId (optional) to createInterestSchema + listInterestsSchema (updateInterestSchema inherits it via partial() automatically). - Add assertYachtBelongsToClient helper that accepts direct client ownership OR company-represented clients with an active membership in the owning company. - createInterest + updateInterest validate yacht ownership whenever yachtId is supplied/changed. - changeInterestStage rejects moving out of stage=open with yachtId null (ValidationError). - listInterests filter supports yachtId. - Integration tests cover all 7 paths; validator test for yachtId. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { PIPELINE_STAGES, LEAD_CATEGORIES } from '@/lib/constants';
|
||||
|
||||
export const createInterestSchema = z.object({
|
||||
clientId: z.string().min(1),
|
||||
yachtId: z.string().optional(),
|
||||
berthId: z.string().optional(),
|
||||
pipelineStage: z.enum(PIPELINE_STAGES).default('open'),
|
||||
leadCategory: z.enum(LEAD_CATEGORIES).optional(),
|
||||
@@ -34,6 +35,7 @@ export const changeStageSchema = z.object({
|
||||
|
||||
export const listInterestsSchema = baseListQuerySchema.extend({
|
||||
clientId: z.string().optional(),
|
||||
yachtId: z.string().optional(),
|
||||
berthId: z.string().optional(),
|
||||
pipelineStage: z
|
||||
.string()
|
||||
|
||||
Reference in New Issue
Block a user