Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/components/Shortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const ItemTemplate = React.memo((props: ItemTemplateProps) => {
dayHover,
changeDayHover,
hideDatepicker,
changeDatepickerValue
changeDatepickerValue,
value
} = useContext(DatepickerContext);

// Functions
Expand Down Expand Up @@ -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 (
<li
className={getClassName()}
className={`${getClassName()} ${highlightActiveCell(props?.item)}`}
onClick={() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down