This commit is contained in:
hailin 2025-03-12 12:34:56 +08:00
parent dc838f22e0
commit cd69ad2c68
1 changed files with 21 additions and 21 deletions

View File

@ -8,30 +8,30 @@ import * as React from "react";
import { OAuthButton } from "../oauth-button";
export function OAuthSignIn() {
// const [isLoading, setIsLoading] = React.useState<OAuthStrategy | null>(null);
// const { signIn, isLoaded: signInLoaded } = useSignIn();
const [isLoading, setIsLoading] = React.useState<OAuthStrategy | null>(null);
const { signIn, isLoaded: signInLoaded } = useSignIn();
// const oauthSignIn = async (provider: OAuthStrategy) => {
// if (!signInLoaded) {
// return null;
// }
// try {
// setIsLoading(provider);
// await signIn.authenticateWithRedirect({
// strategy: provider,
// redirectUrl: "/auth/sso-callback",
// redirectUrlComplete: "/app/apis",
// });
// } catch (err) {
// console.error(err);
// setIsLoading(null);
// toast.error((err as Error).message);
// }
// };
const oauthSignIn = async (provider: OAuthStrategy) => {
if (!signInLoaded) {
return null;
}
try {
setIsLoading(provider);
await signIn.authenticateWithRedirect({
strategy: provider,
redirectUrl: "/auth/sso-callback",
redirectUrlComplete: "/app/apis",
});
} catch (err) {
console.error(err);
setIsLoading(null);
toast.error((err as Error).message);
}
};
return (
<div className="flex flex-col gap-2">
{/* <OAuthButton onClick={() => oauthSignIn("oauth_github")}>
<OAuthButton onClick={() => oauthSignIn("oauth_github")}>
{isLoading === "oauth_github" ? (
<Loading className="w-6 h-6" />
) : (
@ -46,7 +46,7 @@ export function OAuthSignIn() {
<Google className="w-6 h-6" />
)}
Google
</OAuthButton> */}
</OAuthButton>
</div>
);
}