WIP API
This commit is contained in:
@@ -15,11 +15,12 @@ const AuthPage = () => {
|
||||
const [rememberMe, setRememberMe] = useState(false);
|
||||
const [checkboxError, setCheckboxError] = useState(false);
|
||||
const [authError, setAuthError] = useState("");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const isEmailValid = emailRegex.test(email);
|
||||
const isFormValid = isEmailValid && password.length > 0;
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (!rememberMe) {
|
||||
@@ -32,9 +33,11 @@ const AuthPage = () => {
|
||||
|
||||
try {
|
||||
setAuthError("");
|
||||
login(email, password);
|
||||
setIsSubmitting(true);
|
||||
await login(email, password); // теперь это async
|
||||
} catch (err) {
|
||||
setAuthError(err.message || "Неверный логин или пароль");
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -111,27 +114,45 @@ const AuthPage = () => {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Ссылки */}
|
||||
<div className="flex justify-between text-[11px] font-montserrat font-bold text-[#FF6363] mt-5">
|
||||
{/* <button
|
||||
type="button"
|
||||
className="hover:underline"
|
||||
onClick={() => router.push("/recPassword")}
|
||||
>
|
||||
Забыли пароль?
|
||||
</button> */}
|
||||
<button
|
||||
type="button"
|
||||
className="hover:underline"
|
||||
onClick={() => router.push("/reg")}
|
||||
>
|
||||
Регистрация
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Кнопка Войти */}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={!isFormValid}
|
||||
className={`mt-4 w-full rounded-full py-2 text-center font-montserrat font-extrabold text-sm transition-colors
|
||||
disabled={!isFormValid || isSubmitting}
|
||||
className={` w-full rounded-full py-2 text-center font-montserrat font-extrabold text-sm transition-colors
|
||||
${
|
||||
isFormValid
|
||||
isFormValid && !isSubmitting
|
||||
? "bg-green-500 text-white hover:bg-green-600"
|
||||
: "bg-white text-[#C4C4C4] cursor-not-allowed"
|
||||
}`}
|
||||
>
|
||||
Войти
|
||||
{isSubmitting ? "Входим..." : "Войти"}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{/* Подсказка по тестовым логинам */}
|
||||
<div className="mt-4 text-[15px] text-white font-mонтserrat space-y-1">
|
||||
<p>Тестовые аккаунты:</p>
|
||||
<p>Пользователь: user@mail.com / user123</p>
|
||||
<p>Волонтёр: vol@mail.com / vol123</p>
|
||||
<p>Модератор: mod@mail.com / mod123</p>
|
||||
{/* Подсказка по тестовым логинам — можно убрать, когда перейдёшь на реальные аккаунты */}
|
||||
<div className="mt-4 text-[15px] text-white font-montserrat space-y-1">
|
||||
<p>Тестовые аккаунты (если настроены на бэке):</p>
|
||||
<p>Пользователь: user@mail.com / user123123</p>
|
||||
<p>Волонтёр: vol@mail.com / vol123123</p>
|
||||
<p>Модератор: mod@mail.com / mod123123</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user