import { z } from 'zod'
import type { InstallationPosition } from '~/models/installation-position'

const InstallationPositionSchema = 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(),
  installation_id: z.union([
    z.string({ required_error: 'Instalasi Induk harus diisi' }),
    z.number({ required_error: 'Instalasi Induk harus diisi' }),
  ]),
  employee_id: z
    .union([z.string({ required_error: 'Karyawan harus diisi' }), z.number({ required_error: 'Karyawan harus diisi' })])
    .optional()
    .nullable(),
})
type InstallationPositionFormData = z.infer<typeof InstallationPositionSchema> & Partial<InstallationPosition>

export { InstallationPositionSchema }
export type { InstallationPositionFormData }
