garage-erp/apps/dashboard/modules/appointments/appointment.schema.ts
2026-04-09 15:17:07 +03:00

32 lines
1.0 KiB
TypeScript

import { z } from "zod"
import { AppointmentStatus } from "@garage/api"
const relationFieldSchema = z
.object({ value: z.string(), label: z.string() })
.nullable()
const APPOINTMENT_STATUS_OPTIONS = AppointmentStatus.map((v) => ({
value: v,
label: v.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()),
}))
const appointmentFormSchema = z.object({
title: z.string().min(1, "Title is required"),
date: z.string().min(1, "Date is required"),
from_time: z.string().min(1, "Start time is required"),
to_time: z.string().min(1, "End time is required"),
customer: relationFieldSchema,
vehicle: relationFieldSchema,
service_writer: relationFieldSchema,
technician: relationFieldSchema,
department: relationFieldSchema,
job_card: relationFieldSchema,
notes: z.string().optional(),
status: z.string().optional(),
})
type AppointmentFormValues = z.infer<typeof appointmentFormSchema>
export { appointmentFormSchema, relationFieldSchema, APPOINTMENT_STATUS_OPTIONS }
export type { AppointmentFormValues }