diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index c7321fcd0..1ef4de925 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -12813,6 +12813,27 @@
+
+ removefromproduction
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
schedule
false
diff --git a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx
index 9b576b2e1..ca8f89860 100644
--- a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx
+++ b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx
@@ -112,6 +112,10 @@ export function JobChecklistForm({
scheduled_completion: job && job.scheduled_completion,
scheduled_delivery: job && job.scheduled_delivery,
}),
+ ...(type === "deliver" && {
+ removeFromProduction: true,
+ actual_completion: job && job.actual_completion,
+ }),
}}
>
{t("checklist.labels.checklist")}
diff --git a/client/src/components/jobs-change-status/jobs-change-status.component.jsx b/client/src/components/jobs-change-status/jobs-change-status.component.jsx
index b753419d7..01d7aa936 100644
--- a/client/src/components/jobs-change-status/jobs-change-status.component.jsx
+++ b/client/src/components/jobs-change-status/jobs-change-status.component.jsx
@@ -21,6 +21,7 @@ export function JobsChangeStatus({ job, bodyshop, jobRO }) {
const { t } = useTranslation();
const [availableStatuses, setAvailableStatuses] = useState([]);
+ const [otherStages, setOtherStages] = useState([]);
const [mutationUpdateJobstatus] = useMutation(UPDATE_JOB_STATUS);
const updateJobStatus = (status) => {
mutationUpdateJobstatus({
@@ -34,26 +35,41 @@ export function JobsChangeStatus({ job, bodyshop, jobRO }) {
notification["error"]({ message: t("jobs.errors.saving") });
});
};
+
useEffect(() => {
//Figure out what scenario were in, populate accodingly
if (job && bodyshop) {
- if (bodyshop.md_ro_statuses.pre_production_statuses.includes(job.status))
+ if (
+ bodyshop.md_ro_statuses.pre_production_statuses.includes(job.status)
+ ) {
setAvailableStatuses(bodyshop.md_ro_statuses.pre_production_statuses);
- else if (bodyshop.md_ro_statuses.production_statuses.includes(job.status))
+ if (bodyshop.md_ro_statuses.production_statuses[0])
+ setOtherStages([bodyshop.md_ro_statuses.production_statuses[0]]);
+ } else if (
+ bodyshop.md_ro_statuses.production_statuses.includes(job.status)
+ ) {
setAvailableStatuses(bodyshop.md_ro_statuses.production_statuses);
- else if (
+ setOtherStages([
+ bodyshop.md_ro_statuses.default_imported,
+ bodyshop.md_ro_statuses.default_delivered,
+ ]);
+ } else if (
bodyshop.md_ro_statuses.post_production_statuses.includes(job.status)
- )
+ ) {
setAvailableStatuses(bodyshop.md_ro_statuses.post_production_statuses);
- else {
+ if (bodyshop.md_ro_statuses.production_statuses[0])
+ setOtherStages([bodyshop.md_ro_statuses.production_statuses[0]]);
+ } else {
console.log(
"Status didn't match any restrictions. Allowing all status changes."
);
- setAvailableStatuses(bodyshop.statuses);
+ setAvailableStatuses(bodyshop.md_ro_statuses.statuses);
}
}
}, [job, setAvailableStatuses, bodyshop]);
+ console.log("availableStatuses", availableStatuses);
+ console.log("otherStages", otherStages);
const statusmenu = (
);
diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addtoproduction.util.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addtoproduction.util.jsx
index 4d23ac53f..0def7574c 100644
--- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addtoproduction.util.jsx
+++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addtoproduction.util.jsx
@@ -6,7 +6,8 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
export default function AddToProduction(
apolloClient,
jobId,
- completionCallback
+ completionCallback,
+ remove = false
) {
logImEXEvent("job_add_to_production");
@@ -14,17 +15,17 @@ export default function AddToProduction(
apolloClient
.mutate({
mutation: UPDATE_JOB,
- variables: { jobId: jobId, job: { inproduction: true } },
+ variables: { jobId: jobId, job: { inproduction: !remove } },
})
.then((res) => {
notification["success"]({
- message: i18n.t("jobs.successes.addedtoproduction"),
+ message: i18n.t("jobs.successes.save"),
});
if (completionCallback) completionCallback();
})
.catch((error) => {
notification["errors"]({
- message: i18n.t("jobs.errors.addingtoproduction", {
+ message: i18n.t("jobs.errors.saving", {
error: JSON.stringify(error),
}),
});
diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx
index dd211b331..4f5fb01ec 100644
--- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx
+++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx
@@ -128,13 +128,24 @@ export function JobsDetailHeaderActions({
{t("menus.jobsactions.newcccontract")}
- AddToProduction(client, job.id, refetch)}
- >
- {t("jobs.actions.addtoproduction")}
-
+ {job.inproduction ? (
+ AddToProduction(client, job.id, refetch, true)}
+ >
+ {t("jobs.actions.removefromproduction")}
+
+ ) : (
+ AddToProduction(client, job.id, refetch)}
+ >
+ {t("jobs.actions.addtoproduction")}
+
+ )}
+