date-fns#isSameWeek TypeScript Examples

The following examples show how to use date-fns#isSameWeek. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeeklyCalendar.tsx    From react-calendar with MIT License 6 votes vote down vote up
export function WeeklyBody<EventItem>({
  events,
  renderItem,
  style,
}: WeeklyBodyProps<EventItem>) {
  let { week, selectedDay } = useWeeklyCalendar();
  return (
    <div className="rc-overflow-auto rc-max-h-96" style={style}>
      <ul className="rc-divide-y rc-divide-gray-200 ">
        {events.map(item => {
          // If they select a single day, filter out events for different days
          if (selectedDay) {
            if (!isSameDay(selectedDay, item.date)) return null;
          }
          //if an event is for a different week, filter it out
          if (!isSameWeek(week, item.date)) return null;

          //return the remeaining events!
          return renderItem({
            item,
            showingFullWeek: selectedDay === undefined,
          });
        })}
      </ul>
    </div>
  );
}