diff --git a/components/PeriodCard.tsx b/components/PeriodCard.tsx index b679235e..909470d9 100644 --- a/components/PeriodCard.tsx +++ b/components/PeriodCard.tsx @@ -14,6 +14,7 @@ const PeriodCard = ({ period }: Props) => { const { data: session } = useSession(); const router = useRouter(); const [hasApplied, setHasApplied] = useState(false); + const [isLoading, setIsLoading] = useState(true); useEffect(() => { const checkApplicationStatus = async () => { @@ -24,6 +25,7 @@ const PeriodCard = ({ period }: Props) => { if (response.ok) { const data = await response.json(); setHasApplied(data.exists); + setIsLoading(false); } } }; @@ -33,6 +35,17 @@ const PeriodCard = ({ period }: Props) => { } }, [period._id, session?.user?.owId]); + if (isLoading) { + return ( +