This repository has been archived on 2024-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
p61-project/app/application/habits/[habitId]/index.tsx

22 lines
647 B
TypeScript

import { Redirect, useLocalSearchParams } from "expo-router"
import { HabitEditForm } from "@/presentation/react/components/HabitEditForm/HabitEditForm"
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 <Redirect href="/application/habits/" />
}
return (
<HabitEditForm habit={habitHistory.habit} key={habitHistory.habit.id} />
)
}
export default HabitPage