diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index 7c3751b03..00f279a66 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -18,6 +18,7 @@ import ProductionListLastContacted from "./production-list-columns.lastcontacted import ProductionListColumnPaintPriority from "./production-list-columns.paintpriority.component"; import ProductionListColumnNote from "./production-list-columns.productionnote.component"; import ProductionListColumnStatus from "./production-list-columns.status.component"; +import ProductionListColumnCategory from "./production-list-columns.status.category"; import ProductionlistColumnTouchTime from "./prodution-list-columns.touchtime.component"; const r = ({ technician, state, activeStatuses, bodyshop }) => { @@ -251,6 +252,29 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { state.sortedInfo.columnKey === "status" && state.sortedInfo.order, render: (text, record) => , }, + { + title: i18n.t("jobs.fields.category"), + dataIndex: "category", + key: "category", + ellipsis: true, + + filters: + (bodyshop && + bodyshop.md_categories.map((s) => { + return { + text: s, + value: [s], + }; + })) || + [], + onFilter: (value, record) => value.includes(record.category), + sorter: (a, b) => alphaSort(a.category, b.category), + sortOrder: + state.sortedInfo.columnKey === "category" && state.sortedInfo.order, + render: (text, record) => ( + + ), + }, { title: i18n.t("production.labels.bodyhours"), dataIndex: "labhrs", diff --git a/client/src/components/production-list-columns/production-list-columns.status.category.jsx b/client/src/components/production-list-columns/production-list-columns.status.category.jsx new file mode 100644 index 000000000..115b69a3f --- /dev/null +++ b/client/src/components/production-list-columns/production-list-columns.status.category.jsx @@ -0,0 +1,63 @@ +import { useMutation } from "@apollo/client"; +import { Dropdown, Menu, Spin } from "antd"; +import React, { useState } from "react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.utils"; +import { UPDATE_JOB } from "../../graphql/jobs.queries"; +import { insertAuditTrail } from "../../redux/application/application.actions"; +import { selectBodyshop } from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + insertAuditTrail: ({ jobid, operation }) => + dispatch(insertAuditTrail({ jobid, operation })), +}); +export function ProductionListColumnCategory({ record, bodyshop }) { + const [updateJob] = useMutation(UPDATE_JOB); + const [loading, setLoading] = useState(false); + + const handleSetStatus = async (e) => { + logImEXEvent("production_change_status"); + + setLoading(true); + const { key } = e; + await updateJob({ + variables: { + jobId: record.id, + job: { + category: key, + }, + }, + }); + + setLoading(false); + }; + + return ( + + {bodyshop.md_categories.map((item) => ( + {item} + ))} + + } + trigger={["click"]} + > +
+ {record.category} + {loading && } +
+
+ ); +} +export default connect( + mapStateToProps, + mapDispatchToProps +)(ProductionListColumnCategory); diff --git a/client/src/components/production-list-table/production-list-table.component.jsx b/client/src/components/production-list-table/production-list-table.component.jsx index dd2c5fc32..56278c1fc 100644 --- a/client/src/components/production-list-table/production-list-table.component.jsx +++ b/client/src/components/production-list-table/production-list-table.component.jsx @@ -88,6 +88,12 @@ export function ProductionListTable({ ); const handleTableChange = (pagination, filters, sorter) => { + console.log( + "🚀 ~ file: production-list-table.component.jsx ~ line 91 ~ pagination, filters, sorter", + pagination, + filters, + sorter + ); setState({ ...state, filteredInfo: filters, @@ -263,8 +269,10 @@ export function ProductionListTable({ }, }} columns={columns.map((c, index) => { + console.log(c); return { ...c, + filteredValue: state.filteredInfo[c.key] || null, sortOrder: state.sortedInfo.columnKey === c.key && state.sortedInfo.order, title: headerItem(c), diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js index e3a48640c..7dfb88012 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js @@ -25,15 +25,20 @@ export function ScheduleCalendarHeaderGraph({ bodyshop, loadData }) { const { ssbuckets } = bodyshop; const data = useMemo(() => { - return Object.keys(loadData.expectedLoad).map((key) => { - const metadataBucket = ssbuckets.filter((b) => b.id === key)[0]; + return ( + (loadData && + loadData.expectedLoad && + Object.keys(loadData.expectedLoad).map((key) => { + const metadataBucket = ssbuckets.filter((b) => b.id === key)[0]; - return { - bucket: loadData.expectedLoad[key].label, - current: loadData.expectedLoad[key].count, - target: metadataBucket && metadataBucket.target, - }; - }); + return { + bucket: loadData.expectedLoad[key].label, + current: loadData.expectedLoad[key].count, + target: metadataBucket && metadataBucket.target, + }; + })) || + [] + ); }, [loadData, ssbuckets]); const popContent = ( diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 6ff600dce..999d56224 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -123,6 +123,7 @@ export const QUERY_EXACT_JOB_IN_PRODUCTION = gql` ro_number ownr_fn ownr_ln + category ownr_co_nm v_model_yr v_model_desc @@ -193,6 +194,7 @@ export const QUERY_EXACT_JOBS_IN_PRODUCTION = gql` status ro_number ownr_fn + category ownr_ln ownr_co_nm v_model_yr @@ -263,6 +265,7 @@ export const QUERY_JOBS_IN_PRODUCTION = gql` id updated_at status + category ro_number ownr_fn ownr_ln