IO-2215 Critical Parts scanning.
IO-2215 Critical Parts Scanning IO-2215 critical parts scanning
This commit is contained in:
@@ -348,7 +348,7 @@ export function JobLinesComponent({
|
||||
onClick={() => {
|
||||
setJobLineEditContext({
|
||||
actions: { refetch: refetch, submit: form && form.submit },
|
||||
context: record,
|
||||
context: { ...record, jobid: job.id },
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -14,8 +14,12 @@ import UndefinedToNull from "../../utils/undefinedtonull";
|
||||
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
|
||||
import Axios from "axios";
|
||||
import Dinero from "dinero.js";
|
||||
import CriticalPartsScan from "../../utils/criticalPartsScan";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
jobLineEditModal: selectJobLineEditModal,
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("jobLineEdit")),
|
||||
@@ -24,7 +28,13 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
function JobLinesUpsertModalContainer({
|
||||
jobLineEditModal,
|
||||
toggleModalVisible,
|
||||
bodyshop,
|
||||
}) {
|
||||
const { CriticalPartsScanning } = useTreatments(
|
||||
["CriticalPartsScanning"],
|
||||
{},
|
||||
bodyshop.imexshopid
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
const [insertJobLine] = useMutation(INSERT_NEW_JOB_LINE);
|
||||
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
|
||||
@@ -109,6 +119,9 @@ function JobLinesUpsertModalContainer({
|
||||
}
|
||||
toggleModalVisible();
|
||||
}
|
||||
if (CriticalPartsScanning.treatment === "on") {
|
||||
CriticalPartsScan(jobLineEditModal.context.jobid);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@ import {
|
||||
useApolloClient,
|
||||
useLazyQuery,
|
||||
useMutation,
|
||||
useQuery,
|
||||
useQuery
|
||||
} from "@apollo/client";
|
||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Col, notification, Row } from "antd";
|
||||
import Axios from "axios";
|
||||
import Dinero from "dinero.js";
|
||||
@@ -19,7 +20,7 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import {
|
||||
DELETE_AVAILABLE_JOB,
|
||||
QUERY_AVAILABLE_JOBS,
|
||||
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK,
|
||||
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK
|
||||
} from "../../graphql/available-jobs.queries";
|
||||
import { INSERT_NEW_JOB, UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
import { INSERT_NEW_NOTE } from "../../graphql/notes.queries";
|
||||
@@ -27,10 +28,11 @@ import { SEARCH_VEHICLE_BY_VIN } from "../../graphql/vehicles.queries";
|
||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
selectCurrentUser
|
||||
} from "../../redux/user/user.selectors";
|
||||
import confirmDialog from "../../utils/asyncConfirm";
|
||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||
import CriticalPartsScan from "../../utils/criticalPartsScan";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import JobsAvailableScan from "../jobs-available-scan/jobs-available-scan.component";
|
||||
import JobsFindModalContainer from "../jobs-find-modal/jobs-find-modal.container";
|
||||
@@ -53,6 +55,11 @@ export function JobsAvailableContainer({
|
||||
currentUser,
|
||||
insertAuditTrail,
|
||||
}) {
|
||||
const { CriticalPartsScanning } = useTreatments(
|
||||
["CriticalPartsScanning"],
|
||||
{},
|
||||
bodyshop.imexshopid
|
||||
);
|
||||
const { loading, error, data, refetch } = useQuery(QUERY_AVAILABLE_JOBS, {
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
@@ -155,6 +162,9 @@ export function JobsAvailableContainer({
|
||||
},
|
||||
})
|
||||
.then((r) => {
|
||||
if (CriticalPartsScanning.treatment === "on") {
|
||||
CriticalPartsScan(r.data.insert_jobs.returning[0].id);
|
||||
}
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.created"),
|
||||
onClick: () => {
|
||||
@@ -241,7 +251,9 @@ export function JobsAvailableContainer({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (CriticalPartsScanning.treatment === "on") {
|
||||
CriticalPartsScan(updateResult.data.update_jobs.returning[0].id);
|
||||
}
|
||||
if (updateResult.errors) {
|
||||
//error while inserting
|
||||
notification["error"]({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Button, Card, Tabs } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -24,6 +25,11 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoComponent);
|
||||
|
||||
export function ShopInfoComponent({ bodyshop, form, saveLoading }) {
|
||||
const { CriticalPartsScanning } = useTreatments(
|
||||
["CriticalPartsScanning"],
|
||||
{},
|
||||
bodyshop.imexshopid
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card
|
||||
@@ -72,9 +78,11 @@ export function ShopInfoComponent({ bodyshop, form, saveLoading }) {
|
||||
<Tabs.TabPane key="laborrates" tab={t("bodyshop.labels.laborrates")}>
|
||||
<ShopInfoLaborRates form={form} />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="partsscan" tab={t("bodyshop.labels.partsscan")}>
|
||||
<ShopInfoPartsScan form={form} />
|
||||
</Tabs.TabPane>
|
||||
{CriticalPartsScanning.treatment === "on" && (
|
||||
<Tabs.TabPane key="partsscan" tab={t("bodyshop.labels.partsscan")}>
|
||||
<ShopInfoPartsScan form={form} />
|
||||
</Tabs.TabPane>
|
||||
)}
|
||||
</Tabs>
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -230,6 +230,7 @@
|
||||
"addapptcolor": "Add Appointment Color",
|
||||
"addbucket": "Add Definition",
|
||||
"addpartslocation": "Add Parts Location",
|
||||
"addpartsrule": "Add Parts Scan Rule",
|
||||
"addspeedprint": "Add Speed Print",
|
||||
"addtemplate": "Add Template",
|
||||
"newlaborrate": "New Labor Rate",
|
||||
@@ -331,6 +332,10 @@
|
||||
"md_jobline_presets": "Jobline Presets",
|
||||
"md_lost_sale_reasons": "Lost Sale Reasons",
|
||||
"md_parts_order_comment": "Parts Orders Comments",
|
||||
"md_parts_scan": {
|
||||
"expression": "RegEX Expression",
|
||||
"flags": "Flags"
|
||||
},
|
||||
"md_payment_types": "Payment Types",
|
||||
"md_referral_sources": "Referral Sources",
|
||||
"messaginglabel": "Messaging Preset Label",
|
||||
@@ -581,6 +586,7 @@
|
||||
"notespresets": "Notes Presets",
|
||||
"orderstatuses": "Order Statuses",
|
||||
"partslocations": "Parts Locations",
|
||||
"partsscan": "Critical Parts Scanning",
|
||||
"printlater": "Print Later",
|
||||
"qbo": "Use QuickBooks Online?",
|
||||
"qbo_departmentid": "QBO Department ID",
|
||||
|
||||
@@ -230,6 +230,7 @@
|
||||
"addapptcolor": "",
|
||||
"addbucket": "",
|
||||
"addpartslocation": "",
|
||||
"addpartsrule": "",
|
||||
"addspeedprint": "",
|
||||
"addtemplate": "",
|
||||
"newlaborrate": "",
|
||||
@@ -331,6 +332,10 @@
|
||||
"md_jobline_presets": "",
|
||||
"md_lost_sale_reasons": "",
|
||||
"md_parts_order_comment": "",
|
||||
"md_parts_scan": {
|
||||
"expression": "",
|
||||
"flags": ""
|
||||
},
|
||||
"md_payment_types": "",
|
||||
"md_referral_sources": "",
|
||||
"messaginglabel": "",
|
||||
@@ -581,6 +586,7 @@
|
||||
"notespresets": "",
|
||||
"orderstatuses": "",
|
||||
"partslocations": "",
|
||||
"partsscan": "",
|
||||
"printlater": "",
|
||||
"qbo": "",
|
||||
"qbo_departmentid": "",
|
||||
|
||||
@@ -230,6 +230,7 @@
|
||||
"addapptcolor": "",
|
||||
"addbucket": "",
|
||||
"addpartslocation": "",
|
||||
"addpartsrule": "",
|
||||
"addspeedprint": "",
|
||||
"addtemplate": "",
|
||||
"newlaborrate": "",
|
||||
@@ -331,6 +332,10 @@
|
||||
"md_jobline_presets": "",
|
||||
"md_lost_sale_reasons": "",
|
||||
"md_parts_order_comment": "",
|
||||
"md_parts_scan": {
|
||||
"expression": "",
|
||||
"flags": ""
|
||||
},
|
||||
"md_payment_types": "",
|
||||
"md_referral_sources": "",
|
||||
"messaginglabel": "",
|
||||
@@ -581,6 +586,7 @@
|
||||
"notespresets": "",
|
||||
"orderstatuses": "",
|
||||
"partslocations": "",
|
||||
"partsscan": "",
|
||||
"printlater": "",
|
||||
"qbo": "",
|
||||
"qbo_departmentid": "",
|
||||
|
||||
12
client/src/utils/criticalPartsScan.js
Normal file
12
client/src/utils/criticalPartsScan.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import axios from "axios";
|
||||
import { notification } from "antd";
|
||||
|
||||
async function CriticalPartsScan(jobid) {
|
||||
try {
|
||||
await axios.post("/job/partsscan", { jobid });
|
||||
} catch (error) {
|
||||
notification.open({ type: "error", message: JSON.stringify(error) });
|
||||
}
|
||||
}
|
||||
|
||||
export default CriticalPartsScan;
|
||||
Reference in New Issue
Block a user