import { z } from 'zod';

export const createStorySchema = z.object({
  campaignId: z.string().min(1),
  type: z.enum(['MILESTONE', 'VICTORY', 'RESPONSE', 'CUSTOM']),
  title: z.string().min(1).max(200),
  body: z.string().min(1).max(5000),
  coverImageUrl: z.string().url().optional(),
  milestoneValue: z.number().int().positive().optional(),
  milestoneMetric: z.string().max(100).optional(),
});

export const updateStorySchema = z.object({
  campaignId: z.string().min(1).optional(),
  type: z.enum(['MILESTONE', 'VICTORY', 'RESPONSE', 'CUSTOM']).optional(),
  title: z.string().min(1).max(200).optional(),
  body: z.string().min(1).max(5000).optional(),
  coverImageUrl: z.string().url().nullable().optional(),
  milestoneValue: z.number().int().positive().nullable().optional(),
  milestoneMetric: z.string().max(100).nullable().optional(),
});

export const listStoriesSchema = z.object({
  page: z.coerce.number().int().min(1).default(1),
  limit: z.coerce.number().int().min(1).max(100).default(20),
  campaignId: z.string().optional(),
  status: z.enum(['DRAFT', 'PUBLISHED', 'ARCHIVED']).optional(),
});

export type CreateStoryInput = z.infer<typeof createStorySchema>;
export type UpdateStoryInput = z.infer<typeof updateStorySchema>;
export type ListStoriesInput = z.infer<typeof listStoriesSchema>;
