From 71987799c04c93bfff5a1caab586fe08dfb00017 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= <contact@theoludwig.fr>
Date: Mon, 20 May 2024 11:41:04 +0200
Subject: [PATCH] fix: should filter habits by start date

---
 .../components/HabitsMainPage/HabitsList.tsx           | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/presentation/react-native/components/HabitsMainPage/HabitsList.tsx b/presentation/react-native/components/HabitsMainPage/HabitsList.tsx
index beacc11..20738f3 100644
--- a/presentation/react-native/components/HabitsMainPage/HabitsList.tsx
+++ b/presentation/react-native/components/HabitsMainPage/HabitsList.tsx
@@ -92,10 +92,14 @@ export const HabitsList: React.FC<HabitsListProps> = (props) => {
               >
                 {habitsTracker.habitsHistory[frequency]
                   .filter((habitItem) => {
+                    const startDate = new Date(habitItem.habit.startDate)
+                    startDate.setHours(0, 0, 0, 0)
+
                     return (
-                      (habitItem.habit.endDate != null &&
-                        habitItem.habit.endDate >= selectedDate) ||
-                      habitItem.habit.endDate == null
+                      startDate <= selectedDate &&
+                      (habitItem.habit.endDate == null ||
+                        (habitItem.habit.endDate != null &&
+                          habitItem.habit.endDate >= selectedDate))
                     )
                   })
                   .map((item) => {
-- 
GitLab