From 5f1e06a793d48bbac3b05519450e3be7d398bb64 Mon Sep 17 00:00:00 2001 From: houseassassin Date: Wed, 20 May 2026 12:26:15 +0300 Subject: [PATCH] feat: Login and Register pages Co-Authored-By: Claude Sonnet 4.6 --- src/pages/Login.tsx | 62 +++++++++++++++++++++++++++++++++++++++++- src/pages/Register.tsx | 59 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index e791fc2..11fabb6 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1 +1,61 @@ -export default function Login() { return
Login
; } +import { useState } from "react"; +import { useNavigate, Link } from "react-router-dom"; +import { Shield } from "lucide-react"; +import { api } from "../api/client"; +import { useAuthStore } from "../store/auth"; +import { Button } from "../components/ui/Button"; +import { Input } from "../components/ui/Input"; +import { GlassCard } from "../components/ui/GlassCard"; + +export default function Login() { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + const [loading, setLoading] = useState(false); + const { setAuth } = useAuthStore(); + const navigate = useNavigate(); + + async function handleLogin(e: React.FormEvent) { + e.preventDefault(); + setError(""); + setLoading(true); + const res = await api.login(email, password); + setLoading(false); + if (!res.ok) { setError(res.error || "Ошибка входа"); return; } + setAuth(res.access_token, res.refresh_token, res.user); + navigate("/dashboard"); + } + + return ( +
+
+
+
+ +
+
+ +
+

Войти в Aura Store

+

Доступ к личному кабинету

+
+ +
+
+ email +
+
+ +
+ setEmail(e.target.value)} placeholder="you@example.com" required /> + setPassword(e.target.value)} placeholder="••••••••" required error={error} /> + +
+ +

+ Нет аккаунта? Зарегистрироваться +

+ +
+ ); +} diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 1c84e19..75df22f 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -1 +1,58 @@ -export default function Register() { return
Register
; } +import { useState } from "react"; +import { useNavigate, Link } from "react-router-dom"; +import { Shield } from "lucide-react"; +import { api } from "../api/client"; +import { useAuthStore } from "../store/auth"; +import { Button } from "../components/ui/Button"; +import { Input } from "../components/ui/Input"; +import { GlassCard } from "../components/ui/GlassCard"; + +export default function Register() { + const [name, setName] = useState(""); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + const [loading, setLoading] = useState(false); + const { setAuth } = useAuthStore(); + const navigate = useNavigate(); + + async function handleRegister(e: React.FormEvent) { + e.preventDefault(); + setError(""); + if (password.length < 6) { setError("Пароль минимум 6 символов"); return; } + setLoading(true); + const res = await api.register(email, password, name); + setLoading(false); + if (!res.ok) { setError(res.error || "Ошибка регистрации"); return; } + setAuth(res.access_token, res.refresh_token, res.user); + navigate("/dashboard"); + } + + return ( +
+
+
+
+ +
+
+ +
+

Создать аккаунт

+

Регистрация в Aura Store

+
+ +
+ setName(e.target.value)} placeholder="Ваше имя" /> + setEmail(e.target.value)} placeholder="you@example.com" required /> + setPassword(e.target.value)} placeholder="Минимум 6 символов" required error={error} /> + +
+ +

+ Уже есть аккаунт? Войти +

+
+
+ ); +}