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'; import { apiUrl } from '@/lib/api'; export default function SignIn() { const { phase, googleOn, microsoftOn } = useAuth(); const [searchParams, setSearchParams] = useSearchParams(); useEffect(() => { const err = searchParams.get('auth_error'); if (!err) return; if (err === 'access_denied') { console.info('Sign-in was cancelled.'); } else if (err === 'invite_email_mismatch') { console.warn( 'Invitation email does not match your account. Sign in with the invited address.' ); } else { console.warn('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 = apiUrl( inviteParam ? `/api/auth/google?invite=${encodeURIComponent(inviteParam)}` : '/api/auth/google' ); const microsoftHref = apiUrl( inviteParam ? `/api/auth/microsoft?invite=${encodeURIComponent(inviteParam)}` : '/api/auth/microsoft' ); if (phase === 'loading') { return (
Could not reach the server. Refresh and try again.
Sign-in is not configured
Set GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET and/or MICROSOFT_CLIENT_ID/ MICROSOFT_CLIENT_SECRET on the server to enable access.
{APP_TAGLINE}
Sign in to access campaigns, contacts, leads, and deals.
{inviteParam ? (You have a workspace invitation. Sign in with the email address that received the invite.
) : null}