From 5540872f62ccf115fa5f8de8149386e7e8df01b8 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 17 Nov 2021 20:18:21 -0800 Subject: [PATCH] IO-1531 CC Contract add to production. --- .../contract-form/contract-form.component.jsx | 3 +- .../contract-create.page.component.jsx | 30 +++++++++++++------ .../contract-create.page.container.jsx | 27 ++++++++++++++++- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/client/src/components/contract-form/contract-form.component.jsx b/client/src/components/contract-form/contract-form.component.jsx index acf1b53fd..803fd59d0 100644 --- a/client/src/components/contract-form/contract-form.component.jsx +++ b/client/src/components/contract-form/contract-form.component.jsx @@ -1,5 +1,5 @@ import { WarningFilled } from "@ant-design/icons"; -import { Form, Input, InputNumber, Space } from "antd"; +import { Form, Input, InputNumber, Space, Switch } from "antd"; import moment from "moment"; import React from "react"; import { useTranslation } from "react-i18next"; @@ -42,7 +42,6 @@ export default function ContractFormComponent({ )} - form.submit()} - loading={loading} - > - {t("general.actions.create")} - + + {selectedJobState[0] && selectedCarState[0] && ( + + + + )} + + ); return ( diff --git a/client/src/pages/contract-create/contract-create.page.container.jsx b/client/src/pages/contract-create/contract-create.page.container.jsx index 95d31e486..7ab35f1c5 100644 --- a/client/src/pages/contract-create/contract-create.page.container.jsx +++ b/client/src/pages/contract-create/contract-create.page.container.jsx @@ -7,6 +7,7 @@ import { useHistory, useLocation } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import { INSERT_NEW_CONTRACT } from "../../graphql/cccontracts.queries"; +import { UPDATE_JOB } from "../../graphql/jobs.queries"; import { setBreadcrumbs, setSelectedHeader, @@ -37,8 +38,9 @@ export function ContractCreatePageContainer({ (location.state && location.state.jobId) || null ); const [insertContract] = useMutation(INSERT_NEW_CONTRACT); + const [intakeJob] = useMutation(UPDATE_JOB); - const handleFinish = async (values) => { + const handleFinish = async ({ addtoproduction, ...values }) => { if (!!selectedCarState[0] && !!selectedJobState[0]) { setLoading(true); const result = await insertContract({ @@ -54,12 +56,35 @@ export function ContractCreatePageContainer({ }, }, }); + if (!result.errors) { //Update the courtesy car to have the damage. notification["success"]({ message: t("contracts.successes.saved"), }); + //Intake the job if required + if (addtoproduction) { + const result2 = await intakeJob({ + variables: { + jobId: selectedJobState[0], + job: { + actual_in: new Date(), + inproduction: true, + status: bodyshop.md_ro_statuses.default_arrived, + }, + }, + }); + if (result2.errors) { + notification["error"]({ + message: t("jobs.errors.saving", { + error: JSON.stringify(!result2.errors), + }), + }); + return; + } + } + form.resetFields(); form.resetFields(); history.push(