feat(LoginForm): add isLoading check to LoginForm, add new test cases

This commit is contained in:
Ilia Mashkov
2026-03-24 20:03:34 +03:00
parent c006a94c4d
commit 70bcf7fdcf
2 changed files with 22 additions and 3 deletions

View File

@@ -1,4 +1,8 @@
import { selectFormValid, useAuthStore } from "../../model";
import {
selectFormValid,
selectStatusIsLoading,
useAuthStore,
} from "../../model";
import type { SubmitEvent, ChangeEvent } from "react";
/**
@@ -8,6 +12,9 @@ export function LoginForm() {
const { formData, setEmail, setPassword, login } = useAuthStore();
const formValid = useAuthStore(selectFormValid);
const isLoading = useAuthStore(selectStatusIsLoading);
const disabled = !formValid || isLoading;
const handleEmailChange = (e: ChangeEvent<HTMLInputElement>) => {
setEmail(e.target.value);
@@ -36,7 +43,7 @@ export function LoginForm() {
value={formData?.password?.value ?? ""}
onChange={handlePasswordChange}
/>
<button type="submit" disabled={!formValid}>
<button type="submit" disabled={disabled}>
Login
</button>
</form>