- Implemented TemplateCheckpointEditDialog for creating and editing inspection checkpoints. - Added VendorActions component for managing vendor actions including edit, activate/deactivate, and delete. - Created VendorContext for managing vendor state across components. - Developed VendorGeneralInfo component to display detailed vendor information. - Introduced AedSymbol and Money components for consistent currency representation. - Added PromptDialog for user input prompts throughout the application. - Implemented RelationLink component for unified related-data display in CRUD tables. - Created InspectionTemplatesClient for API interactions related to inspection templates.
35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
import { z } from "zod"
|
|
|
|
const relationFieldSchema = z
|
|
.object({ value: z.string(), label: z.string() })
|
|
.nullable()
|
|
|
|
const inspectionFormSchema = z.object({
|
|
customer: relationFieldSchema.refine((val) => !!val?.value, "Customer is required"),
|
|
vehicle: relationFieldSchema.refine((val) => !!val?.value, "Vehicle is required"),
|
|
department: relationFieldSchema.refine((val) => !!val?.value, "Department is required"),
|
|
inspection_category: relationFieldSchema.refine((val) => !!val?.value, "Inspection category is required"),
|
|
employee: relationFieldSchema.refine((val) => !!val?.value, "Employee is required"),
|
|
job_card: relationFieldSchema.optional(),
|
|
labor_rate: relationFieldSchema.optional(),
|
|
title: z.string().min(1, "Title is required").max(100, "Title cannot exceed 100 characters"),
|
|
order_number: z.string().min(1, "Order number is required").max(100, "Order number cannot exceed 100 characters"),
|
|
date: z.string().min(1, "Date is required"),
|
|
time: z.string().min(1, "Time is required"),
|
|
status: z.string().optional(),
|
|
note: z.string().optional(),
|
|
description: z.string().optional(),
|
|
rate_type: z.string().optional(),
|
|
quantity: z.coerce.number().min(0).optional(),
|
|
rate: z.coerce.number().min(0).optional(),
|
|
working_hours: z.coerce.number().min(0).optional(),
|
|
labor_hours: z.coerce.number().min(0).optional(),
|
|
tax: relationFieldSchema.optional(),
|
|
chart_of_account: z.string().optional(),
|
|
})
|
|
|
|
type InspectionFormValues = z.infer<typeof inspectionFormSchema>
|
|
|
|
export { inspectionFormSchema, relationFieldSchema }
|
|
export type { InspectionFormValues }
|