import { type ReactNode } from 'react'; import { motion } from 'framer-motion'; import { ShieldAlert, LogIn, Sparkles, ShieldCheck } from 'lucide-react'; import { useAuth } from '@/context/AuthContext'; interface ProtectedRouteProps { children: ReactNode; title: string; description: string; requireVerifiedStudent?: boolean; } export default function ProtectedRoute({ children, title, description, requireVerifiedStudent = false, }: ProtectedRouteProps) { const { isAuthenticated, isVerifiedStudent, loginWithGoogle, user } = useAuth(); // If user is authenticated (and meets verified student criteria if required), render the actual page! const isAllowed = isAuthenticated && (!requireVerifiedStudent || isVerifiedStudent); if (isAllowed) { return <>{children}; } return (
{/* Background ambient light */}
{/* Lock / Shield Icon */}
{requireVerifiedStudent ? ( ) : ( )}
{/* Feature Title */}
Authentication Required

{title}

{!isAuthenticated ? ( <> {description} Sign in with your Google account to access this feature. ) : ( <> You are signed in as {user?.email}. This feature is restricted to verified students with an @ritchennai.edu.in college email. )}

{/* Action Button */}
{!isAuthenticated ? 'Sign In with Google to Unlock' : 'Switch to @ritchennai.edu.in Account'}

Sign-in is quick, secure, and preserves your student privacy.

); }