import { useEffect, useRef } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, ShieldCheck, Sparkles } from 'lucide-react'; import { useAuth } from '@/context/AuthContext'; interface GoogleAuthModalProps { isOpen: boolean; onClose: () => void; } export default function GoogleAuthModal({ isOpen, onClose }: GoogleAuthModalProps) { const buttonRef = useRef(null); const { isAuthenticated } = useAuth(); // Close modal automatically if user gets authenticated useEffect(() => { if (isAuthenticated && isOpen) { onClose(); } }, [isAuthenticated, isOpen, onClose]); // Render Google Button inside modal when open useEffect(() => { if (!isOpen) return; const renderGoogleBtn = () => { if (window.google && buttonRef.current) { buttonRef.current.innerHTML = ''; window.google.accounts.id.renderButton(buttonRef.current, { type: 'standard', theme: 'outline', size: 'large', text: 'signin_with', shape: 'pill', logo_alignment: 'left', width: 280, }); } }; // Render immediately if script is loaded renderGoogleBtn(); // Or poll briefly if script is loading const interval = setInterval(() => { if (window.google) { renderGoogleBtn(); clearInterval(interval); } }, 200); return () => clearInterval(interval); }, [isOpen]); return ( {isOpen && (
{/* Backdrop */} {/* Modal Container */} {/* Background Orbs */}
{/* Close Button */} {/* Icon Header */}
{/* Title & Description */}

Sign In to Freshers Hub

Sign in with your Google account. Use your{' '} @ritchennai.edu.in college email to unlock the{' '} Verified Student badge and post collaboration requests!

{/* Google Sign-In Button Container */}
{/* Verified Student Callout */}
Official RIT Student Verification via Google
)} ); }