From 0c43c8edd26da056625dcd70b31214105d6659fa Mon Sep 17 00:00:00 2001 From: Mohammad Khyata Date: Mon, 27 Apr 2026 11:32:35 +0300 Subject: [PATCH] add customer_id prop to RhfVehicleSelectField and update vehicle query Co-authored-by: Copilot --- apps/dashboard/modules/job-cards/job-card-form.tsx | 3 ++- .../modules/vehicles/rhf-vehicle-select-field.tsx | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/modules/job-cards/job-card-form.tsx b/apps/dashboard/modules/job-cards/job-card-form.tsx index 656626c..f92d39c 100644 --- a/apps/dashboard/modules/job-cards/job-card-form.tsx +++ b/apps/dashboard/modules/job-cards/job-card-form.tsx @@ -208,6 +208,7 @@ export function JobCardForm({ resourceId, initialData, onSuccess }: JobCardFormP const hasInsurance = form.watch("has_insurance") const status = form.watch("status") + const customer = form.watch("customer") const isCheckIn = status === "check_in" const { mutate, error, isPending } = useFormMutation(form, { @@ -250,7 +251,7 @@ export function JobCardForm({ resourceId, initialData, onSuccess }: JobCardFormP
- +
diff --git a/apps/dashboard/modules/vehicles/rhf-vehicle-select-field.tsx b/apps/dashboard/modules/vehicles/rhf-vehicle-select-field.tsx index b73fbb5..ddd3e99 100644 --- a/apps/dashboard/modules/vehicles/rhf-vehicle-select-field.tsx +++ b/apps/dashboard/modules/vehicles/rhf-vehicle-select-field.tsx @@ -72,6 +72,7 @@ export type RhfVehicleSelectFieldProps< required?: boolean disabled?: boolean placeholder?: string + customer_id?: string | null } // ── Component ── @@ -86,6 +87,7 @@ export function RhfVehicleSelectField< required, disabled, placeholder = "Search by make, model, year, or plate...", + customer_id, }: RhfVehicleSelectFieldProps) { const api = useAuthApi() const anchorRef = useRef(null) @@ -100,9 +102,9 @@ export function RhfVehicleSelectField< } = useController({ name, control, disabled }) const { data: options = [], isLoading } = useQuery({ - queryKey: [VEHICLE_ROUTES.INDEX, "vehicle-select"], + queryKey: [VEHICLE_ROUTES.INDEX, "vehicle-select", customer_id], queryFn: async () => { - const res = await api.vehicles.list() + const res = await api.vehicles.list({ customer_id: customer_id || undefined }) return extractItems(res).map(buildVehicleOption) }, staleTime: 5 * 60 * 1000, @@ -129,7 +131,7 @@ export function RhfVehicleSelectField< const combobox = (
- { const single = Array.isArray(val) ? val[0] ?? null : val