From a595074494e382c98499ad7ddaacc5fcc3ce87a2 Mon Sep 17 00:00:00 2001 From: Julian Ammouche Ottosen <42567826+julian-ao@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:17:55 +0200 Subject: [PATCH] Added loading to period cards (#157) * added loading to period cards * Added skeleton loader to PeriodCard --------- Co-authored-by: fredrir --- components/PeriodCard.tsx | 13 +++++++++++++ pages/apply.tsx | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) 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) => ( ))}