1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00
p61-project/app/application/habits/[habitId]/index.tsx

22 lines
650 B
TypeScript
Raw Normal View History

import { Redirect, useLocalSearchParams } from "expo-router"
2024-03-24 23:41:23 +01:00
2024-05-02 01:08:27 +02:00
import { HabitEditForm } from "@/presentation/react-native/components/HabitForm/HabitEditForm"
2024-04-11 13:07:17 +02:00
import { useHabitsTracker } from "@/presentation/react/contexts/HabitsTracker"
2024-03-24 23:41:23 +01:00
const HabitPage: React.FC = () => {
const { habitId } = useLocalSearchParams()
const { habitsTracker } = useHabitsTracker()
2024-03-24 23:41:23 +01:00
const habitHistory = habitsTracker.getHabitHistoryById(habitId as string)
2024-04-11 13:07:17 +02:00
if (habitHistory == null) {
return <Redirect href="/application/habits/" />
}
2024-03-24 23:41:23 +01:00
return (
2024-04-11 13:07:17 +02:00
<HabitEditForm habit={habitHistory.habit} key={habitHistory.habit.id} />
2024-03-24 23:41:23 +01:00
)
}
export default HabitPage