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 } : {}), };