import { z } from 'zod';

export const effectivenessQuerySchema = z.object({
  campaignId: z.string().uuid().optional(),
  dateFrom: z.string().datetime({ offset: true }).optional(),
  dateTo: z.string().datetime({ offset: true }).optional(),
});

export const trendQuerySchema = effectivenessQuerySchema.extend({
  granularity: z.enum(['day', 'week']).default('day'),
});

export const geoQuerySchema = effectivenessQuerySchema.extend({
  groupBy: z.enum(['province', 'city', 'postalCode']).default('postalCode'),
  limit: z.coerce.number().int().positive().max(200).default(20),
});

export const repQuerySchema = effectivenessQuerySchema.extend({
  sortBy: z.enum(['responseCount', 'responseRate', 'name']).default('responseCount'),
  limit: z.coerce.number().int().positive().max(200).default(20),
});

export type EffectivenessQuery = z.infer<typeof effectivenessQuerySchema>;
export type TrendQuery = z.infer<typeof trendQuerySchema>;
export type GeoQuery = z.infer<typeof geoQuerySchema>;
export type RepQuery = z.infer<typeof repQuerySchema>;
