diff --git a/app/application/habits/[habitId]/index.tsx b/app/application/habits/[habitId]/index.tsx
index aeaa0c2..6236764 100644
--- a/app/application/habits/[habitId]/index.tsx
+++ b/app/application/habits/[habitId]/index.tsx
@@ -1,10 +1,17 @@
-import { useLocalSearchParams } from "expo-router"
+import { Redirect, useLocalSearchParams } from "expo-router"
import { Text } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context"
+import { useHabitsTracker } from "@/presentation/react/contexts/HabitsTracker"
+
const HabitPage: React.FC = () => {
const { habitId } = useLocalSearchParams()
+ const { habitsTracker } = useHabitsTracker()
+ const habitHistory = habitsTracker.getHabitHistoryById(habitId as string)
+ if (habitHistory == null) {
+ return
+ }
return (
{
},
]}
>
- Habit Page {habitId}
+
+ Habit Page {habitId} {habitHistory.habit.name}
+
)
}
diff --git a/domain/entities/HabitsTracker.ts b/domain/entities/HabitsTracker.ts
index c86b1c2..7a99215 100644
--- a/domain/entities/HabitsTracker.ts
+++ b/domain/entities/HabitsTracker.ts
@@ -34,4 +34,18 @@ export class HabitsTracker implements HabitsTrackerData {
}),
)
}
+
+ public getAllHabitsHistory(): HabitHistory[] {
+ return [
+ ...this.habitsHistory.daily,
+ ...this.habitsHistory.weekly,
+ ...this.habitsHistory.monthly,
+ ]
+ }
+
+ public getHabitHistoryById(id: Habit["id"]): HabitHistory | undefined {
+ return this.getAllHabitsHistory().find((habitHistory) => {
+ return habitHistory.habit.id === id
+ })
+ }
}