1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00

fix: should filter habits by start date

This commit is contained in:
Théo LUDWIG 2024-05-20 11:41:04 +02:00
parent 3c0c34d187
commit 71987799c0
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B

View File

@ -92,10 +92,14 @@ export const HabitsList: React.FC<HabitsListProps> = (props) => {
> >
{habitsTracker.habitsHistory[frequency] {habitsTracker.habitsHistory[frequency]
.filter((habitItem) => { .filter((habitItem) => {
const startDate = new Date(habitItem.habit.startDate)
startDate.setHours(0, 0, 0, 0)
return ( return (
(habitItem.habit.endDate != null && startDate <= selectedDate &&
habitItem.habit.endDate >= selectedDate) || (habitItem.habit.endDate == null ||
habitItem.habit.endDate == null (habitItem.habit.endDate != null &&
habitItem.habit.endDate >= selectedDate))
) )
}) })
.map((item) => { .map((item) => {