import { z } from 'zod';

// Esquema para QuestionStat
export const QuestionStatSchema = z.object({
  questionId: z.string(),
  label: z.string(),
  count: z.number(),
});

// Esquema para SurveyDetail
export const SurveyDetailSchema = z.object({
  id: z.number(),
  title: z.string(),
  description: z.string(),
  totalResponses: z.number(),
  targetAudience: z.string(),
  createdAt: z.string(),
  closingDate: z.string().optional(),
  questionStats: z.array(QuestionStatSchema),
});


// Esquema para SurveyStatisticsData
export const SurveyStatisticsDataSchema = z.object({
  totalSurveys: z.number(),
  totalResponses: z.number(),
  completionRate: z.number(),
  surveysByMonth: z.array(
    z.object({
      month: z.string(),
      count: z.number(),
    })
  ),
  responsesByAudience: z.array(
    z.object({
      name: z.string(),
      value: z.number(),
    })
  ),
  responseDistribution: z.array(
    z.object({
      title: z.string(),
      responses: z.number(),
    })
  ),
  surveyDetails: z.array(SurveyDetailSchema),
  // surveyDetails: z.array(z.any()),
});

// Response schemas for the API create, update 
export const SurveyStatisticsSchema = z.object({
  message: z.string(),
  data: SurveyStatisticsDataSchema,
});

// Tipos inferidos de Zod
export type SurveyStatisticsType = z.infer<typeof SurveyStatisticsSchema>;
export type SurveyDetailType = z.infer<typeof SurveyDetailSchema>;
export type QuestionStatType = z.infer<typeof QuestionStatSchema>;