From 488374a5204eee82dc62a09f64cb9318e54357f1 Mon Sep 17 00:00:00 2001 From: Fatih20 <fnri39@protonmail.com> Date: Fri, 17 Nov 2023 00:30:31 +0700 Subject: [PATCH] Do not show application option when trainer is employed. --- src/pages/gym/GymIndividual.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/gym/GymIndividual.tsx b/src/pages/gym/GymIndividual.tsx index 79e5b19..f9eb9d4 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> ); } -- GitLab