diff --git a/src/pages/gym/GymIndividual.tsx b/src/pages/gym/GymIndividual.tsx index 79e5b192e1a6f761af1433540a4d8f2bfa3033db..f9eb9d4e1f60a0971abd83da9815ecdd31bc8e36 100644 --- a/src/pages/gym/GymIndividual.tsx +++ b/src/pages/gym/GymIndividual.tsx @@ -1,13 +1,15 @@ import GymApplication from "@/components/gym/GymApplication"; import config from "@/utils/config"; +import { useUser } from "@/utils/context/AuthProvider"; import { useGym } from "@/utils/context/GymProvider"; import { useParams } from "react-router-dom"; function GymIndividual() { const { id } = useParams(); - const { data: gym, status } = useGym(Number(id ?? 1)); + const { data: gym, status: gymStatus } = useGym(Number(id ?? 1)); + const { status, user } = useUser(); - if (status !== "success") { + if (gymStatus !== "success") { return "Loading..."; } @@ -28,7 +30,13 @@ function GymIndividual() { <p>{gym.cityName}</p> <p>{gym.description}</p> </div> - <GymApplication gym={gym} /> + {status !== "success" || !user ? ( + <p>Loading...</p> + ) : !user.gymId ? ( + <GymApplication gym={gym} /> + ) : ( + "" + )} </div> ); }