"use client"; import { Loading } from "@/components/ui/loading"; // import { GitHub, Google } from "@/components/ui/icons"; import { toast } from "@/components/ui/toaster"; // import { useSignIn } from "@clerk/nextjs"; //import type { OAuthStrategy } from "@clerk/types"; import * as React from "react"; import { OAuthButton } from "../oauth-button"; type OAuthStrategy = 'oauth_google' | 'oauth_github'; export function OAuthSignIn() { const [isLoading, setIsLoading] = React.useState(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); } }; return (
oauthSignIn("oauth_github")}> {isLoading === "oauth_github" ? ( ) : ( )} GitHub oauthSignIn("oauth_google")}> {isLoading === "oauth_google" ? ( ) : ( )} Google
); }