41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
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, notification) {
|
|
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.
|
|
}
|