fix: update default values in service form and enhance validation for required fields
This commit is contained in:
parent
4b51ffe457
commit
25c3125894
@ -43,10 +43,10 @@ export type ServiceFormProps = {
|
||||
// ── Default values ──
|
||||
|
||||
const DEFAULT_VALUES: ServiceFormValues = {
|
||||
shop_type: null,
|
||||
category: null,
|
||||
unit_type: null,
|
||||
department: null,
|
||||
shop_type: { value: "", label: "" },
|
||||
category: { value: "", label: "" },
|
||||
unit_type: { value: "", label: "" },
|
||||
department: { value: "", label: "" },
|
||||
labor_name: "",
|
||||
service_code: "",
|
||||
labor_matrix: "",
|
||||
|
||||
@ -5,8 +5,13 @@ export const relationFieldSchema = z
|
||||
.object({ value: z.string(), label: z.string() })
|
||||
.nullable()
|
||||
|
||||
const requiredRelationFieldSchema = relationFieldSchema.refine((value) => value !== null, {
|
||||
message: "This field is required",
|
||||
const requiredRelationFieldSchema = relationFieldSchema.superRefine((value, ctx) => {
|
||||
if (!value?.value) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "This field is required",
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const optionalNumericField = z.preprocess(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user