IO-1722 adjusted logic for card color

This commit is contained in:
swtmply
2023-05-06 04:56:03 +08:00
parent 56fef0f43c
commit 04509fa587
2 changed files with 15 additions and 6 deletions

View File

@@ -7,10 +7,13 @@ const CardColorLegend = ({ bodyshop }) => {
const data = bodyshop.ssbuckets.map((bucket) => { const data = bodyshop.ssbuckets.map((bucket) => {
let color = { r: 255, g: 255, b: 255 }; let color = { r: 255, g: 255, b: 255 };
if (bucket.color.rgb) { if (bucket.color) {
color = bucket.color.rgb; color = bucket.color;
if (bucket.color.rgb) {
color = bucket.color.rgb;
}
} }
color = bucket.color; // default to white
return { return {
label: bucket.label, label: bucket.label,

View File

@@ -24,11 +24,17 @@ const cardColor = (ssbuckets, totalHrs) => {
bucket.gte <= totalHrs && (!!bucket.lt ? bucket.lt > totalHrs : true) bucket.gte <= totalHrs && (!!bucket.lt ? bucket.lt > totalHrs : true)
)[0]; )[0];
if (bucket.color.rgb) { let color = { r: 255, g: 255, b: 255 };
return bucket.color.rgb;
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) { function getContrastYIQ(bgColor) {