'use client'; import { useState } from 'react'; import { oauthService } from '@/lib/services/auth'; import { Button } from '@/components/ui/button'; import { Alert, AlertDescription } from '@/components/ui/alert'; import { AlertCircle, Loader2 } from 'lucide-react'; interface OAuthButtonsProps { redirectUrl?: string; } export function OAuthButtons({ redirectUrl = '/dashboard' }: OAuthButtonsProps) { const [isLoading, setIsLoading] = useState(null); const [error, setError] = useState(''); const handleOAuth = async (provider: 'google' | 'discord') => { setError(''); setIsLoading(provider); try { await oauthService.initiateOAuth(provider, redirectUrl); // User will be redirected to OAuth provider } catch (err: any) { setError(err.response?.data?.detail || `Failed to initiate ${provider} login`); setIsLoading(null); } }; return (
{error && ( {error} )}
Or continue with
); }