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,
|
QUERY_AVAILABLE_NEW_JOBS,
|
||||||
} from "../../graphql/available-jobs.queries";
|
} from "../../graphql/available-jobs.queries";
|
||||||
import { INSERT_NEW_JOB } from "../../graphql/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 { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||||
@@ -73,12 +72,12 @@ export function JobsAvailableContainer({
|
|||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
const existingVehicles = await client.query({
|
// const existingVehicles = await client.query({
|
||||||
query: SEARCH_VEHICLE_BY_VIN,
|
// query: SEARCH_VEHICLE_BY_VIN,
|
||||||
variables: {
|
// variables: {
|
||||||
vin: estData.data.available_jobs_by_pk.est_data.vehicle.data.v_vin,
|
// vin: estData.data.available_jobs_by_pk.est_data.vehicle.data.v_vin,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
const newJob = {
|
const newJob = {
|
||||||
...estData.data.available_jobs_by_pk.est_data,
|
...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"),
|
owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat("0.00"),
|
||||||
job_totals: newTotals,
|
job_totals: newTotals,
|
||||||
queued_for_parts: true,
|
queued_for_parts: true,
|
||||||
...(existingVehicles.data.vehicles.length > 0
|
// ...(existingVehicles.data.vehicles.length > 0
|
||||||
? { vehicleid: existingVehicles.data.vehicles[0].id, vehicle: null }
|
// ? { vehicleid: existingVehicles.data.vehicles[0].id, vehicle: null }
|
||||||
: {}),
|
// : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
insertNewJob({
|
insertNewJob({
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import { connect } from "react-redux";
|
|||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { CONVERT_JOB_TO_RO } from "../../graphql/jobs.queries";
|
import { CONVERT_JOB_TO_RO } from "../../graphql/jobs.queries";
|
||||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
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({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
@@ -22,16 +25,18 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
|
|||||||
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleConvert = (values) => {
|
const handleConvert = async (values) => {
|
||||||
mutationConvertJob({
|
const res = await mutationConvertJob({
|
||||||
variables: { jobId: job.id, ...values },
|
variables: { jobId: job.id, ...values },
|
||||||
}).then((r) => {
|
});
|
||||||
refetch();
|
|
||||||
|
|
||||||
|
if (!res.errors) {
|
||||||
|
refetch();
|
||||||
notification["success"]({
|
notification["success"]({
|
||||||
message: t("jobs.successes.converted"),
|
message: t("jobs.successes.converted"),
|
||||||
});
|
});
|
||||||
});
|
setVisible(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const popMenu = (
|
const popMenu = (
|
||||||
|
|||||||
Reference in New Issue
Block a user