Files
bodyshop/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addtoproduction.util.jsx
Allan Carr fa7d90d2a9 IO-2651 Audit Log Extension
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-03-05 15:28:22 -08:00

49 lines
1.3 KiB
JavaScript

import { notification } from "antd";
import i18n from "i18next";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { UPDATE_JOB } from "../../graphql/jobs.queries";
import { insertAuditTrail } from "../../redux/application/application.actions";
import { store } from "../../redux/store";
import AuditTrailMapping from "../../utils/AuditTrailMappings";
export default function AddToProduction(
apolloClient,
jobId,
completionCallback,
remove = false
) {
logImEXEvent("job_add_to_production");
//get a list of all fields on the job
apolloClient
.mutate({
mutation: UPDATE_JOB,
variables: { jobId: jobId, job: { inproduction: !remove } },
})
.then((res) => {
notification["success"]({
message: i18n.t("jobs.successes.save"),
});
store.dispatch(
insertAuditTrail({
jobid: jobId,
operation: AuditTrailMapping.jobinproductionchange(!remove),
type: "jobinproductionchange",
})
);
if (completionCallback) completionCallback();
})
.catch((error) => {
notification["errors"]({
message: i18n.t("jobs.errors.saving", {
error: JSON.stringify(error),
}),
});
});
//insert the new job. call the callback with the returned ID when done.
return;
}