Resolved attempted duplicate vehicle creation on import IO-471
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useApolloClient, useMutation, useQuery } from "@apollo/react-hooks";
|
||||
import { useMutation, useQuery, useApolloClient } from "@apollo/react-hooks";
|
||||
import { notification } from "antd";
|
||||
import Axios from "axios";
|
||||
import Dinero from "dinero.js";
|
||||
@@ -17,6 +17,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import JobsAvailableComponent from "./jobs-available-new.component";
|
||||
import { SEARCH_VEHICLE_BY_VIN } from "../../graphql/vehicles.queries";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -72,12 +73,12 @@ 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,
|
||||
// },
|
||||
// });
|
||||
const 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,
|
||||
@@ -85,9 +86,9 @@ 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
|
||||
// ? { vehicleid: existingVehicles.data.vehicles[0].id, vehicle: null }
|
||||
// : {}),
|
||||
...(existingVehicles.data.vehicles.length > 0
|
||||
? { vehicleid: existingVehicles.data.vehicles[0].id, vehicle: null }
|
||||
: {}),
|
||||
};
|
||||
|
||||
insertNewJob({
|
||||
|
||||
Reference in New Issue
Block a user