import React, { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { useNavigate } from 'react-router-dom'; import { Lock, ChevronRight, ShieldCheck, AlertCircle, Eye, EyeOff, User, Zap } from 'lucide-react'; import { useAuthContext } from '@/components/shared/AuthProvider'; import logo from '@/assets/Img/Util/iT_Guys/logo1.png'; /** * LoginView - Versão Premium para o Workspace iTGUYS * Inspirado no design "Reproduced" com split-screen e alta fidelidade visual. */ export const LoginView = () => { const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const [step, setStep] = useState(1); // 1: Login, 2: OTP const navigate = useNavigate(); const [otp, setOtp] = useState(['', '', '', '', '', '']); const otpRefs = React.useRef([]); const handleLogin = async (e) => { e.preventDefault(); setIsLoading(true); setError(''); // Senhas de teste permitidas const allowedPasswords = ['itguys@2026', 'teste@finance', 'admin']; setTimeout(() => { if (allowedPasswords.includes(password)) { sessionStorage.setItem('workspace_access', 'granted'); setStep(2); setIsLoading(false); } else { setError('Chave de acesso inválida ou expirada.'); setIsLoading(false); } }, 800); }; const handleOtpChange = (index, value) => { if (!/^\d*$/.test(value)) return; const newOtp = [...otp]; newOtp[index] = value.slice(-1); setOtp(newOtp); // Auto focus next if (value && index < 5) { otpRefs.current[index + 1]?.focus(); } // Auto submit if full if (newOtp.every(digit => digit !== '')) { setTimeout(() => handleFinalize(), 600); } }; const handleKeyDown = (index, e) => { if (e.key === 'Backspace' && !otp[index] && index > 0) { otpRefs.current[index - 1]?.focus(); } }; const handleFinalize = () => { navigate('/plataforma/workspace'); window.location.reload(); }; return (
{/* Left Panel - Brand & Identity */}
{/* Background Effects */}
{/* Logo Area */} iTGUYS Logo

WORKSPACE EXPERIENCE

Gestão Estratégica & Inteligência Financeira

{/* Floating Badges */}
Encrypted
Versão 2026.1
{/* Right Panel - Interactive Form */}
{/* Decorative Grid */}
{step === 1 ? (
Restricted Access

Identifique-se

Insira sua chave mestra para acessar o sistema.

{/* User field (Readonly for Context) */}
{/* Password Field */}
setPassword(e.target.value)} placeholder="Chave de Acesso" autoFocus className="w-full bg-white/[0.05] border border-white/10 rounded-2xl py-4 pl-12 pr-12 text-white text-sm font-bold focus:ring-2 focus:ring-[#22bb6c]/50 focus:border-[#22bb6c] focus:bg-white/[0.08] outline-none transition-all placeholder:text-white/20 tracking-[0.2em]" />
{error && ( {error} )}
Logo iTGUYS Core Systems v4
) : ( /* Step 2 - Digite o Código (Reference Image 1 style) */

Digite o Código

{otp.map((digit, i) => ( otpRefs.current[i] = el} type="text" maxLength={1} value={digit} onChange={(e) => handleOtpChange(i, e.target.value)} onKeyDown={(e) => handleKeyDown(i, e)} autoFocus={i === 0} className="w-16 h-20 bg-white rounded-[20px] text-[#002137] text-4xl font-black text-center outline-none focus:ring-4 focus:ring-[#22bb6c]/50 transition-all shadow-lg" /> ))}
)}
{/* Decorative Blur and Logo Overlay for Mobile (if any) */}
); };