File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
src/modules/account/components Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { medusaClient } from "@lib/config"
2
2
import { LOGIN_VIEW , useAccount } from "@lib/context/account-context"
3
3
import Button from "@modules/common/components/button"
4
4
import Input from "@modules/common/components/input"
5
+ import Spinner from "@modules/common/icons/spinner"
5
6
import { useRouter } from "next/router"
6
7
import { useState } from "react"
7
8
import { FieldValues , useForm } from "react-hook-form"
@@ -24,11 +25,11 @@ const Login = () => {
24
25
const {
25
26
register,
26
27
handleSubmit,
27
- formState : { errors } ,
28
+ formState : { errors, isSubmitting } ,
28
29
} = useForm < SignInCredentials > ( )
29
30
30
31
const onSubmit = handleSubmit ( async ( credentials ) => {
31
- medusaClient . auth
32
+ await medusaClient . auth
32
33
. authenticate ( credentials )
33
34
. then ( ( ) => {
34
35
refetchCustomer ( )
@@ -39,6 +40,11 @@ const Login = () => {
39
40
40
41
return (
41
42
< div className = "max-w-sm w-full flex flex-col items-center" >
43
+ { isSubmitting && (
44
+ < div className = "z-10 fixed inset-0 bg-white bg-opacity-50 flex items-center justify-center" >
45
+ < Spinner size = { 24 } />
46
+ </ div >
47
+ ) }
42
48
< h1 className = "text-large-semi uppercase mb-6" > Welcome back</ h1 >
43
49
< p className = "text-center text-base-regular text-gray-700 mb-8" >
44
50
Sign in to access an enhanced shopping experience.
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { medusaClient } from "@lib/config"
2
2
import { LOGIN_VIEW , useAccount } from "@lib/context/account-context"
3
3
import Button from "@modules/common/components/button"
4
4
import Input from "@modules/common/components/input"
5
+ import Spinner from "@modules/common/icons/spinner"
5
6
import Link from "next/link"
6
7
import { useRouter } from "next/router"
7
8
import { useState } from "react"
@@ -28,11 +29,11 @@ const Register = () => {
28
29
const {
29
30
register,
30
31
handleSubmit,
31
- formState : { errors } ,
32
+ formState : { errors, isSubmitting } ,
32
33
} = useForm < RegisterCredentials > ( )
33
34
34
35
const onSubmit = handleSubmit ( async ( credentials ) => {
35
- medusaClient . customers
36
+ await medusaClient . customers
36
37
. create ( credentials )
37
38
. then ( ( ) => {
38
39
refetchCustomer ( )
@@ -43,6 +44,11 @@ const Register = () => {
43
44
44
45
return (
45
46
< div className = "max-w-sm flex flex-col items-center mt-12" >
47
+ { isSubmitting && (
48
+ < div className = "z-10 fixed inset-0 bg-white bg-opacity-50 flex items-center justify-center" >
49
+ < Spinner size = { 24 } />
50
+ </ div >
51
+ ) }
46
52
< h1 className = "text-large-semi uppercase mb-6" > Become a Acme Member</ h1 >
47
53
< p className = "text-center text-base-regular text-gray-700 mb-4" >
48
54
Create your Acme Member profile, and get access to an enhanced shopping
You can’t perform that action at this time.
0 commit comments