Skip to content

Commit 62f5a1b

Browse files
authored
💄 style: style improve auth sign in box loading (#8805)
1 parent 2e9ad20 commit 62f5a1b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/app/[variants]/(auth)/next-auth/signin/AuthSignInBox.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createStyles } from 'antd-style';
77
import { AuthError } from 'next-auth';
88
import { signIn } from 'next-auth/react';
99
import { useRouter, useSearchParams } from 'next/navigation';
10-
import { memo } from 'react';
10+
import { memo, useState } from 'react';
1111
import { useTranslation } from 'react-i18next';
1212

1313
import BrandWatermark from '@/components/BrandWatermark';
@@ -70,6 +70,7 @@ export default memo(() => {
7070
const { styles } = useStyles();
7171
const { t } = useTranslation('clerk');
7272
const router = useRouter();
73+
const [loadingProvider, setLoadingProvider] = useState<string | null>(null);
7374

7475
const oAuthSSOProviders = useUserStore((s) => s.oAuthSSOProviders);
7576

@@ -79,9 +80,11 @@ export default memo(() => {
7980
const callbackUrl = searchParams.get('callbackUrl') ?? '/';
8081

8182
const handleSignIn = async (provider: string) => {
83+
setLoadingProvider(provider);
8284
try {
8385
await signIn(provider, { redirectTo: callbackUrl });
8486
} catch (error) {
87+
setLoadingProvider(null);
8588
// Signin can fail for a number of reasons, such as the user
8689
// not existing, or the user not having the correct role.
8790
// In some cases, you may want to redirect to a custom error
@@ -127,6 +130,7 @@ export default memo(() => {
127130
className={styles.button}
128131
icon={AuthIcons(provider, 16)}
129132
key={provider}
133+
loading={loadingProvider === provider}
130134
onClick={() => handleSignIn(provider)}
131135
>
132136
{provider}

0 commit comments

Comments
 (0)