Skip to content

Commit 0fed25c

Browse files
authored
change loading rings and fix registration loading (#205)
1 parent e293518 commit 0fed25c

File tree

10 files changed

+52
-33
lines changed

10 files changed

+52
-33
lines changed

src/app/login/page.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
import Login from "@/components/LoginForm/Login";
1+
import dynamic from "next/dynamic";
2+
3+
import KevinLoadingRing from "@/components/KevinLoadingRing";
24
import RegistrationLayout from "@/components/layouts/RegistrationLayout";
35

6+
const Login = dynamic(() => import("@/components/LoginForm/Login"), {
7+
ssr: false,
8+
loading: () => (
9+
<div className="mt-16 flex w-full items-center justify-center">
10+
<KevinLoadingRing />
11+
</div>
12+
),
13+
});
14+
415
export default function LoginPage() {
516
return (
617
<RegistrationLayout>

src/app/participant/profile/page.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import dynamic from "next/dynamic";
22

3+
import KevinLoadingRing from "@/components/KevinLoadingRing";
4+
35
// Dynamically import UserProfile with preloading
46
const UserProfile = dynamic(
57
() => import("@/components/UserProfile/UserProfile"),
68
{
79
ssr: false,
8-
loading: () => <p>Loading user profile...</p>,
10+
loading: () => (
11+
<div className="flex w-full items-center justify-center">
12+
<KevinLoadingRing />
13+
</div>
14+
),
915
},
1016
);
1117

src/components/KevinLoadingRing.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default function KevinLoadingRing() {
1212
height={240}
1313
/>
1414
<div className="ml-2 flex w-full items-center justify-center space-x-1">
15-
<span className="text-dark-pink">Loading</span>
16-
<span className=" mt-3 size-1 animate-pulse rounded-full bg-dark-pink delay-200"></span>
17-
<span className="delay-400 mt-3 size-1 animate-pulse rounded-full bg-dark-pink"></span>
18-
<span className="delay-600 mt-3 size-1 animate-pulse rounded-full bg-dark-pink"></span>
15+
<span className="font-semibold text-gray-700">Loading</span>
16+
<span className=" mt-3 size-1 animate-pulse rounded-full bg-gray-700 delay-200"></span>
17+
<span className="delay-400 mt-3 size-1 animate-pulse rounded-full bg-gray-700"></span>
18+
<span className="delay-600 mt-3 size-1 animate-pulse rounded-full bg-gray-700"></span>
1919
</div>
2020
</div>
2121
</>

src/components/LoadingRing.tsx

-12
This file was deleted.

src/components/LoginForm/PersonalFormFields.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import FormFieldsHeader from "@/components/LoginForm/FormFieldsHeader";
1010
import { Flex, Input, Label, SelectField } from "@aws-amplify/ui-react";
1111
import { useMutation, useQuery } from "@tanstack/react-query";
1212

13-
import LoadingRing from "../LoadingRing";
13+
import KevinLoadingRing from "../KevinLoadingRing";
1414
import { UserType, useUser } from "../contexts/UserContext";
1515

1616
export default function PersonalFormFields({ user }: { user: AuthUser }) {
@@ -91,8 +91,14 @@ export default function PersonalFormFields({ user }: { user: AuthUser }) {
9191
setFormState((prevState) => ({ ...prevState, [name]: value }));
9292
}
9393
};
94+
95+
console.log(isPending);
9496
if (isPending) {
95-
return <LoadingRing />;
97+
return (
98+
<div className="mt-16 flex w-full items-center justify-center">
99+
<KevinLoadingRing />
100+
</div>
101+
);
96102
}
97103
if (isError) {
98104
return <div>Error, please try again later.</div>;

src/components/UserProfile/FoodTicket.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { QRCode } from "react-qrcode-logo";
88
import { type Schema } from "@/amplify/data/resource";
99
import { createMessageAndCode } from "@/amplify/function/BusinessLogic/utils/crytography";
1010
import { getUpcomingFoodEventDetails } from "@/app/get-food-ticket/actions";
11-
import LoadingRing from "@/components/LoadingRing";
11+
import KevinLoadingRing from "@/components/KevinLoadingRing";
1212
import { UserType, useUser } from "@/components/contexts/UserContext";
1313
import { useQuery } from "@tanstack/react-query";
1414

@@ -114,7 +114,7 @@ export default function UserFoodTicket() {
114114
<>
115115
{isFetching ? (
116116
<div className="flex h-screen w-full items-center justify-center bg-fuzzy-peach">
117-
<LoadingRing />
117+
<KevinLoadingRing />
118118
</div>
119119
) : (
120120
<div className="flex size-full flex-col items-center bg-fuzzy-peach">

src/components/UserProfile/TeamProfile.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { type Schema } from "@/amplify/data/resource";
44
import { client } from "@/app/QueryProvider";
5-
import LoadingRing from "@/components/LoadingRing";
5+
import KevinLoadingRing from "@/components/KevinLoadingRing";
66
import TeamForm from "@/components/UserProfile/TeamForm";
77
import { useUser } from "@/components/contexts/UserContext";
88
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
@@ -54,7 +54,7 @@ const TeamProfile = () => {
5454
<>
5555
{isFetching || !userTeamId ? (
5656
<div className="flex h-screen w-full items-center justify-center bg-fuzzy-peach">
57-
<LoadingRing />
57+
<KevinLoadingRing />
5858
</div>
5959
) : (
6060
<>

src/components/UserProfile/UserProfile.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useState } from "react";
55

66
import { type Schema } from "@/amplify/data/resource";
77
import { client } from "@/app/QueryProvider";
8-
import LoadingRing from "@/components/LoadingRing";
8+
import KevinLoadingRing from "@/components/KevinLoadingRing";
99
import UserForm from "@/components/UserProfile/UserForm";
1010
import { useUser } from "@/components/contexts/UserContext";
1111
import { useMutation, useQuery } from "@tanstack/react-query";
@@ -87,8 +87,8 @@ const UserProfile = () => {
8787
<div>
8888
{" "}
8989
{isFetching || userContextIsFetching ? (
90-
<div className="flex h-screen w-full items-center justify-center bg-fuzzy-peach">
91-
<LoadingRing />
90+
<div className="flex w-full items-center justify-center">
91+
<KevinLoadingRing />
9292
</div>
9393
) : (
9494
<div className="flex w-full flex-col bg-fuzzy-peach">

src/components/reset/ResetPage.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Schema } from "@/amplify/data/resource";
1010
import { Button, CheckboxField, Input, Label } from "@aws-amplify/ui-react";
1111
import { useMutation, useQuery } from "@tanstack/react-query";
1212

13-
import LoadingRing from "../LoadingRing";
13+
import KevinLoadingRing from "../KevinLoadingRing";
1414

1515
const client = generateClient<Schema>();
1616
export default function ResetPage() {
@@ -113,9 +113,12 @@ export default function ResetPage() {
113113
name: "scoringSidepots",
114114
});
115115

116-
if (hackathonData.isPending) return <LoadingRing />;
117-
118-
if (userMutation.isPending) return <LoadingRing />;
116+
if (hackathonData.isPending || userMutation.isPending)
117+
return (
118+
<div className="mt-16 flex w-full items-center justify-center">
119+
<KevinLoadingRing />
120+
</div>
121+
);
119122

120123
if (userMutation.isError) return <div>Error, please try again later.</div>;
121124

src/components/teamRegistration/TeamInformation.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { client } from "@/app/QueryProvider";
44
import { useQuery } from "@tanstack/react-query";
55

6-
import LoadingRing from "../LoadingRing";
6+
import KevinLoadingRing from "../KevinLoadingRing";
77

88
export default function TeamInformation({
99
state = "Registered",
@@ -19,7 +19,12 @@ export default function TeamInformation({
1919
},
2020
});
2121
const teamName = data?.name ?? "Unknown";
22-
if (isPending) return <LoadingRing />;
22+
if (isPending)
23+
return (
24+
<div className="mt-4">
25+
<KevinLoadingRing />
26+
</div>
27+
);
2328
if (state === "Joined")
2429
return (
2530
<div className=" flex flex-col gap-4 text-center text-5xl font-bold">

0 commit comments

Comments
 (0)