Resolved convert window visibility and job import error when vehicle already exists IO-426
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
QUERY_AVAILABLE_NEW_JOBS,
|
||||
} from "../../graphql/available-jobs.queries";
|
||||
import { INSERT_NEW_JOB } from "../../graphql/jobs.queries";
|
||||
import { SEARCH_VEHICLE_BY_VIN } from "../../graphql/vehicles.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
@@ -73,12 +72,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,
|
||||
@@ -86,9 +85,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({
|
||||
|
||||
@@ -6,7 +6,10 @@ import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { CONVERT_JOB_TO_RO } from "../../graphql/jobs.queries";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import {
|
||||
selectAuthLevel,
|
||||
selectBodyshop,
|
||||
} from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
@@ -22,16 +25,18 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
||||
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleConvert = (values) => {
|
||||
mutationConvertJob({
|
||||
const handleConvert = async (values) => {
|
||||
const res = await mutationConvertJob({
|
||||
variables: { jobId: job.id, ...values },
|
||||
}).then((r) => {
|
||||
refetch();
|
||||
});
|
||||
|
||||
if (!res.errors) {
|
||||
refetch();
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.converted"),
|
||||
});
|
||||
});
|
||||
setVisible(false);
|
||||
}
|
||||
};
|
||||
|
||||
const popMenu = (
|
||||
|
||||
Reference in New Issue
Block a user