import React, { useEffect } from 'react'; import { useSearchParams } from 'react-router-dom'; import { Loader2, Zap } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import { APP_NAME, APP_TAGLINE } from '@/lib/branding'; import { useAuth } from '@/context/AuthContext'; export default function SignIn() { const { phase, googleOn } = useAuth(); const [searchParams, setSearchParams] = useSearchParams(); useEffect(() => { const err = searchParams.get('auth_error'); if (!err) return; if (err === 'access_denied') { console.info('Google sign-in was cancelled.'); } else if (err === 'invite_email_mismatch') { console.warn( 'Invitation email does not match your Google account. Sign in with the invited address.' ); } else { console.warn('Google sign-in error:', err); } const next = new URLSearchParams(searchParams); next.delete('auth_error'); setSearchParams(next, { replace: true }); }, [searchParams, setSearchParams]); const inviteParam = searchParams.get('invite'); const googleHref = inviteParam ? `/api/auth/google?invite=${encodeURIComponent(inviteParam)}` : '/api/auth/google'; if (phase === 'loading') { return (
); } if (phase === 'error') { return (

Could not reach the server. Refresh and try again.

); } if (!googleOn) { return (

Google sign-in is not configured

Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET on the server to enable access.

); } return (

{APP_NAME}

{APP_TAGLINE}

Sign in with your Google account to access campaigns, contacts, leads, and deals.

{inviteParam ? (

You have a workspace invitation. Sign in with the email address that received the invite.

) : null}
); } function GoogleMark({ className }) { return ( ); }