feat(dashboard): allow both vendor and employee on payment made
Remove the mutual-exclusion validation and update the field descriptions so a payment-made can be linked to a vendor and an employee at the same time. Previously selecting both raised a validation error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
97ad275588
commit
baa716b8ff
@ -268,14 +268,14 @@ export function PaymentMadeForm({ resourceId, initialData, onSuccess, billId, ex
|
|||||||
name="vendor"
|
name="vendor"
|
||||||
label="Vendor"
|
label="Vendor"
|
||||||
required={vendorRequired}
|
required={vendorRequired}
|
||||||
description="Select either a vendor or an employee."
|
description="Select a vendor, an employee, or both."
|
||||||
/>
|
/>
|
||||||
<RhfAsyncSelectField
|
<RhfAsyncSelectField
|
||||||
name="employee"
|
name="employee"
|
||||||
label="Employee"
|
label="Employee"
|
||||||
placeholder="Select employee"
|
placeholder="Select employee"
|
||||||
required={employeeRequired}
|
required={employeeRequired}
|
||||||
description="Select either a vendor or an employee."
|
description="Select a vendor, an employee, or both."
|
||||||
queryKey={[EMPLOYEE_ROUTES.INDEX]}
|
queryKey={[EMPLOYEE_ROUTES.INDEX]}
|
||||||
listFn={() => api.employees.list()}
|
listFn={() => api.employees.list()}
|
||||||
mapOption={mapEmployeeOption}
|
mapOption={mapEmployeeOption}
|
||||||
|
|||||||
@ -66,19 +66,6 @@ const paymentMadeFormSchema = z.object({
|
|||||||
message: "Vendor or employee is required",
|
message: "Vendor or employee is required",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasVendor && hasEmployee) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
path: ["vendor"],
|
|
||||||
message: "Select either a vendor or an employee, not both",
|
|
||||||
})
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
path: ["employee"],
|
|
||||||
message: "Select either a vendor or an employee, not both",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
type PaymentMadeFormValues = z.infer<typeof paymentMadeFormSchema>
|
type PaymentMadeFormValues = z.infer<typeof paymentMadeFormSchema>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user