import { z } from 'zod';

export const serviceCategorySchema = z
  .object({
    id: z.union([z.string(), z.number()]),
    name: z.string(),
    slug: z.string(),
    description: z.string().optional(),
  })
  .passthrough();

export const serviceItemSchema = z.object({
  id: z.union([z.string(), z.number()]),
  title: z.string(),
  slug: z.string(),
  description: z.string(),
  priceFrom: z.number().nullable().optional(),
  imageUrl: z.string().nullable().optional(),
  status: z.string(),
  category: serviceCategorySchema.nullish(),
  createdAt: z.string(),
  updatedAt: z.string(),
});

export type ServiceItem = z.infer<typeof serviceItemSchema>;
export type ServiceCategory = z.infer<typeof serviceCategorySchema>;

export const serviceListSchema = z.array(serviceItemSchema);

export type ServiceListResponse = z.infer<typeof serviceListSchema>;

export const servicePageSchema = z.object({
  items: serviceListSchema,
  total: z.number(),
  limit: z.number(),
  offset: z.number(),
});

export type ServicePageResponse = z.infer<typeof servicePageSchema>;
