import { z } from 'zod'
import type { SubSpecialistPosition } from '~/models/subspecialist-position'

const SubSpecialistPositionSchema = z.object({
  code: z.string({ required_error: 'Kode harus diisi' }).min(1, 'Kode minimum 1 karakter'),
  name: z.string({ required_error: 'Nama harus diisi' }).min(1, 'Nama minimum 1 karakter'),
  headStatus: z.boolean().optional().nullable(),
  subspecialist_code: z
    .union([
      z.string({ required_error: 'Spesialis harus diisi' }),
      z.number({ required_error: 'Spesialis harus diisi' }),
    ])
    .optional()
    .nullable(),
  employee_id: z
    .union([z.string({ required_error: 'Karyawan harus diisi' }), z.number({ required_error: 'Karyawan harus diisi' })])
    .optional()
    .nullable(),
})

type SubSpecialistPositionFormData = z.infer<typeof SubSpecialistPositionSchema> & Partial<SubSpecialistPosition>

export { SubSpecialistPositionSchema }
export type { SubSpecialistPositionFormData }
