import React, { useState } from 'react'; import { useNavigate, Link } from 'react-router-dom'; import { useAuthStore } from '../store/authStore'; import { Eye, EyeOff, ArrowRight } from 'lucide-react'; export default function Login() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [emailError, setEmailError] = useState(''); const [showPassword, setShowPassword] = useState(false); const { signIn, isLoading } = useAuthStore(); const navigate = useNavigate(); const validateEmail = (email) => { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); }; const handleLogin = async (e) => { e.preventDefault(); if (!email || !password) { alert('Proszę wprowadzić email i hasło.'); return; } if (!validateEmail(email)) { setEmailError('Nieprawidłowy format adresu email'); return; } try { await signIn(email, password); navigate('/'); } catch (e) { alert("Błąd logowania: " + (e.response?.data?.message || e.message)); } }; if (isLoading) { return (