import * as z from 'zod';

export const leadSchema = z.object({
  branchId: z.string().nullable().optional(),
  customerId: z.string().nullable().optional(),
  contactId: z.string().nullable().optional(),
  description: z.string().nullable().optional(),
  projectName: z.string().nullable().optional(),
  projectLocation: z.string().nullable().optional(),
  leadChannel: z.string().nullable().optional(),
  productType: z.string().nullable().optional(),
  priority: z.string().nullable().optional(),
  estimatedValue: z.number().nullable().optional(),
  awarenessId: z.string().nullable().optional(),
  status: z.string().min(1, 'Please select lead status').default('new_job'),
  followupStatus: z.string().nullable().optional(),
  lostReason: z.string().nullable().optional(),
  outcome: z.enum(['open', 'won', 'lost']).default('open'),
  ownerMarketingUserId: z.string().nullable().optional()
});

export const leadFormSchema = z.object({
  branchId: z.string().nullable(),
  customerId: z.string().nullable(),
  contactId: z.string().nullable(),
  description: z.string().nullable(),
  projectName: z.string().nullable(),
  projectLocation: z.string().nullable(),
  leadChannel: z.string().nullable(),
  productType: z.string().nullable(),
  priority: z.string().nullable(),
  estimatedValue: z.number().nullable(),
  awarenessId: z.string().nullable(),
  status: z.string().min(1, 'Please select lead status'),
  followupStatus: z.string().nullable(),
  lostReason: z.string().nullable(),
  outcome: z.enum(['open', 'won', 'lost']),
  ownerMarketingUserId: z.string().nullable()
});

export const updateLeadSchema = leadSchema.partial();

export const assignLeadSchema = z.object({
  salesOwnerId: z.string().min(1, 'Sales owner is required'),
  assignmentRemark: z.string().nullable().optional()
});

export const leadFollowupSchema = z.object({
  followupDate: z.string().min(1, 'Follow-up date required'),
  followupStatus: z.string().min(1, 'Please select follow-up status'),
  note: z.string().nullable().optional(),
  nextFollowupDate: z.string().nullable().optional()
});
