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 ( +
+
+
+
+
+
+ ); + } + return (
diff --git a/pages/apply.tsx b/pages/apply.tsx index dc6f3f14..4fce96e6 100644 --- a/pages/apply.tsx +++ b/pages/apply.tsx @@ -74,7 +74,7 @@ const Apply = () => {

Nåværende opptaksperioder

-
+
{currentPeriods.map((period: periodType, index: number) => ( ))}