File tree 4 files changed +29
-21
lines changed
4 files changed +29
-21
lines changed Original file line number Diff line number Diff line change 1
1
import { Suspense } from "react" ;
2
2
import { Loader } from "@/ui/atoms/Loader" ;
3
- import { LoginForm } from "@/ui/components/LoginForm" ;
3
+ import { LoginForm } from "@/ui/components/LoginForm/LoginForm " ;
4
4
5
5
export default function LoginPage ( ) {
6
6
return (
Original file line number Diff line number Diff line change 1
1
import { CurrentUserOrderListDocument } from "@/gql/graphql" ;
2
2
import { executeGraphQL } from "@/lib/graphql" ;
3
- import { LoginForm } from "@/ui/components/LoginForm" ;
3
+ import { LoginForm } from "@/ui/components/LoginForm/LoginForm " ;
4
4
import { OrderListItem } from "@/ui/components/OrderListItem" ;
5
5
6
6
export default async function OrderPage ( ) {
Original file line number Diff line number Diff line change
1
+ import { LoginButton } from "./components/LoginButton" ;
1
2
import { saleorAuthClient } from "@/app/config" ;
2
3
3
4
export async function LoginForm ( ) {
4
5
return (
5
6
< div className = "mx-auto mt-16 w-full max-w-lg" >
6
7
< form
7
- className = "rounded border p-8 shadow-md"
8
+ className = "flex flex-col gap-y-2 rounded border p-8 shadow-md"
8
9
action = { async ( formData ) => {
9
10
"use server" ;
10
11
@@ -23,39 +24,30 @@ export async function LoginForm() {
23
24
}
24
25
} }
25
26
>
26
- < div className = "mb-2" >
27
- < label className = "sr-only" htmlFor = "email" >
28
- Email
29
- </ label >
27
+ < label >
28
+ < span className = "sr-only" > Email</ span >
30
29
< input
31
30
type = "email"
32
31
name = "email"
33
32
placeholder = "Email"
34
33
className = "w-full rounded border bg-neutral-50 px-4 py-2"
34
+ required
35
35
/>
36
- </ div >
37
- < div className = "mb-4" >
38
- < label className = "sr-only" htmlFor = "password" >
39
- Password
40
- </ label >
36
+ </ label >
37
+ < label >
38
+ < span className = "sr-only" > Password</ span >
41
39
< input
42
40
type = "password"
43
41
name = "password"
44
42
placeholder = "Password"
45
43
autoCapitalize = "off"
46
44
autoComplete = "off"
47
45
className = "w-full rounded border bg-neutral-50 px-4 py-2"
46
+ required
48
47
/>
49
- </ div >
50
-
51
- < button
52
- className = "rounded bg-neutral-800 px-4 py-2 text-neutral-200 hover:bg-neutral-700"
53
- type = "submit"
54
- >
55
- Log In
56
- </ button >
48
+ </ label >
49
+ < LoginButton />
57
50
</ form >
58
- < div > </ div >
59
51
</ div >
60
52
) ;
61
53
}
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { useFormStatus } from "react-dom" ;
4
+
5
+ export const LoginButton = ( ) => {
6
+ const { pending } = useFormStatus ( ) ;
7
+ return (
8
+ < button
9
+ className = "mt-2 self-start rounded bg-neutral-800 px-4 py-2 text-neutral-200 hover:bg-neutral-700 aria-disabled:opacity-80"
10
+ type = "submit"
11
+ aria-disabled = { pending }
12
+ >
13
+ { pending ? "Processing..." : "Log In" }
14
+ </ button >
15
+ ) ;
16
+ } ;
You can’t perform that action at this time.
0 commit comments