Skip to content

Commit e799fce

Browse files
authored
feat: add loading to the signin button (#123)
* feat: add loading to signin button * fix: padding in the back button detail page * fix: button size
1 parent 063634d commit e799fce

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/app/catalog/[repoName]/[serverName]/[version]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default async function CatalogDetailPage({
3030
const server = serverResponse?.server ?? {};
3131

3232
return (
33-
<div className="flex flex-col gap-2 pt-5 pb-8 px-4">
33+
<div className="flex flex-col gap-2 pb-8 px-4">
3434
<ServerDetailTitle
3535
publisher={server.repository?.source}
3636
serverName={server.name || "Unknown server"}

src/app/signin/signin-button.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
"use client";
2+
import { Loader2 } from "lucide-react";
3+
import { useState } from "react";
24
import { toast } from "sonner";
35
import { OktaIcon } from "@/components/brand-icons";
46
import { Button } from "@/components/ui/button";
57
import { authClient } from "@/lib/auth/auth-client";
68

79
export function SignInButton({ providerId }: { providerId: string }) {
10+
const [isLoading, setIsLoading] = useState(false);
811
const isOktaProvider = providerId === "okta" || providerId === "oidc";
912
const providerName = providerId.charAt(0).toUpperCase() + providerId.slice(1);
1013

1114
const handleOIDCSignIn = async () => {
15+
setIsLoading(true);
1216
try {
1317
const { error } = await authClient.signIn.oauth2({
1418
providerId,
1519
callbackURL: "/catalog",
1620
});
1721

1822
if (error) {
23+
setIsLoading(false);
1924
toast.error("Signin failed", {
2025
description:
2126
error.message ||
@@ -24,6 +29,7 @@ export function SignInButton({ providerId }: { providerId: string }) {
2429
return;
2530
}
2631
} catch (error) {
32+
setIsLoading(false);
2733
const errorMessage =
2834
error instanceof Error ? error.message : "An unexpected error occurred";
2935

@@ -38,9 +44,16 @@ export function SignInButton({ providerId }: { providerId: string }) {
3844
onClick={handleOIDCSignIn}
3945
className="w-full h-9 gap-2"
4046
size="default"
47+
disabled={isLoading}
4148
>
42-
{isOktaProvider && <OktaIcon className="size-4 shrink-0" />}
43-
<span>{providerName}</span>
49+
{isLoading ? (
50+
<Loader2 className="text-muted-foreground size-4 animate-spin" />
51+
) : (
52+
<>
53+
{isOktaProvider && <OktaIcon className="size-4 shrink-0" />}
54+
<span>{providerName}</span>
55+
</>
56+
)}
4457
</Button>
4558
);
4659
}

0 commit comments

Comments
 (0)