diff --git a/src/admin/auth/LoginPage.jsx b/src/admin/auth/LoginPage.jsx new file mode 100644 index 0000000..17ecc8f --- /dev/null +++ b/src/admin/auth/LoginPage.jsx @@ -0,0 +1,110 @@ +import React, { useState } from 'react'; +import { useNavigate, useLocation } from 'react-router-dom'; +import { Shield } from 'lucide-react'; +import { useAuth } from './useAuth'; + +const LoginPage = () => { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [error, setError] = useState(''); + const [submitting, setSubmitting] = useState(false); + const { login } = useAuth(); + const navigate = useNavigate(); + const location = useLocation(); + const from = location.state?.from?.pathname || '/admin/kanban'; + + const handleSubmit = async (e) => { + e.preventDefault(); + setSubmitting(true); + setError(''); + const { error } = await login(email, password); + if (error) { + setError('Неверный email или пароль'); + setSubmitting(false); + } else { + navigate(from, { replace: true }); + } + }; + + const inputStyle = { + width: '100%', padding: '14px', + background: 'var(--bg-lighter)', + border: '2px solid var(--border-light)', + borderRadius: '8px', + color: 'var(--text-main)', + fontSize: '1rem', + outline: 'none', + fontFamily: 'var(--font-body)', + boxSizing: 'border-box', + }; + + const labelStyle = { + display: 'block', marginBottom: '8px', + fontSize: '0.85rem', fontWeight: 700, + color: 'var(--text-muted)', textTransform: 'uppercase', letterSpacing: '0.5px', + }; + + return ( +