import { z } from 'zod';
import { GovernmentLevel, CampaignEmailStatus, EmailMethod } from '@prisma/client';

export const sendCampaignEmailSchema = z.object({
  userEmail: z.string().email('Valid email is required'),
  userName: z.string().min(1, 'Name is required'),
  postalCode: z.string().min(1, 'Postal code is required'),
  recipientEmail: z.string().email('Valid recipient email is required'),
  recipientName: z.string().optional(),
  recipientTitle: z.string().optional(),
  recipientLevel: z.nativeEnum(GovernmentLevel).optional(),
  emailMethod: z.nativeEnum(EmailMethod),
  customEmailSubject: z.string().optional(),
  customEmailBody: z.string().optional(),
});

export const trackMailtoSchema = z.object({
  recipientEmail: z.string().email('Valid recipient email is required'),
  recipientName: z.string().optional(),
  recipientTitle: z.string().optional(),
  recipientLevel: z.nativeEnum(GovernmentLevel).optional(),
  userEmail: z.string().email().optional(),
  userName: z.string().optional(),
  postalCode: z.string().optional(),
});

export const listCampaignEmailsSchema = z.object({
  page: z.coerce.number().int().positive().default(1),
  limit: z.coerce.number().int().positive().max(100).default(20),
  status: z.nativeEnum(CampaignEmailStatus).optional(),
  emailMethod: z.nativeEnum(EmailMethod).optional(),
});

export const campaignSlugParamSchema = z.object({
  slug: z.string().min(1),
});

export const campaignIdParamSchema = z.object({
  id: z.string().min(1),
});

export type SendCampaignEmailInput = z.infer<typeof sendCampaignEmailSchema>;
export type TrackMailtoInput = z.infer<typeof trackMailtoSchema>;
export type ListCampaignEmailsInput = z.infer<typeof listCampaignEmailsSchema>;
