import { z } from 'zod'

export const cardTypeStatusSchema = z.enum(['active', 'inactive'])

export const rechargeTypeSchema = z.enum(['balance', 'subscription'])

export const cardTypeSchema = z.object({
  id: z.union([z.string(), z.number()]),
  user_id: z.union([z.string(), z.number()]),
  application_id: z.union([z.string(), z.number()]).nullable(),
  name: z.string(),
  description: z.string(),
  recharge_type: rechargeTypeSchema.default('balance'),
  value: z.number(),
  value_unit: z.string().optional(),
  price: z.number(),
  generatedCount: z.number().default(0),
  status: cardTypeStatusSchema,
  created_at: z.string(),
  updated_at: z.string().optional(),
  application: z.object({
    id: z.union([z.string(), z.number()]),
    name: z.string(),
  }).optional().nullable(),
})

export type CardType = z.infer<typeof cardTypeSchema>
export type CardTypeStatus = z.infer<typeof cardTypeStatusSchema>
export type RechargeType = z.infer<typeof rechargeTypeSchema>
