feat: highlight expired date and datetime attributes

This commit is contained in:
2025-04-13 12:11:41 +04:00
parent 0a479fae1c
commit 5487aab274
6 changed files with 40 additions and 18 deletions

View File

@@ -32,9 +32,17 @@ const CardAttributesInSummaryItem = ({ cardSummary }: Props) => {
const isHighlightNeeded = (cardAttr: CardAttributeSchema): boolean => {
const type = cardAttr.attribute.type.type;
if (type !== "datetime") return false;
if (!cardAttr.attribute.isHighlightIfExpired) return false;
if (type !== "datetime" && type !== "date") return false;
const datetime = new Date(cardAttr.value as string);
return datetime < new Date();
const curr = new Date();
if (type === "datetime") {
return datetime < curr;
}
curr.setHours(0, 0, 0, 0);
return datetime < curr;
};
return (