Spaces:
Sleeping
Sleeping
Download Frontend/src/pages/Auth/Login.jsx from smit9604/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 7.4 kB
-
https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Frontend/src/pages/Auth/Login.jsx
- Command line
-
hf download hf://spaces/smit9604/ExamCraftAI/Frontend/src/pages/Auth/Login.jsx
-
curl -L -o Login.jsx https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Frontend/src/pages/Auth/Login.jsx
7.4 kB
| import React, { useState } from "react"; | |
| import { Link, useNavigate } from "react-router-dom"; | |
| import { motion } from "framer-motion"; | |
| import { BrainCircuit, Mail, Lock, ArrowRight } from "lucide-react"; | |
| import { Button } from "../../components/ui/Button"; | |
| import { Input } from "../../components/ui/Input"; | |
| import { useToast } from "../../components/ui/Toast"; | |
| import { supabase } from "../../utils/supabaseClient"; | |
| export default function Login() { | |
| const [email, setEmail] = useState(""); | |
| const [password, setPassword] = useState(""); | |
| const [isLoading, setIsLoading] = useState(false); | |
| const navigate = useNavigate(); | |
| const { addToast } = useToast(); | |
| const handleLogin = async (e) => { | |
| e.preventDefault(); | |
| setIsLoading(true); | |
| try { | |
| const { data, error } = await supabase.auth.signInWithPassword({ | |
| email, | |
| password, | |
| }); | |
| if (error) throw error; | |
| addToast({ | |
| title: "Welcome Back!", | |
| description: "Successfully logged into ExamCraft.AI", | |
| variant: "success", | |
| }); | |
| navigate("/app"); | |
| } catch (error) { | |
| addToast({ | |
| title: "Login Failed", | |
| description: error.message || "Invalid credentials. Please try again.", | |
| variant: "destructive", | |
| }); | |
| } finally { | |
| setIsLoading(false); | |
| } | |
| }; | |
| return ( | |
| <div className="min-h-screen flex selection:bg-primary/30"> | |
| {/* Left split screen (Illustration/Info) */} | |
| <motion.div | |
| initial={{ opacity: 0, x: -50 }} | |
| animate={{ opacity: 1, x: 0 }} | |
| transition={{ duration: 0.8 }} | |
| className="hidden lg:flex w-1/2 bg-card relative flex-col justify-between p-12 overflow-hidden border-r border-border" | |
| > | |
| {/* Animated fluid blob */} | |
| <motion.div | |
| animate={{ scale: [1, 1.1, 1], rotate: [0, -10, 0] }} | |
| transition={{ duration: 20, repeat: Infinity, ease: "easeInOut" }} | |
| className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] bg-primary/20 rounded-full blur-[100px] pointer-events-none" | |
| /> | |
| <div className="relative z-10"> | |
| <Link to="/" className="flex items-center gap-2 mb-12"> | |
| <BrainCircuit className="h-8 w-8 text-primary" /> | |
| <span className="text-2xl font-bold tracking-tight">ExamCraft.<span className="text-primary">AI</span></span> | |
| </Link> | |
| <h1 className="text-4xl font-extrabold mb-4 leading-tight"> | |
| Streamline your <br /> Exam Preparation. | |
| </h1> | |
| <p className="text-lg text-muted-foreground max-w-md"> | |
| The premium AI toolkit for modern educators. Upload, configure, and generate in seconds. | |
| </p> | |
| </div> | |
| {/* Decorative Graphic or Testimonial Placeholder */} | |
| <div className="relative z-10 glass p-6 rounded-xl border border-white/10 w-full max-w-sm"> | |
| <p className="italic text-muted-foreground text-sm mb-4"> | |
| "ExamCraft.AI cut my paper-setting time from hours to literally minutes. The AI quality is astounding." | |
| </p> | |
| <div className="flex items-center gap-3"> | |
| <div className="h-10 w-10 bg-primary/20 rounded-full flex items-center justify-center font-bold text-primary">JD</div> | |
| <div> | |
| <p className="font-semibold text-sm">Dr. Jane Doe</p> | |
| <p className="text-xs text-muted-foreground">University Professor</p> | |
| </div> | |
| </div> | |
| </div> | |
| </motion.div> | |
| {/* Right split screen (Form) */} | |
| <motion.div | |
| initial={{ opacity: 0, x: 50 }} | |
| animate={{ opacity: 1, x: 0 }} | |
| transition={{ duration: 0.8, delay: 0.1 }} | |
| className="w-full lg:w-1/2 bg-background flex items-center justify-center p-8 relative" | |
| > | |
| <div className="w-full max-w-md"> | |
| <div className="mb-10 lg:hidden flex items-center justify-center gap-2"> | |
| <BrainCircuit className="h-8 w-8 text-primary" /> | |
| <span className="text-3xl font-bold tracking-tight">ExamCraft.<span className="text-primary">AI</span></span> | |
| </div> | |
| <h2 className="text-3xl font-bold mb-2">Sign in</h2> | |
| <p className="text-muted-foreground mb-8"> | |
| Don't have an account? <Link to="/register" className="text-primary hover:underline font-medium">Create one</Link> | |
| </p> | |
| <form onSubmit={handleLogin} className="space-y-4"> | |
| <div className="relative"> | |
| <Mail className="absolute left-3 top-2.5 h-5 w-5 text-muted-foreground pointer-events-none z-10" /> | |
| <Input | |
| type="email" | |
| placeholder="Email Address" | |
| value={email} | |
| onChange={(e) => setEmail(e.target.value)} | |
| required | |
| className="pl-10 h-12 text-base" | |
| /> | |
| </div> | |
| <div className="relative mb-2"> | |
| <Lock className="absolute left-3 top-2.5 h-5 w-5 text-muted-foreground pointer-events-none z-10" /> | |
| <Input | |
| type="password" | |
| placeholder="Password" | |
| value={password} | |
| onChange={(e) => setPassword(e.target.value)} | |
| required | |
| className="pl-10 h-12 text-base" | |
| /> | |
| </div> | |
| <div className="flex justify-end pr-2 -mt-4 mb-6"> | |
| <Link to="/forgot-password" className="text-sm text-muted-foreground hover:text-primary transition-colors"> | |
| Forgot password? | |
| </Link> | |
| </div> | |
| <Button type="submit" size="lg" className="w-full glow-border" isLoading={isLoading}> | |
| Sign In <ArrowRight className="ml-2 h-4 w-4" /> | |
| </Button> | |
| </form> | |
| <div className="mt-8 flex items-center justify-center opacity-50 space-x-4"> | |
| <div className="h-px bg-border flex-1" /> | |
| <span className="text-xs uppercase tracking-wider font-semibold">Secure Login</span> | |
| <div className="h-px bg-border flex-1" /> | |
| </div> | |
| </div> | |
| </motion.div> | |
| </div> | |
| ); | |
| } | |