IO-1722 refactor color function
This commit is contained in:
@@ -18,14 +18,16 @@ import moment from "moment";
|
||||
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
||||
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
|
||||
|
||||
const cardColor = (job_sizes, totalHrs) => {
|
||||
for (const size of job_sizes) {
|
||||
if (totalHrs <= (size.lt || 999) && totalHrs >= size.gte) {
|
||||
if (size.color) {
|
||||
return size.color.hex;
|
||||
}
|
||||
}
|
||||
const cardColor = (ssbuckets, totalHrs) => {
|
||||
const bucket = ssbuckets.filter(
|
||||
(bucket) =>
|
||||
bucket.gte <= totalHrs && (!!bucket.lt ? bucket.lt > totalHrs : true)
|
||||
)[0];
|
||||
|
||||
if (bucket.color) {
|
||||
return bucket.color.hex;
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
@@ -76,18 +78,16 @@ export default function ProductionBoardCard(
|
||||
|
||||
const totalHrs =
|
||||
card.labhrs.aggregate.sum.mod_lb_hrs + card.larhrs.aggregate.sum.mod_lb_hrs;
|
||||
const bgColor = cardColor(bodyshop.ssbuckets, totalHrs);
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="react-kanban-card imex-kanban-card"
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor:
|
||||
cardSettings &&
|
||||
cardSettings.cardcolor &&
|
||||
cardColor(bodyshop.ssbuckets, totalHrs),
|
||||
backgroundColor: cardSettings && cardSettings.cardcolor && bgColor,
|
||||
|
||||
color: getContrastYIQ(cardColor(bodyshop.ssbuckets, totalHrs)),
|
||||
color: getContrastYIQ(bgColor),
|
||||
}}
|
||||
title={
|
||||
<Space>
|
||||
|
||||
Reference in New Issue
Block a user