import React, { useState } from 'react'; const LoginPage = () => { const [loginType, setLoginType] = useState('email'); // 'email' or 'phone' const [identifier, setIdentifier] = useState(''); const [password, setPassword] = useState(''); const handleLogin = (e) => { e.preventDefault(); if (!identifier || !password) { alert('Please fill in all fields.'); return; } if (loginType === 'email') { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(identifier)) { alert('Please enter a valid email address.'); return; } } else { // Basic phone number validation (e.g., starts with + and has digits) const phoneRegex = /^\+?[0-9\s-]{8,}$/; if (!phoneRegex.test(identifier)) { alert('Please enter a valid phone number.'); return; } } console.log(`Attempting to log in with ${loginType}: ${identifier}`); // In a real application, you would make an API call here alert(`Login successful with ${loginType}!`); }; return (

Welcome Back

Login to access your account.

setIdentifier(e.target.value)} className="w-full px-4 py-2 text-gray-900 bg-white border border-gray-300 rounded-lg appearance-none focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white" placeholder={loginType === 'email' ? 'name@company.com' : '+1 (555) 000-0000'} />
setPassword(e.target.value)} className="w-full px-4 py-2 text-gray-900 bg-white border border-gray-300 rounded-lg appearance-none focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white" placeholder="Password" />
Forgot password?
); }; export default LoginPage;