bazarr/frontend/src/pages/Authentication.tsx

67 lines
1.5 KiB
TypeScript
Raw Normal View History

import { useSystem } from "@/apis/hooks";
import { Environment } from "@/utilities";
2022-05-31 15:49:04 +00:00
import {
Avatar,
Button,
Card,
Container,
Divider,
PasswordInput,
Stack,
TextInput,
} from "@mantine/core";
import { useForm } from "@mantine/form";
2022-05-31 15:49:04 +00:00
import { FunctionComponent } from "react";
2021-03-25 14:22:43 +00:00
const Authentication: FunctionComponent = () => {
2022-05-31 15:49:04 +00:00
const { login } = useSystem();
2021-03-25 14:22:43 +00:00
2022-05-31 15:49:04 +00:00
const form = useForm({
initialValues: {
username: "",
password: "",
},
});
2021-03-25 14:22:43 +00:00
return (
2022-05-31 15:49:04 +00:00
<Container my="xl" size={400}>
<Card shadow="xl">
<Stack>
<Avatar
mx="auto"
size={64}
src={`${Environment.baseUrl}/images/logo128.png`}
2022-05-31 15:49:04 +00:00
></Avatar>
<Divider></Divider>
<form
onSubmit={form.onSubmit((values) => {
login(values);
})}
>
2022-05-31 15:49:04 +00:00
<Stack>
<TextInput
name="Username"
2021-03-25 14:22:43 +00:00
placeholder="Username"
required
2022-05-31 15:49:04 +00:00
{...form.getInputProps("username")}
></TextInput>
<PasswordInput
name="Password"
2021-03-25 14:22:43 +00:00
required
2022-05-31 15:49:04 +00:00
placeholder="Password"
{...form.getInputProps("password")}
></PasswordInput>
<Divider></Divider>
<Button fullWidth uppercase type="submit">
Login
</Button>
</Stack>
</form>
</Stack>
2021-03-25 14:22:43 +00:00
</Card>
2022-05-31 15:49:04 +00:00
</Container>
2021-03-25 14:22:43 +00:00
);
};
export default Authentication;