diff --git a/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx b/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx index f81a77d25..88bd2ec7e 100644 --- a/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx +++ b/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx @@ -6,7 +6,7 @@ import { PauseCircleOutlined } from "@ant-design/icons"; import { Card, Col, Row, Space, Tooltip } from "antd"; -import React, { useMemo } from "react"; +import React, { useMemo, useCallback } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import { DateTimeFormatter } from "../../utils/DateFormatter"; @@ -26,14 +26,7 @@ import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.c */ const cardColor = (ssbuckets, totalHrs) => { const bucket = ssbuckets.find((bucket) => bucket.gte <= totalHrs && (!bucket.lt || bucket.lt > totalHrs)); - - let color = { r: 255, g: 255, b: 255 }; - - if (bucket && bucket.color) { - color = bucket.color.rgb || bucket.color; - } - - return color; + return bucket && bucket.color ? bucket.color.rgb || bucket.color : { r: 255, g: 255, b: 255 }; }; /** @@ -56,31 +49,32 @@ const getContrastYIQ = (bgColor) => export default function ProductionBoardCard({ technician, card, bodyshop, cardSettings }) { const { t } = useTranslation(); - let employee_body, employee_prep, employee_refinish, employee_csr; - - // Destructure metadata const { metadata } = card; - if (metadata?.employee_body) { - employee_body = bodyshop.employees.find((e) => e.id === metadata.employee_body); - } - if (metadata?.employee_prep) { - employee_prep = bodyshop.employees.find((e) => e.id === metadata.employee_prep); - } - if (metadata?.employee_refinish) { - employee_refinish = bodyshop.employees.find((e) => e.id === metadata.employee_refinish); - } - if (metadata?.employee_csr) { - employee_csr = bodyshop.employees.find((e) => e.id === metadata.employee_csr); - } - // if (metadata.?employee_csr) { - // employee_csr = bodyshop.employees.find((e) => e.id === metadata.employee_csr); - // } + const employee_body = useMemo( + () => metadata?.employee_body && bodyshop.employees.find((e) => e.id === metadata.employee_body), + [metadata?.employee_body, bodyshop.employees] + ); + const employee_prep = useMemo( + () => metadata?.employee_prep && bodyshop.employees.find((e) => e.id === metadata.employee_prep), + [metadata?.employee_prep, bodyshop.employees] + ); + const employee_refinish = useMemo( + () => metadata?.employee_refinish && bodyshop.employees.find((e) => e.id === metadata.employee_refinish), + [metadata?.employee_refinish, bodyshop.employees] + ); + const employee_csr = useMemo( + () => metadata?.employee_csr && bodyshop.employees.find((e) => e.id === metadata.employee_csr), + [metadata?.employee_csr, bodyshop.employees] + ); - const pastDueAlert = - !!metadata?.scheduled_completion && - ((dayjs().isSameOrAfter(dayjs(metadata.scheduled_completion), "day") && "production-completion-past") || - (dayjs().add(1, "day").isSame(dayjs(metadata.scheduled_completion), "day") && "production-completion-soon")); + const pastDueAlert = useMemo(() => { + if (!metadata?.scheduled_completion) return null; + const completionDate = dayjs(metadata.scheduled_completion); + if (dayjs().isSameOrAfter(completionDate, "day")) return "production-completion-past"; + if (dayjs().add(1, "day").isSame(completionDate, "day")) return "production-completion-soon"; + return null; + }, [metadata?.scheduled_completion]); const totalHrs = useMemo(() => { return metadata?.labhrs && metadata?.larhrs @@ -125,9 +119,9 @@ export default function ProductionBoardCard({ technician, card, bodyshop, cardSe } > - {cardSettings && cardSettings.ownr_nm && ( + {cardSettings?.ownr_nm && ( - {cardSettings && cardSettings.compact ? ( + {cardSettings.compact ? (
{`${metadata.ownr_ln || ""} ${metadata.ownr_co_nm || ""}`}
) : (
@@ -136,97 +130,79 @@ export default function ProductionBoardCard({ technician, card, bodyshop, cardSe )} )} - {cardSettings && cardSettings.model_info && ( + {cardSettings?.model_info && ( -
{`${metadata.v_model_yr || ""} ${ - metadata.v_make_desc || "" - } ${metadata.v_model_desc || ""}`}
+
{`${metadata.v_model_yr || ""} ${metadata.v_make_desc || ""} ${metadata.v_model_desc || ""}`}
)} - - {cardSettings && cardSettings.ins_co_nm && metadata.ins_co_nm && ( - + {cardSettings?.ins_co_nm && metadata.ins_co_nm && ( +
{metadata.ins_co_nm || ""}
)} - {cardSettings && cardSettings.clm_no && metadata.clm_no && ( - + {cardSettings?.clm_no && metadata.clm_no && ( +
{metadata.clm_no || ""}
)} - - {cardSettings && cardSettings.employeeassignments && ( + {cardSettings?.employeeassignments && ( - {`B: ${ + {`B: ${ employee_body ? `${employee_body.first_name.substr(0, 3)} ${employee_body.last_name.charAt(0)}` : "" } ${metadata.labhrs.aggregate.sum.mod_lb_hrs || "?"}h`} - {`P: ${ + {`P: ${ employee_prep ? `${employee_prep.first_name.substr(0, 3)} ${employee_prep.last_name.charAt(0)}` : "" }`} - {`R: ${ + {`R: ${ employee_refinish ? `${employee_refinish.first_name.substr(0, 3)} ${employee_refinish.last_name.charAt(0)}` : "" } ${metadata.larhrs.aggregate.sum.mod_lb_hrs || "?"}h`} - {`C: ${ + {`C: ${ employee_csr ? `${employee_csr.first_name} ${employee_csr.last_name}` : "" }`} )} - {/* {cardSettings && cardSettings.laborhrs && ( - - - {`B: ${ - metadata.labhrs.aggregate.sum.mod_lb_hrs || "?" - } hrs`} - {`R: ${ - metadata.larhrs.aggregate.sum.mod_lb_hrs || "?" - } hrs`} - - - )} */} - {cardSettings && cardSettings.actual_in && metadata.actual_in && ( - + {cardSettings?.actual_in && metadata.actual_in && ( + {metadata.actual_in} )} - {cardSettings && cardSettings.scheduled_completion && metadata.scheduled_completion && ( - + {cardSettings?.scheduled_completion && metadata.scheduled_completion && ( + {metadata.scheduled_completion} )} - {cardSettings && cardSettings.ats && metadata.alt_transport && ( + {cardSettings?.ats && metadata.alt_transport && (
{metadata.alt_transport || ""}
)} - {cardSettings && cardSettings.sublets && ( + {cardSettings?.sublets && ( )} - {cardSettings && cardSettings.production_note && ( + {cardSettings?.production_note && ( - {cardSettings && cardSettings.production_note && ( - - )} + )} - {cardSettings && cardSettings.partsstatus && ( + {cardSettings?.partsstatus && ( diff --git a/client/src/components/production-board-kanban/production-board-kanban.utils.js b/client/src/components/production-board-kanban/production-board-kanban.utils.js index a10446928..61519d007 100644 --- a/client/src/components/production-board-kanban/production-board-kanban.utils.js +++ b/client/src/components/production-board-kanban/production-board-kanban.utils.js @@ -1,5 +1,5 @@ import { groupBy } from "lodash"; -import fakeData from "./testData/board600.json"; +import fakeData from "./testData/board1200.json"; const sortByParentId = (arr) => { // return arr.reduce((accumulator, currentValue) => { diff --git a/client/src/components/trello-board/controllers/Lane.jsx b/client/src/components/trello-board/controllers/Lane.jsx index 8725cccb2..7ba4391d1 100644 --- a/client/src/components/trello-board/controllers/Lane.jsx +++ b/client/src/components/trello-board/controllers/Lane.jsx @@ -177,6 +177,7 @@ const Lane = ({ const Card = React.memo(({ provided, item: card, isDragging }) => { const onDeleteCard = () => removeCard(card.id); + return (
( - - {(provided, snapshot) => } - - ); + const renderDraggable = (index, item) => { + if (!item) { + console.log("null Item"); + return null; + } + + return ( + + {(provided, snapshot) => } + + ); + }; const renderAddCardLink = useCallback( () => editable && !addCardMode && , @@ -231,44 +239,13 @@ const Lane = ({ style={{ display: "flex", flex: 1, - whiteSpace: "wrap" + whiteSpace: "nowrap" }} > {children}
); - /** - * Components for the grid layout - * @type {{Item: (function({children: *, [p: string]: *}): *), List: React.ForwardRefExoticComponent & React.RefAttributes>}} - */ - const gridComponents = { - List: forwardRef(({ style, children, ...props }, ref) => ( -
- {children} -
- )), - Item: ({ children, ...props }) => ( -
- {children} -
- ) - }; - /** * Render the droppable component with the provided cards and the provided props from react-beautiful-dnd * @param provided @@ -291,7 +268,35 @@ const Lane = ({ scrollerRef: provided.innerRef, listClassName: "grid-container", itemClassName: "grid-item", - components: gridComponents, + components: { + List: forwardRef(({ style, children, ...props }, ref) => ( +
+ {children} +
+ )), + Item: ({ children, ...props }) => ( +
+ {children} +
+ ) + }, itemContent: (index, item) => {renderDraggable(index, item)} } : { @@ -306,16 +311,18 @@ const Lane = ({ }; const finalComponentProps = collapsed ? {} : componentProps; return ( -
- +
+
+ + {provided.placeholder} +
{renderAddCardLink()} {renderNewCardForm()} - {provided.placeholder}
); }; diff --git a/client/src/components/trello-board/styles/Base.js b/client/src/components/trello-board/styles/Base.js index 775e9589d..c313e73e2 100644 --- a/client/src/components/trello-board/styles/Base.js +++ b/client/src/components/trello-board/styles/Base.js @@ -101,7 +101,8 @@ export const StyleVertical = styled.div` .react-trello-card { flex: 0 1 auto; - min-width: 120px; + width: auto; + height: auto; } .react-trello-board {