From 786c7903073e4ed3fb0bcab4af46a82d20f13923 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 4 Aug 2023 12:28:08 -0700 Subject: [PATCH] WIP Tech Claiming Ability --- bodyshop_translations.babel | 47 ++++++ .../job-line-dispatch-button.component.jsx | 13 +- .../parts-dispatch-expander.component.jsx | 13 +- .../tech-sider/tech-sider.component.jsx | 15 +- client/src/graphql/parts-dispatch.queries.js | 49 ++++++ .../tech-dispatched-parts.page.jsx | 139 ++++++++++++++++++ client/src/pages/tech/tech.page.component.jsx | 8 + client/src/translations/en_us/common.json | 4 + client/src/translations/es/common.json | 4 + client/src/translations/fr/common.json | 4 + 10 files changed, 286 insertions(+), 10 deletions(-) create mode 100644 client/src/pages/tech-dispatched-parts/tech-dispatched-parts.page.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index bbf89d093..f5a1d8e48 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -33786,6 +33786,27 @@ tech + + dispatchedparts + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + home false @@ -35877,6 +35898,32 @@ parts_dispatch + + actions + + + accept + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + errors diff --git a/client/src/components/job-line-dispatch-button/job-line-dispatch-button.component.jsx b/client/src/components/job-line-dispatch-button/job-line-dispatch-button.component.jsx index 04b808932..50fdfee05 100644 --- a/client/src/components/job-line-dispatch-button/job-line-dispatch-button.component.jsx +++ b/client/src/components/job-line-dispatch-button/job-line-dispatch-button.component.jsx @@ -70,7 +70,7 @@ export function JobLineDispatchButton({ notification.open({ type: "error", message: t("parts_dispatch.errors.creating", { - error: JSON.stringify(result.errors), + error: result.errors, }), }); } else { @@ -79,7 +79,7 @@ export function JobLineDispatchButton({ { name: Templates.parts_dispatch.key, variables: { - id: result.data.insert_part_dispatch_one.id, + id: result.data.insert_parts_dispatch_one.id, }, }, {}, @@ -91,7 +91,7 @@ export function JobLineDispatchButton({ notification.open({ type: "error", message: t("parts_dispatch.errors.creating", { - error: JSON.stringify(error), + error: error, }), }); } finally { @@ -137,7 +137,12 @@ export function JobLineDispatchButton({ - + ), }, ]; return ( @@ -38,7 +41,7 @@ export default function PartsDispatchExpander({ dispatch, job }) { diff --git a/client/src/components/tech-sider/tech-sider.component.jsx b/client/src/components/tech-sider/tech-sider.component.jsx index c6ea4f67f..3cb3c261c 100644 --- a/client/src/components/tech-sider/tech-sider.component.jsx +++ b/client/src/components/tech-sider/tech-sider.component.jsx @@ -1,4 +1,8 @@ -import Icon, { SearchOutlined, ScheduleOutlined } from "@ant-design/icons"; +import Icon, { + SearchOutlined, + ScheduleOutlined, + CarOutlined, +} from "@ant-design/icons"; import { Layout, Menu } from "antd"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; @@ -68,6 +72,15 @@ export function TechSider({ technician, techLogout }) { }> {t("menus.tech.productionlist")} + } + > + + {t("menus.tech.dispatchedparts")} + + ({}); + +export function TechDispatchedParts({ technician, bodyshop }) { + const searchParams = queryString.parse(useLocation().search); + const { page } = searchParams; + + const { loading, error, data, refetch } = useQuery( + GET_UNACCEPTED_PARTS_DISPATCH, + { + variables: { + techId: technician.id, + offset: page ? (page - 1) * 25 : 0, + limit: 25, + }, + } + ); + + const { t } = useTranslation(); + const history = useHistory(); + + if (error) return ; + + const parts_dispatch = data?.parts_dispatch; + + const columns = [ + { + title: t("jobs.fields.ro_number"), + dataIndex: "job.ro_number", + key: "ro_number", + sorter: (a, b) => alphaSort(a.ro_number, b.ro_number), + + render: (text, record) => record.job.ro_number || t("general.labels.na"), + }, + { + title: t("jobs.fields.status"), + dataIndex: "status", + key: "status", + sorter: (a, b) => alphaSort(a.status, b.status), + render: (text, record) => { + return record.job.status || t("general.labels.na"); + }, + }, + + { + title: t("jobs.fields.vehicle"), + dataIndex: "vehicle", + key: "vehicle", + ellipsis: true, + render: (text, record) => ( + {`${record.job.v_model_yr || ""} ${ + record.job.v_make_desc || "" + } ${record.job.v_model_desc || ""}`} + ), + }, + { + title: t("general.labels.actions"), + dataIndex: "actions", + key: "actions", + render: (text, record) => ( + + ), + }, + ]; + const handleTableChange = (pagination, filters, sorter) => { + searchParams.page = pagination.current; + history.push({ search: queryString.stringify(searchParams) }); + }; + + return ( + + + + } + > +
( + + ), + rowExpandable: (record) => true, + //expandRowByClick: true, + expandIcon: ({ expanded, onExpand, record }) => + expanded ? ( + onExpand(record, e)} /> + ) : ( + onExpand(record, e)} /> + ), + }} + /> + + ); +} +export default connect( + mapStateToProps, + mapDispatchToProps +)(TechDispatchedParts); diff --git a/client/src/pages/tech/tech.page.component.jsx b/client/src/pages/tech/tech.page.component.jsx index f7639a473..d56ce6e09 100644 --- a/client/src/pages/tech/tech.page.component.jsx +++ b/client/src/pages/tech/tech.page.component.jsx @@ -34,6 +34,9 @@ const TechJobClock = lazy(() => const TechShiftClock = lazy(() => import("../tech-shift-clock/tech-shift-clock.component") ); +const TechDispatchedParts = lazy(() => + import("../tech-dispatched-parts/tech-dispatched-parts.page") +); const { Content } = Layout; @@ -98,6 +101,11 @@ export function TechPage({ technician, match }) { path={`${match.path}/board`} component={ProductionBoardPage} /> + diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index cd518d134..07533cf11 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1985,6 +1985,7 @@ "shops": "My Shops" }, "tech": { + "dispatchedparts": "Dispatched Parts", "home": "Home", "jobclockin": "Job Clock In", "jobclockout": "Job Clock Out", @@ -2126,6 +2127,9 @@ } }, "parts_dispatch": { + "actions": { + "accept": "Accept" + }, "errors": { "creating": "Error dispatching parts. {{error}}" }, diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index a95c8511f..0e38e3c01 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1985,6 +1985,7 @@ "shops": "Mis tiendas" }, "tech": { + "dispatchedparts": "", "home": "", "jobclockin": "", "jobclockout": "", @@ -2126,6 +2127,9 @@ } }, "parts_dispatch": { + "actions": { + "accept": "" + }, "errors": { "creating": "" }, diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index ded54b294..8c69db593 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1985,6 +1985,7 @@ "shops": "Mes boutiques" }, "tech": { + "dispatchedparts": "", "home": "", "jobclockin": "", "jobclockout": "", @@ -2126,6 +2127,9 @@ } }, "parts_dispatch": { + "actions": { + "accept": "" + }, "errors": { "creating": "" },