IO-1491 Simplify production query to use ignore employee relationships and match locally.
This commit is contained in:
@@ -82,7 +82,6 @@ function Header({
|
|||||||
setReportCenterContext,
|
setReportCenterContext,
|
||||||
recentItems,
|
recentItems,
|
||||||
}) {
|
}) {
|
||||||
console.log("🚀 ~ file: header.component.jsx ~ line 85 ~ bodyshop", bodyshop);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import ProductionSubletsManageComponent from "../production-sublets-manage/production-sublets-manage.component";
|
import ProductionSubletsManageComponent from "../production-sublets-manage/production-sublets-manage.component";
|
||||||
import ProductionListColumnProductionNote from "../production-list-columns/production-list-columns.productionnote.component";
|
import ProductionListColumnProductionNote from "../production-list-columns/production-list-columns.productionnote.component";
|
||||||
|
|
||||||
export default function ProductionBoardCard(technician, card) {
|
export default function ProductionBoardCard(technician, card, bodyshop) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const menu = (
|
const menu = (
|
||||||
<div>
|
<div>
|
||||||
@@ -19,6 +19,21 @@ export default function ProductionBoardCard(technician, card) {
|
|||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
let employee_body, employee_prep, employee_refinish, employee_csr;
|
||||||
|
if (card.employee_body) {
|
||||||
|
employee_body = bodyshop.employees.find((e) => e.id === card.employee_body);
|
||||||
|
}
|
||||||
|
if (card.employee_prep) {
|
||||||
|
employee_prep = bodyshop.employees.find((e) => e.id === card.employee_prep);
|
||||||
|
}
|
||||||
|
if (card.employee_refinish) {
|
||||||
|
employee_refinish = bodyshop.employees.find(
|
||||||
|
(e) => e.id === card.employee_refinish
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (card.employee_csr) {
|
||||||
|
employee_csr = bodyshop.employees.find((e) => e.id === card.employee_csr);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown overlay={menu} trigger={["contextMenu"]}>
|
<Dropdown overlay={menu} trigger={["contextMenu"]}>
|
||||||
@@ -53,23 +68,23 @@ export default function ProductionBoardCard(technician, card) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="mex-flex-row__margin">
|
<div className="mex-flex-row__margin">
|
||||||
<div>{`B: ${
|
<div>{`B: ${
|
||||||
card.employee_body_rel
|
employee_body
|
||||||
? `${card.employee_body_rel.first_name} ${card.employee_body_rel.last_name}`
|
? `${employee_body.first_name} ${employee_body.last_name}`
|
||||||
: ""
|
: ""
|
||||||
}`}</div>
|
}`}</div>
|
||||||
<div>{`P: ${
|
<div>{`P: ${
|
||||||
card.employee_prep_rel
|
employee_prep
|
||||||
? `${card.employee_prep_rel.first_name} ${card.employee_prep_rel.last_name}`
|
? `${employee_prep.first_name} ${employee_prep.last_name}`
|
||||||
: ""
|
: ""
|
||||||
}`}</div>
|
}`}</div>
|
||||||
<div>{`R: ${
|
<div>{`R: ${
|
||||||
card.employee_refinish_rel
|
employee_refinish
|
||||||
? `${card.employee_refinish_rel.first_name} ${card.employee_refinish_rel.last_name}`
|
? `${employee_refinish.first_name} ${employee_refinish.last_name}`
|
||||||
: ""
|
: ""
|
||||||
}`}</div>
|
}`}</div>
|
||||||
<div>{`CSR: ${
|
<div>{`CSR: ${
|
||||||
card.employee_csr_rel
|
employee_csr
|
||||||
? `${card.employee_csr_rel.first_name} ${card.employee_csr_rel.last_name}`
|
? `${employee_csr.first_name} ${employee_csr.last_name}`
|
||||||
: ""
|
: ""
|
||||||
}`}</div>
|
}`}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ export function ProductionBoardKanbanComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const totalHrs = data
|
const totalHrs = data
|
||||||
.reduce(
|
.reduce(
|
||||||
(acc, val) =>
|
(acc, val) =>
|
||||||
acc +
|
acc +
|
||||||
(val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) +
|
(val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) +
|
||||||
(val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0),
|
(val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
.toFixed(1);
|
.toFixed(1);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<IndefiniteLoading loading={isMoving} />
|
<IndefiniteLoading loading={isMoving} />
|
||||||
@@ -167,7 +167,7 @@ export function ProductionBoardKanbanComponent({
|
|||||||
<Board
|
<Board
|
||||||
children={boardLanes}
|
children={boardLanes}
|
||||||
disableCardDrag={isMoving}
|
disableCardDrag={isMoving}
|
||||||
renderCard={(card) => ProductionBoardCard(technician, card)}
|
renderCard={(card) => ProductionBoardCard(technician, card, bodyshop)}
|
||||||
onCardDragEnd={handleDragEnd}
|
onCardDragEnd={handleDragEnd}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ const r = ({ technician, state, activeStatuses }) => {
|
|||||||
: "",
|
: "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProductionListDate record={record} field="date_next_contact" time/>
|
<ProductionListDate record={record} field="date_next_contact" time />
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -356,7 +356,7 @@ const r = ({ technician, state, activeStatuses }) => {
|
|||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<ProductionListEmployeeAssignment
|
<ProductionListEmployeeAssignment
|
||||||
record={record}
|
record={record}
|
||||||
type="employee_body_rel"
|
type="employee_body"
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -367,7 +367,7 @@ const r = ({ technician, state, activeStatuses }) => {
|
|||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<ProductionListEmployeeAssignment
|
<ProductionListEmployeeAssignment
|
||||||
record={record}
|
record={record}
|
||||||
type="employee_prep_rel"
|
type="employee_prep"
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -376,10 +376,7 @@ const r = ({ technician, state, activeStatuses }) => {
|
|||||||
dataIndex: "employee_csr",
|
dataIndex: "employee_csr",
|
||||||
key: "employee_csr",
|
key: "employee_csr",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<ProductionListEmployeeAssignment
|
<ProductionListEmployeeAssignment record={record} type="employee_csr" />
|
||||||
record={record}
|
|
||||||
type="employee_csr_rel"
|
|
||||||
/>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -389,7 +386,7 @@ const r = ({ technician, state, activeStatuses }) => {
|
|||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<ProductionListEmployeeAssignment
|
<ProductionListEmployeeAssignment
|
||||||
record={record}
|
record={record}
|
||||||
type="employee_refinish_rel"
|
type="employee_refinish"
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export function ProductionListEmpAssignment({
|
|||||||
const result = await updateJob({
|
const result = await updateJob({
|
||||||
variables: { jobId: record.id, job: { [empAssignment]: employeeid } },
|
variables: { jobId: record.id, job: { [empAssignment]: employeeid } },
|
||||||
|
|
||||||
awaitRefetchQueries: true,
|
// awaitRefetchQueries: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
insertAuditTrail({
|
insertAuditTrail({
|
||||||
@@ -145,13 +145,18 @@ export function ProductionListEmpAssignment({
|
|||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let theEmployee;
|
||||||
|
|
||||||
|
if (record[type])
|
||||||
|
theEmployee = bodyshop.employees.find((e) => e.id === record[type]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover destroyTooltipOnHide content={popContent} visible={visibility}>
|
<Popover destroyTooltipOnHide content={popContent} visible={visibility}>
|
||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
{record[type] ? (
|
{record[type] ? (
|
||||||
<div>
|
<div>
|
||||||
<span>{`${record[type].first_name || ""} ${
|
<span>{`${theEmployee.first_name || ""} ${
|
||||||
record[type].last_name || ""
|
theEmployee.last_name || ""
|
||||||
}`}</span>
|
}`}</span>
|
||||||
<DeleteFilled
|
<DeleteFilled
|
||||||
style={iconStyle}
|
style={iconStyle}
|
||||||
@@ -174,13 +179,13 @@ export function ProductionListEmpAssignment({
|
|||||||
|
|
||||||
const determineFieldName = (operation) => {
|
const determineFieldName = (operation) => {
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case "employee_body_rel":
|
case "employee_body":
|
||||||
return "employee_body";
|
return "employee_body";
|
||||||
case "employee_prep_rel":
|
case "employee_prep":
|
||||||
return "employee_prep";
|
return "employee_prep";
|
||||||
case "employee_refinish_rel":
|
case "employee_refinish":
|
||||||
return "employee_refinish";
|
return "employee_refinish";
|
||||||
case "employee_csr_rel":
|
case "employee_csr":
|
||||||
return "employee_csr";
|
return "employee_csr";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -135,39 +135,10 @@ export const SUBSCRIPTION_JOBS_IN_PRODUCTION = gql`
|
|||||||
production_vars
|
production_vars
|
||||||
kanbanparent
|
kanbanparent
|
||||||
alt_transport
|
alt_transport
|
||||||
joblines_status {
|
|
||||||
part_type
|
|
||||||
count
|
|
||||||
status
|
|
||||||
}
|
|
||||||
employee_body
|
employee_body
|
||||||
employee_body_rel {
|
|
||||||
id
|
|
||||||
first_name
|
|
||||||
last_name
|
|
||||||
}
|
|
||||||
employee_refinish
|
employee_refinish
|
||||||
employee_refinish_rel {
|
|
||||||
id
|
|
||||||
first_name
|
|
||||||
last_name
|
|
||||||
}
|
|
||||||
employee_prep
|
employee_prep
|
||||||
employee_prep_rel {
|
employee_csr
|
||||||
id
|
|
||||||
first_name
|
|
||||||
last_name
|
|
||||||
}
|
|
||||||
employee_csr_rel {
|
|
||||||
id
|
|
||||||
first_name
|
|
||||||
last_name
|
|
||||||
}
|
|
||||||
partcount: joblines_aggregate(where: { removed: { _eq: false } }) {
|
|
||||||
nodes {
|
|
||||||
status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
labhrs: joblines_aggregate(
|
labhrs: joblines_aggregate(
|
||||||
where: {
|
where: {
|
||||||
_and: [{ mod_lbr_ty: { _neq: "LAR" } }, { removed: { _eq: false } }]
|
_and: [{ mod_lbr_ty: { _neq: "LAR" } }, { removed: { _eq: false } }]
|
||||||
|
|||||||
Reference in New Issue
Block a user