chore: codify React component style

This commit is contained in:
2026-08-25 15:33:20 +03:00
parent 268acdf2e1
commit d10e1dd182
65 changed files with 711 additions and 365 deletions
+9 -7
View File
@@ -1,5 +1,6 @@
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";
@@ -50,14 +51,13 @@ const registerSchema = loginSchema.refine(
}),
);
type AuthFormValues = z.input<typeof loginSchema>;
export function AuthForm({
register,
onSubmit,
}: {
type AuthFormProps = {
register?: true;
onSubmit: (email: string, password: string) => Promise<void>;
}) {
};
const AuthForm: FC<AuthFormProps> = (props) => {
const { register, onSubmit } = props;
const { t } = useTranslation();
const schema = register ? registerSchema : loginSchema;
const methods = useForm<AuthFormValues>({
@@ -114,4 +114,6 @@ export function AuthForm({
</form>
</FormProvider>
);
}
};
export { AuthForm };
+6 -2
View File
@@ -1,13 +1,15 @@
import type { FC } from "react";
import { useLocation, useNavigate } from "react-router";
import { useAuth } from "../model/auth";
import { AuthForm } from "./AuthForm";
export function LoginForm() {
const LoginForm: FC = () => {
const { login } = useAuth();
const navigate = useNavigate();
const location = useLocation();
const returnTo =
(location.state as { returnTo?: string } | null)?.returnTo ?? "/accounts";
return (
<AuthForm
onSubmit={async (email, password) => {
@@ -16,4 +18,6 @@ export function LoginForm() {
}}
/>
);
}
};
export { LoginForm };
+6 -2
View File
@@ -1,13 +1,15 @@
import type { FC } from "react";
import { useLocation, useNavigate } from "react-router";
import { useAuth } from "../model/auth";
import { AuthForm } from "./AuthForm";
export function RegisterForm() {
const RegisterForm: FC = () => {
const { register } = useAuth();
const navigate = useNavigate();
const location = useLocation();
const returnTo =
(location.state as { returnTo?: string } | null)?.returnTo ?? "/accounts";
return (
<AuthForm
register
@@ -17,4 +19,6 @@ export function RegisterForm() {
}}
/>
);
}
};
export { RegisterForm };