|
| 1 | +import { Grid, TextInput, Button, PasswordInput, Divider, Text, Image } from "@mantine/core"; |
| 2 | +import { useForm } from "@mantine/form"; |
| 3 | +import { Link } from "react-router"; |
| 4 | +import logo from "../assets/images/logo.svg"; |
| 5 | + |
| 6 | +export function meta() { |
| 7 | + return [ |
| 8 | + { title: "PeerPrep - Login" }, |
| 9 | + { name: "description", content: "Welcome to PeerPrep!" }, |
| 10 | + ]; |
| 11 | +} |
| 12 | + |
| 13 | +export default function Login() { |
| 14 | + const form = useForm({ |
| 15 | + initialValues: { |
| 16 | + email: "", |
| 17 | + password: "", |
| 18 | + }, |
| 19 | + |
| 20 | + validate: { |
| 21 | + email: (value) => (/^\S+@\S+$/.test(value) ? null : "Invalid email"), |
| 22 | + password: (value) => |
| 23 | + value.length < 6 ? "Password must be at least 6 characters" : null, |
| 24 | + }, |
| 25 | + }); |
| 26 | + |
| 27 | + return ( |
| 28 | + <Grid> |
| 29 | + <Grid.Col span={12}> |
| 30 | + <Grid justify="center" gutter={"xs"} mt={{ base: 20, md: 200 }}> |
| 31 | + <Grid.Col span={{ base: 12, md: 4 }}> |
| 32 | + <Image src={logo} alt="PeerPrep Logo" /> |
| 33 | + <form onSubmit={form.onSubmit((values) => console.log(values))}> |
| 34 | + <Grid.Col span={12}> |
| 35 | + <TextInput |
| 36 | + label="Email" |
| 37 | + placeholder="Enter your email" |
| 38 | + type="email" |
| 39 | + key={form.key("email")} |
| 40 | + {...form.getInputProps('email')} |
| 41 | + error={undefined} |
| 42 | + /> |
| 43 | + </Grid.Col> |
| 44 | + <Grid.Col span={12}> |
| 45 | + <PasswordInput |
| 46 | + label="Password" |
| 47 | + placeholder="Enter your password" |
| 48 | + type="password" |
| 49 | + key={form.key("password")} |
| 50 | + {...form.getInputProps('password')} |
| 51 | + /> |
| 52 | + </Grid.Col> |
| 53 | + <Grid.Col span={12} mt="md"> |
| 54 | + <Button type="submit" fullWidth autoContrast> |
| 55 | + Login |
| 56 | + </Button> |
| 57 | + </Grid.Col> |
| 58 | + </form> |
| 59 | + <Grid.Col span={12} mt="md"> |
| 60 | + <Divider my="xs" /> |
| 61 | + </Grid.Col> |
| 62 | + <Grid.Col span={12} mt="md" className="text-center"> |
| 63 | + <Text span>Don't have an account? </Text><Link to="/signup"><Text span td="underline" c="blue" className="cursor-pointer">Sign up!</Text></Link> |
| 64 | + </Grid.Col> |
| 65 | + </Grid.Col> |
| 66 | + </Grid> |
| 67 | + </Grid.Col> |
| 68 | + </Grid> |
| 69 | + ); |
| 70 | +} |
0 commit comments