chore: finish frontend ESLint migration #18
Enable every plugin recommended preset and replace Biome with ESLint formatting. Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
This commit is contained in:
@@ -2,6 +2,7 @@ import { MantineProvider } from "@mantine/core";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AuthForm } from "./AuthForm";
|
||||
|
||||
describe("AuthForm", () => {
|
||||
@@ -10,7 +11,7 @@ describe("AuthForm", () => {
|
||||
render(
|
||||
<MantineProvider>
|
||||
<MemoryRouter>
|
||||
<AuthForm register onSubmit={onSubmit} />
|
||||
<AuthForm onSubmit={onSubmit} register />
|
||||
</MemoryRouter>
|
||||
</MantineProvider>,
|
||||
);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { FC } from "react";
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { Alert, Button, PasswordInput, Stack, TextInput } from "@mantine/core";
|
||||
import type { FC } from "react";
|
||||
import { useState } from "react";
|
||||
import { FormProvider, type Resolver, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
type AuthFormValues,
|
||||
loginSchema,
|
||||
@@ -13,12 +15,12 @@ import {
|
||||
import classes from "./AuthForm.module.css";
|
||||
|
||||
type AuthFormProps = {
|
||||
register?: true;
|
||||
onSubmit: (email: string, password: string) => Promise<void>;
|
||||
register?: true;
|
||||
};
|
||||
|
||||
const AuthForm: FC<AuthFormProps> = (props) => {
|
||||
const { register, onSubmit } = props;
|
||||
const { onSubmit, register } = props;
|
||||
const { t } = useTranslation();
|
||||
const schema = register ? registerSchema : loginSchema;
|
||||
const methods = useForm<AuthFormValues>({
|
||||
@@ -27,7 +29,7 @@ const AuthForm: FC<AuthFormProps> = (props) => {
|
||||
const {
|
||||
formState: { errors, isSubmitting },
|
||||
} = methods;
|
||||
const [submitError, setSubmitError] = useState<string | null>(null);
|
||||
const [submitError, setSubmitError] = useState<null | string>(null);
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
<form
|
||||
@@ -35,7 +37,8 @@ const AuthForm: FC<AuthFormProps> = (props) => {
|
||||
setSubmitError(null);
|
||||
try {
|
||||
await onSubmit(values.email, values.password);
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
setSubmitError(t("auth.requestError"));
|
||||
}
|
||||
})}
|
||||
@@ -60,7 +63,7 @@ const AuthForm: FC<AuthFormProps> = (props) => {
|
||||
/>
|
||||
)}
|
||||
{submitError && <Alert color="red">{submitError}</Alert>}
|
||||
<Button type="submit" loading={isSubmitting}>
|
||||
<Button loading={isSubmitting} type="submit">
|
||||
{t(register ? "auth.register" : "auth.login")}
|
||||
</Button>
|
||||
<Button
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Paper, Stack, Title } from "@mantine/core";
|
||||
import type { FC, PropsWithChildren } from "react";
|
||||
|
||||
import { Paper, Stack, Title } from "@mantine/core";
|
||||
|
||||
import classes from "./AuthPageLayout.module.css";
|
||||
|
||||
type AuthPageLayoutProps = PropsWithChildren<{ title: string }>;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { FC } from "react";
|
||||
|
||||
import { useLocation, useNavigate } from "react-router";
|
||||
|
||||
import { useAuth } from "../model/auth-context";
|
||||
import { AuthForm } from "./AuthForm/AuthForm";
|
||||
|
||||
@@ -7,8 +9,8 @@ const LoginForm: FC = () => {
|
||||
const { login } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const returnTo =
|
||||
(location.state as { returnTo?: string } | null)?.returnTo ?? "/accounts";
|
||||
const returnTo
|
||||
= (location.state as null | { returnTo?: string })?.returnTo ?? "/accounts";
|
||||
|
||||
return (
|
||||
<AuthForm
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { FC } from "react";
|
||||
|
||||
import { useLocation, useNavigate } from "react-router";
|
||||
|
||||
import { useAuth } from "../model/auth-context";
|
||||
import { AuthForm } from "./AuthForm/AuthForm";
|
||||
|
||||
@@ -7,16 +9,16 @@ const RegisterForm: FC = () => {
|
||||
const { register } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const returnTo =
|
||||
(location.state as { returnTo?: string } | null)?.returnTo ?? "/accounts";
|
||||
const returnTo
|
||||
= (location.state as null | { returnTo?: string })?.returnTo ?? "/accounts";
|
||||
|
||||
return (
|
||||
<AuthForm
|
||||
register
|
||||
onSubmit={async (email, password) => {
|
||||
await register(email, password);
|
||||
await navigate(returnTo, { replace: true });
|
||||
}}
|
||||
register
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user