import React, { useState, FormEvent } from 'react'; import { Box, Button, TextField, Link, Typography, Stack, Divider, } from '@mui/material'; import { Link as RouterLink } from 'react-router-dom'; import GoogleIcon from '@mui/icons-material/Google'; import FacebookIcon from '@mui/icons-material/Facebook'; const LoginForm: React.FC = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [errors, setErrors] = useState<{ email?: string; password?: string }>({}); const validate = () => { const newErrors: { email?: string; password?: string } = {}; if (!email) { newErrors.email = 'Email is required'; } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { newErrors.email = 'Invalid email address'; } if (!password) { newErrors.password = 'Password is required'; } else if (password.length < 6) { newErrors.password = 'Password must be at least 6 characters'; } setErrors(newErrors); return Object.keys(newErrors).length === 0; }; const handleSubmit = (e: FormEvent) => { e.preventDefault(); if (!validate()) return; console.log('Submitting', { email, password }); // Placeholder for actual authentication logic }; const handleThirdPartyLogin = (provider: string) => { console.log(`Logging in with ${provider}`); // Placeholder for third‑party auth }; return ( Sign In setEmail(e.target.value)} error={!!errors.email} helperText={errors.email} /> setPassword(e.target.value)} error={!!errors.password} helperText={errors.password} /> Forgot password? Register or ); }; export default LoginForm;