From 04509fa587d6f16d016eba8a0540698370b19cef Mon Sep 17 00:00:00 2001 From: swtmply Date: Sat, 6 May 2023 04:56:03 +0800 Subject: [PATCH] IO-1722 adjusted logic for card color --- ...tion-board-kanban-card-color-legend.component.jsx | 9 ++++++--- .../production-board-kanban-card.component.jsx | 12 +++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx b/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx index 15b33ccc4..d7b763939 100644 --- a/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx +++ b/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx @@ -7,10 +7,13 @@ const CardColorLegend = ({ bodyshop }) => { const data = bodyshop.ssbuckets.map((bucket) => { let color = { r: 255, g: 255, b: 255 }; - if (bucket.color.rgb) { - color = bucket.color.rgb; + if (bucket.color) { + color = bucket.color; + + if (bucket.color.rgb) { + color = bucket.color.rgb; + } } - color = bucket.color; // default to white return { label: bucket.label, 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 7f59eadc4..dca5d3a70 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 @@ -24,11 +24,17 @@ const cardColor = (ssbuckets, totalHrs) => { bucket.gte <= totalHrs && (!!bucket.lt ? bucket.lt > totalHrs : true) )[0]; - if (bucket.color.rgb) { - return bucket.color.rgb; + let color = { r: 255, g: 255, b: 255 }; + + if (bucket && bucket.color) { + color = bucket.color; + + if (bucket.color.rgb) { + color = bucket.color.rgb; + } } - return bucket.color ?? { r: 255, g: 255, b: 255 }; // default to white + return color; }; function getContrastYIQ(bgColor) {