|
1 |
| -import { useEffect, FormEventHandler } from "react"; |
2 |
| -import Checkbox from "@/Components/Checkbox"; |
| 1 | +import LoginForm from "@/Components/forms/LoginForm"; |
3 | 2 | import GuestLayout from "@/Layouts/GuestLayout";
|
4 |
| -import InputError from "@/Components/InputError"; |
5 |
| -import InputLabel from "@/Components/InputLabel"; |
6 |
| -import PrimaryButton from "@/Components/PrimaryButton"; |
7 |
| -import TextInput from "@/Components/TextInput"; |
8 |
| -import { Head, Link, useForm } from "@inertiajs/react"; |
| 3 | +import { Head } from "@inertiajs/react"; |
9 | 4 |
|
10 | 5 | export default function Login({ status }: { status?: string }) {
|
11 |
| - const { data, setData, post, processing, errors } = useForm({ |
12 |
| - username: "", |
13 |
| - password: "", |
14 |
| - remember: false, |
15 |
| - }); |
16 |
| - |
17 |
| - const submit: FormEventHandler = (e) => { |
18 |
| - e.preventDefault(); |
19 |
| - |
20 |
| - post(route("login")); |
21 |
| - }; |
22 |
| - |
23 | 6 | return (
|
24 | 7 | <GuestLayout>
|
25 | 8 | <Head title="Log in" />
|
26 |
| - |
27 | 9 | {status && (
|
28 | 10 | <div className="mb-4 font-medium text-sm text-green-600">
|
29 | 11 | {status}
|
30 | 12 | </div>
|
31 | 13 | )}
|
32 |
| - |
33 |
| - <form onSubmit={submit}> |
34 |
| - <div className="mt-4"> |
35 |
| - <InputLabel htmlFor="username" value="Username" /> |
36 |
| - |
37 |
| - <TextInput |
38 |
| - id="username" |
39 |
| - type="username" |
40 |
| - name="username" |
41 |
| - value={data.username} |
42 |
| - className="mt-1 block w-full" |
43 |
| - autoComplete="username" |
44 |
| - onChange={(e) => setData("username", e.target.value)} |
45 |
| - /> |
46 |
| - |
47 |
| - <InputError message={errors.username} className="mt-2" /> |
48 |
| - </div> |
49 |
| - |
50 |
| - <div className="mt-4"> |
51 |
| - <InputLabel htmlFor="password" value="Password" /> |
52 |
| - |
53 |
| - <TextInput |
54 |
| - id="password" |
55 |
| - type="password" |
56 |
| - name="password" |
57 |
| - value={data.password} |
58 |
| - className="mt-1 block w-full" |
59 |
| - autoComplete="current-password" |
60 |
| - onChange={(e) => setData("password", e.target.value)} |
61 |
| - /> |
62 |
| - |
63 |
| - <InputError message={errors.password} className="mt-2" /> |
64 |
| - </div> |
65 |
| - |
66 |
| - <div className="block mt-4"> |
67 |
| - <label className="flex items-center"> |
68 |
| - <Checkbox |
69 |
| - name="remember" |
70 |
| - checked={data.remember} |
71 |
| - onChange={(e) => |
72 |
| - setData("remember", e.target.checked) |
73 |
| - } |
74 |
| - /> |
75 |
| - <span className="ms-2 text-sm text-slate-600 dark:text-slate-400"> |
76 |
| - Remember me |
77 |
| - </span> |
78 |
| - </label> |
79 |
| - </div> |
80 |
| - |
81 |
| - <div className="flex items-center justify-end mt-4"> |
82 |
| - <PrimaryButton className="ms-4" disabled={processing}> |
83 |
| - Log in |
84 |
| - </PrimaryButton> |
85 |
| - </div> |
86 |
| - </form> |
| 14 | + <LoginForm /> |
87 | 15 | </GuestLayout>
|
88 | 16 | );
|
89 | 17 | }
|
0 commit comments