import { useState, useEffect } from 'react' import './GoogleImport.css' function GoogleImport({ onImportComplete }) { const [importing, setImporting] = useState(false) useEffect(() => { // Check if we got redirected back from Google OAuth const urlParams = new URLSearchParams(window.location.search) const imported = urlParams.get('imported') const importOwner = urlParams.get('owner') const error = urlParams.get('error') if (imported) { alert(`יובאו בהצלחה ${imported} אנשי קשר מחשבון Google של ${importOwner}!`) onImportComplete() // Clean up URL window.history.replaceState({}, document.title, window.location.pathname) } if (error) { alert(`נכשל בייבוא אנשי הקשר: ${error}`) // Clean up URL window.history.replaceState({}, document.title, window.location.pathname) } }, [onImportComplete]) const handleGoogleImport = () => { setImporting(true) // Redirect to backend OAuth endpoint (owner will be extracted from email) const apiUrl = window.ENV?.VITE_API_URL || import.meta.env.VITE_API_URL || 'http://localhost:8000' window.location.href = `${apiUrl}/auth/google` } return ( ) } export default GoogleImport