From 7ce7fbd79d3b090622dd10732808b75d9591cdb1 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 17 Feb 2021 15:40:10 -0800 Subject: [PATCH] Added vehicle alert changes and group verification. RPS-74 --- .../vehicle-group-alert.atom.jsx | 3 +- .../job-group/job-group.molecule.jsx | 44 ++++++++++++++++--- .../jobs-detail-description.molecule.jsx | 2 +- .../reporting-jobs-list.molecule.jsx | 15 +++++-- src/graphql/jobs.queries.js | 2 + 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/components/atoms/vehicle-group-alert/vehicle-group-alert.atom.jsx b/src/components/atoms/vehicle-group-alert/vehicle-group-alert.atom.jsx index e652f95..509a337 100644 --- a/src/components/atoms/vehicle-group-alert/vehicle-group-alert.atom.jsx +++ b/src/components/atoms/vehicle-group-alert/vehicle-group-alert.atom.jsx @@ -30,7 +30,8 @@ const models = [ ]; export default function VehicleGroupAlertAtom({ job, showGroup = false }) { - const shouldWarn = models.includes(job.v_model.toLowerCase()); + const shouldWarn = + models.includes(job.v_model.toLowerCase()) && !job.group_verified; const vehicleText = `${job.v_model_yr} ${job.v_makedesc} ${job.v_model} (${ job.v_type diff --git a/src/components/molecules/job-group/job-group.molecule.jsx b/src/components/molecules/job-group/job-group.molecule.jsx index ef5e368..56313f0 100644 --- a/src/components/molecules/job-group/job-group.molecule.jsx +++ b/src/components/molecules/job-group/job-group.molecule.jsx @@ -1,13 +1,18 @@ -import { DownOutlined, LoadingOutlined } from "@ant-design/icons"; +import { + AlertFilled, + DownOutlined, + LoadingOutlined, + CloseOutlined, + CheckOutlined, +} from "@ant-design/icons"; import { useMutation } from "@apollo/client"; -import { Dropdown, Menu, message } from "antd"; +import { Dropdown, Menu, message, Space, Switch } from "antd"; import React, { useState } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { UPDATE_JOB } from "../../../graphql/jobs.queries"; import ipcTypes from "../../../ipc.types"; import { selectBodyshop } from "../../../redux/user/user.selectors"; -import { AlertFilled } from "@ant-design/icons"; import JobsGroupModalMolecule from "../jobs-group-modal/jobs-group-modal.molecule"; const { ipcRenderer } = window; @@ -44,6 +49,20 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) { setLoading(false); }; + const handleVerifyGroup = async (val) => { + setLoading(true); + const result = await updateJob({ + variables: { jobId: jobId, job: { group_verified: val } }, + }); + + if (!result.errors) { + message.success("Vehicle group updated."); + } else { + message.error("Error updating job."); + } + setLoading(false); + }; + const menu = ( {bodyshop.groups.map((g, idx) => ( @@ -53,21 +72,32 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) { ); return ( - <> + e.preventDefault()}> {group} - {loading && } - {!group && (
No group set.
)} - + {group && ( +
+ } + unCheckedChildren={} + disabled={loading} + defaultChecked={job.group_verified} + onChange={handleVerifyGroup} + /> +
+ )} + + {loading && } +
); } diff --git a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx index 43601a2..413b611 100644 --- a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx +++ b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx @@ -43,7 +43,7 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) { - Ready for Payment Date + R4P Date } > diff --git a/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx b/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx index 3733240..77c37d4 100644 --- a/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx +++ b/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx @@ -1,4 +1,4 @@ -import { Input, Table } from "antd"; +import { Input, Table, Checkbox } from "antd"; import moment from "moment"; import React, { useState } from "react"; import { connect } from "react-redux"; @@ -46,7 +46,7 @@ export function ReportingJobsListMolecule({ sorter: (a, b) => alphaSort(a.clm_no, b.clm_no), }, { - title: "Ready for Payment Date", + title: "R4P", dataIndex: "close_date", key: "close_date", render: (text, record) => moment(record.close_date).format("MM/DD/yyyy"), @@ -88,12 +88,21 @@ export function ReportingJobsListMolecule({ render: (text, record) => record.dbPriceSum.toFormat(), }, { - title: "Actual Price Sum ", + title: "Actual Price Sum", dataIndex: "actPriceSum", key: "actPriceSum", sorter: (a, b) => a.actPriceSum.getAmount() - b.actPriceSum.getAmount(), render: (text, record) => record.actPriceSum.toFormat(), }, + { + title: "Group Verified?", + dataIndex: "group_verified", + key: "group_verified", + sorter: (a, b) => a.group_verified - b.group_verified, + render: (text, record) => ( + + ), + }, { title: "$ (Act./Target)", dataIndex: "jobRpsDollars", diff --git a/src/graphql/jobs.queries.js b/src/graphql/jobs.queries.js index b2b0c52..0c2bc0c 100644 --- a/src/graphql/jobs.queries.js +++ b/src/graphql/jobs.queries.js @@ -154,6 +154,8 @@ export const UPDATE_JOB = gql` updated_at close_date v_age + group + group_verified joblines(order_by: { unq_seq: asc }) { id act_price