import { z } from 'zod';

export const ROLES = [
  'director',
  'officer',
  'broker',
  'representative',
  'legal_counsel',
  'employee',
  'shareholder',
  'other',
] as const;

export const addMembershipSchema = z.object({
  clientId: z.string().min(1),
  role: z.enum(ROLES),
  roleDetail: z.string().optional(),
  startDate: z.coerce.date(),
  isPrimary: z.boolean().optional().default(false),
  notes: z.string().optional(),
});

export const updateMembershipSchema = z.object({
  role: z.enum(ROLES).optional(),
  roleDetail: z.string().nullable().optional(),
  notes: z.string().nullable().optional(),
  isPrimary: z.boolean().optional(),
});

export const endMembershipSchema = z.object({
  endDate: z.coerce.date(),
});

export type AddMembershipInput = z.infer<typeof addMembershipSchema>;
export type UpdateMembershipInput = z.infer<typeof updateMembershipSchema>;
export type EndMembershipInput = z.infer<typeof endMembershipSchema>;
