mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 20:55:42 +00:00
* wip * feat: finalize totp gen code * refactor: split login screen and forms * feat: add totp logic and ui * refactor: make totp pending expiry time fixed * refactor: skip all checks when disable continue is enabled * fix: fix cli not exiting on invalid input
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { TextInput, PasswordInput, Button } from "@mantine/core";
|
|
import { useForm, zodResolver } from "@mantine/form";
|
|
import { LoginFormValues, loginSchema } from "../../schemas/login-schema";
|
|
|
|
interface LoginFormProps {
|
|
isLoading: boolean;
|
|
onSubmit: (values: LoginFormValues) => void;
|
|
}
|
|
|
|
export const LoginForm = (props: LoginFormProps) => {
|
|
const { isLoading, onSubmit } = props;
|
|
|
|
const form = useForm({
|
|
mode: "uncontrolled",
|
|
initialValues: {
|
|
username: "",
|
|
password: "",
|
|
},
|
|
validate: zodResolver(loginSchema),
|
|
});
|
|
|
|
return (
|
|
<form onSubmit={form.onSubmit(onSubmit)}>
|
|
<TextInput
|
|
label="Username"
|
|
placeholder="user@example.com"
|
|
required
|
|
disabled={isLoading}
|
|
key={form.key("username")}
|
|
{...form.getInputProps("username")}
|
|
/>
|
|
<PasswordInput
|
|
label="Password"
|
|
placeholder="password"
|
|
required
|
|
mt="md"
|
|
disabled={isLoading}
|
|
key={form.key("password")}
|
|
{...form.getInputProps("password")}
|
|
/>
|
|
<Button fullWidth mt="xl" type="submit" loading={isLoading}>
|
|
Login
|
|
</Button>
|
|
</form>
|
|
);
|
|
};
|