From fc03955ffbd19233f8e244aca48f6a769f0feaf9 Mon Sep 17 00:00:00 2001 From: Dominik Hryshaiev Date: Mon, 30 Dec 2024 18:52:46 +0100 Subject: [PATCH] fix(calendar): correct date for entries map again --- src/components/App.tsx | 2 +- .../calendar-month/CalendarCell.tsx | 3 +- .../calendar-month/CalendarHeader.tsx | 11 ++--- .../calendar-month/OccurrenceChip.tsx | 12 ++++-- src/components/header/Header.tsx | 41 +++++++++++-------- src/helpers/calendar.ts | 2 +- src/stores/occurrences.store.ts | 2 +- 7 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index b852cf1..54da305 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -18,7 +18,7 @@ setDefaultOptions({ locale: enGB }); const App = () => { React.useEffect(() => { document.getElementById('root')?.classList.add('initialized'); - }); + }, []); return ( diff --git a/src/components/calendar-month/CalendarCell.tsx b/src/components/calendar-month/CalendarCell.tsx index a6c1438..6ec9b46 100644 --- a/src/components/calendar-month/CalendarCell.tsx +++ b/src/components/calendar-month/CalendarCell.tsx @@ -69,8 +69,9 @@ const CalendarCell = ({ const screenSize = useScreenSize(); const date = format( new Date(fullYear, monthNumber - 1, dateNumber), - 'yyyy-MM-d' + 'yyyy-MM-dd' ); + const occurrences = isCalendarDay(date) ? occurrencesByDate[date] || [] : []; const isMobile = screenSize < 768; const hasNote = notes.some((note) => note.day === date); diff --git a/src/components/calendar-month/CalendarHeader.tsx b/src/components/calendar-month/CalendarHeader.tsx index fbdec8e..32477ad 100644 --- a/src/components/calendar-month/CalendarHeader.tsx +++ b/src/components/calendar-month/CalendarHeader.tsx @@ -55,6 +55,7 @@ const CalendarHeader = ({ const { filteredBy, filterBy } = useOccurrencesStore(); const user = useUser(); const screenSize = useScreenSize(); + const isOnCurrentMonth = activeMonthLabel === MONTHS[new Date().getMonth()]; const shouldRenderFilters = !!user && habits.length > 0 && traits.length > 0; @@ -96,7 +97,7 @@ const CalendarHeader = ({
- {!isMobile && ( + {!isMobile && !isOnCurrentMonth && (