diff --git a/src/components/Shortcuts.tsx b/src/components/Shortcuts.tsx index ae54b21..9a40af8 100644 --- a/src/components/Shortcuts.tsx +++ b/src/components/Shortcuts.tsx @@ -22,7 +22,8 @@ const ItemTemplate = React.memo((props: ItemTemplateProps) => { dayHover, changeDayHover, hideDatepicker, - changeDatepickerValue + changeDatepickerValue, + value } = useContext(DatepickerContext); // Functions @@ -63,11 +64,31 @@ const ItemTemplate = React.memo((props: ItemTemplateProps) => { ] ); + function highlightActiveCell(item: ShortcutsItem | ShortcutsItem[]) { + if (Array.isArray(item)) { + // Handle array of ShortcutsItem objects + return item.map(singleItem => { + const { start, end } = singleItem.period; + if (start && end && start === value?.startDate && end === value?.endDate) { + return "bg-gray-100 dark:bg-white/10"; + } + return ""; + }); + } else { + // Handle single ShortcutsItem object + const { start, end } = item.period; + if (start && end && start === value?.startDate && end === value?.endDate) { + return "bg-gray-100 dark:bg-white/10"; + } + return ""; + } + } + const children = props?.children; return (