From 0d484677e0702afb21eedf5e290b98565e539297 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 1 Feb 2021 11:15:45 -0800 Subject: [PATCH] Resolved missing Vehicle info on Import IO-440 --- .../jobs-available-new.container.jsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/src/components/jobs-available-new/jobs-available-new.container.jsx b/client/src/components/jobs-available-new/jobs-available-new.container.jsx index 1806c5c39..b4545a946 100644 --- a/client/src/components/jobs-available-new/jobs-available-new.container.jsx +++ b/client/src/components/jobs-available-new/jobs-available-new.container.jsx @@ -73,12 +73,16 @@ export function JobsAvailableContainer({ }) ).data; - const existingVehicles = await client.query({ - query: SEARCH_VEHICLE_BY_VIN, - variables: { - vin: estData.data.available_jobs_by_pk.est_data.vehicle.data.v_vin, - }, - }); + let existingVehicles; + if (estData.data.available_jobs_by_pk.est_data.vehicle) { + //There's vehicle data, need to double check the VIN. + existingVehicles = await client.query({ + query: SEARCH_VEHICLE_BY_VIN, + variables: { + vin: estData.data.available_jobs_by_pk.est_data.vehicle.data.v_vin, + }, + }); + } const newJob = { ...estData.data.available_jobs_by_pk.est_data, @@ -86,7 +90,7 @@ export function JobsAvailableContainer({ owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat("0.00"), job_totals: newTotals, queued_for_parts: true, - ...(existingVehicles.data.vehicles.length > 0 + ...(existingVehicles && existingVehicles.data.vehicles.length > 0 ? { vehicleid: existingVehicles.data.vehicles[0].id, vehicle: null } : {}), };