From 94353bb342085f0b3f54e96a66ea0dc861717da2 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Wed, 12 Jul 2023 09:42:03 -0700 Subject: [PATCH] IO-2170 Job Status change on Job Clock Out --- .../tech-job-clock-out-button.component.jsx | 50 +++++++++++++++++-- client/src/graphql/jobs-lines.queries.js | 1 + 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/client/src/components/tech-job-clock-out-button/tech-job-clock-out-button.component.jsx b/client/src/components/tech-job-clock-out-button/tech-job-clock-out-button.component.jsx index 5c0830d5e..6fb221e7d 100644 --- a/client/src/components/tech-job-clock-out-button/tech-job-clock-out-button.component.jsx +++ b/client/src/components/tech-job-clock-out-button/tech-job-clock-out-button.component.jsx @@ -5,10 +5,10 @@ import { Col, Form, InputNumber, - notification, Popover, Row, Select, + notification, } from "antd"; import axios from "axios"; import React, { useState } from "react"; @@ -16,13 +16,14 @@ import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { logImEXEvent } from "../../firebase/firebase.utils"; +import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries"; +import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries"; import { UPDATE_TIME_TICKET } from "../../graphql/timetickets.queries"; import { selectTechnician } from "../../redux/tech/tech.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import { CalculateAllocationsTotals } from "../labor-allocations-table/labor-allocations-table.utility"; import TechJobClockoutDelete from "../tech-job-clock-out-delete/tech-job-clock-out-delete.component"; import { LaborAllocationContainer } from "../time-ticket-modal/time-ticket-modal.component"; -import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries"; -import { CalculateAllocationsTotals } from "../labor-allocations-table/labor-allocations-table.utility"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -40,6 +41,7 @@ export function TechClockOffButton({ }) { const [loading, setLoading] = useState(false); const [updateTimeticket] = useMutation(UPDATE_TIME_TICKET); + const [updateJobStatus] = useMutation(UPDATE_JOB_STATUS); const [form] = Form.useForm(); const { queryLoading, data: lineTicketData } = useQuery( GET_LINE_TICKET_BY_PK, @@ -59,7 +61,8 @@ export function TechClockOffButton({ const handleFinish = async (values) => { logImEXEvent("tech_clock_out_job"); - + const status = values.status; + delete values.status; setLoading(true); const result = await updateTimeticket({ variables: { @@ -98,6 +101,25 @@ export function TechClockOffButton({ message: t("timetickets.successes.clockedout"), }); } + + const job_update_result = await updateJobStatus({ + variables: { + jobId: jobId, + status: status, + }, + }); + + if (!!job_update_result.errors) { + notification["error"]({ + message: t("jobs.errors.updating", { + message: JSON.stringify(result.errors), + }), + }); + } else { + notification["success"]({ + message: t("jobs.successes.updated"), + }); + } setLoading(false); if (completedCallback) completedCallback(); }; @@ -228,6 +250,26 @@ export function TechClockOffButton({ + + + + diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index 1600d5082..05af1fba4 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -34,6 +34,7 @@ export const GET_LINE_TICKET_BY_PK = gql` id lbr_adjustments converted + status } joblines(where: { jobid: { _eq: $id }, removed: { _eq: false } }) { id