import React from 'react'; import { apiCall } from '../utils/api'; interface GoogleOAuthButtonProps { onSuccess: (user: any, token: string) => void; onError: (error: string) => void; } const GoogleOAuthButton: React.FC = ({ onSuccess, onError }) => { const handleGoogleLogin = async () => { try { // Get the OAuth URL from backend const { data } = await apiCall('/auth/google/url'); if (data && data.url) { // Redirect to Google OAuth (no popup to avoid CORS issues) window.location.href = data.url; } else { onError('Failed to get authentication URL'); } } catch (error) { console.error('Error initiating Google login:', error); onError('Failed to start authentication'); } }; return ( ); }; export default GoogleOAuthButton;