@@ -30,6 +30,8 @@ import { useFormik } from 'formik';
3030import * as Yup from 'yup' ;
3131import {
3232 Alert ,
33+ Backdrop ,
34+ CircularProgress ,
3335 Divider ,
3436 IconButton ,
3537 InputAdornment ,
@@ -59,8 +61,11 @@ export default function SignIn(): React.ReactElement {
5961 const [ isSubmitted , setIsSubmitted ] = React . useState ( false ) ;
6062 const [ showPassword , setShowPassword ] = React . useState ( false ) ;
6163 const [ showNoEmailSnackbar , setShowNoEmailSnackbar ] = React . useState ( false ) ;
64+ const [ isOAuthLoading , setIsOAuthLoading ] = React . useState ( false ) ;
6265 const searchParams = useSearchParams ( ) ;
6366
67+ const isLoading = userProfileStatus === 'login_in' || isOAuthLoading ;
68+
6469 const SignInSchema = Yup . object ( ) . shape ( {
6570 email : Yup . string ( )
6671 . email ( 'Email format is invalid.' )
@@ -111,18 +116,22 @@ export default function SignIn(): React.ReactElement {
111116 const signInWithProvider = ( oauthProvider : OauthProvider ) : void => {
112117 const auth = getAuth ( ) ;
113118 const provider = oathProviders [ oauthProvider ] ;
119+ setIsOAuthLoading ( true ) ;
114120 signInWithPopup ( auth , provider )
115121 . then ( ( userCredential : UserCredential ) => {
116122 if ( ! userCredential . user . emailVerified ) {
117123 dispatch ( verifyEmail ( ) ) ;
118124 }
119125 if ( userCredential . user . email == null ) {
126+ setIsOAuthLoading ( false ) ;
120127 setShowNoEmailSnackbar ( true ) ;
121128 } else {
129+ setIsOAuthLoading ( false ) ;
122130 dispatch ( loginWithProvider ( { oauthProvider, userCredential } ) ) ;
123131 }
124132 } )
125133 . catch ( ( error ) => {
134+ setIsOAuthLoading ( false ) ;
126135 dispatch (
127136 loginFail ( {
128137 code : error . code ,
@@ -135,6 +144,13 @@ export default function SignIn(): React.ReactElement {
135144
136145 return (
137146 < Container component = 'main' maxWidth = 'xs' >
147+ < Backdrop
148+ open = { isLoading }
149+ sx = { { zIndex : ( theme ) => theme . zIndex . drawer + 1 } }
150+ data-testid = 'signin-loading-overlay'
151+ >
152+ < CircularProgress aria-label = 'Signing in...' />
153+ </ Backdrop >
138154 < Snackbar
139155 open = { showNoEmailSnackbar }
140156 anchorOrigin = { { vertical : 'top' , horizontal : 'center' } }
0 commit comments