"use client"; import * as React from "react"; import { useSignIn } from "@clerk/nextjs"; import type { OAuthStrategy } from "@clerk/types"; import { Button } from "@acme/ui/button"; import * as Icons from "@acme/ui/icons"; import { useToast } from "@acme/ui/use-toast"; export function OAuthSignIn() { const [isLoading, setIsLoading] = React.useState(null); const { signIn, isLoaded: signInLoaded } = useSignIn(); const { toast } = useToast(); const oauthSignIn = async (provider: OAuthStrategy) => { if (!signInLoaded) return null; try { setIsLoading(provider); await signIn.authenticateWithRedirect({ strategy: provider, redirectUrl: "/sso-callback", redirectUrlComplete: "/dashboard", }); } catch (cause) { console.error(cause); setIsLoading(null); toast({ variant: "destructive", title: "Error", description: "Something went wrong, please try again.", }); } }; return (
); }