import React, { useState, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import { User, Briefcase, Lock, ArrowRight, AlertCircle, Home } from 'lucide-react';
import { SpotlightCard } from '../components/SpotlightCard';
// Rainbow Button Component
const RainbowButton = ({ children, onClick, type = "button", className = "" }) => {
const btnRef = useRef(null);
const [position, setPosition] = useState({ x: 0, y: 0 });
const [opacity, setOpacity] = useState(0);
const handleMouseMove = (e) => {
if (!btnRef.current) return;
const rect = btnRef.current.getBoundingClientRect();
setPosition({ x: e.clientX - rect.left, y: e.clientY - rect.top });
};
return (
);
};
const Login = () => {
const [isEmployee, setIsEmployee] = useState(false);
const [identifier, setIdentifier] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const { login } = useAuth();
const navigate = useNavigate();
const handleLogin = (e) => {
e.preventDefault();
setError('');
if (!identifier || !password) {
setError('Please fill in all fields');
return;
}
const type = isEmployee ? 'employee' : 'customer';
const result = login(identifier, password, type);
if (result.success) {
if (type === 'customer') {
navigate('/');
} else {
navigate('/emp/fa/dashboard'); // Default for employees
}
} else {
setError(result.message);
}
};
const fillDemo = (role) => {
if (role === 'customer') {
setIsEmployee(false);
setIdentifier('alice');
setPassword('password');
} else if (role === 'agent') {
setIsEmployee(true);
setIdentifier('FA001');
setPassword('password');
} else if (role === 'admin') {
setIsEmployee(true);
setIdentifier('ADM01');
setPassword('password');
}
};
return (
{/* Subtle Ambient Background */}
Welcome Back
Sign in to your Plano Realty account
{/* Neo-Toggle */}
{/* Demo Quick Links */}
Quick Demo Access
);
};
export default Login;