1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import Image from 'next/image' ;
33import logo from '../../../public/images/logo.png' ;
44import Link from 'next/link' ;
55import MiniFooter from '@/components/global/minifooter' ;
6- import { signIn , useSession } from 'next-auth/react' ;
7- import { useRouter } from 'next/router' ;
6+ import { signIn , useSession } from 'next-auth/react' ;
7+ import { useRouter } from 'next/router' ;
88import Spinner from '@/components/common/Spinner' ;
9- import { mockProviders } from 'next-auth/client/__tests__/helpers/mocks' ;
9+ import { mockProviders } from 'next-auth/client/__tests__/helpers/mocks' ;
1010import callbackUrl = mockProviders . github . callbackUrl ;
11- import { TextField } from '@mui/material' ;
11+ import { TextField } from '@mui/material' ;
1212
1313const LoginComponent = ( ) => {
14- const { data : session , status, update } = useSession ( ) ;
14+ const { data : session , status, update} = useSession ( ) ;
1515 const [ email , setEmail ] = useState ( '' ) ;
1616 const [ password , setPassword ] = useState ( '' ) ;
1717 const [ successMessage , setSuccessMessage ] = useState ( '' ) ;
1818 const router = useRouter ( ) ;
1919 const [ errorMessage , setErrorMessage ] = useState ( '' ) ;
2020 const [ loading , setLoading ] = useState ( false ) ;
21- const { query } = router ;
22-
23- console . log ( 'session' , session ) ;
21+ const { query} = router ;
2422
2523 const handleLoginWithGoogle = async ( ) => {
2624 try {
@@ -49,7 +47,7 @@ const LoginComponent = () => {
4947 email,
5048 password,
5149 redirect : true ,
52- callbackUrl : query ?. callBack ? `http://localhost:3000 ${ query ?. callBack } ` : 'http://localhost:3000 ' ,
50+ callbackUrl : query ?. callBack ? `${ query ?. callBack } ` : '/ ' ,
5351 } ) ;
5452 console . log ( 'signInResponse:' , signInResponse ) ;
5553 if ( signInResponse ?. error ) {
@@ -68,41 +66,43 @@ const LoginComponent = () => {
6866 // }, []
6967 // )
7068 return (
71- < div className = "main-box bg-dark-600" style = { { height : 'auto !important' , minHeight : '100vh' } } >
72- < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' } } >
73- < Image src = { logo } alt = "logo" className = "mt-10 text-center" />
74- < div className = "px-10 py-5 bg-white rounded whitebox mt-11" style = { { height : '546px' , width : '464px' } } >
75- < p className = "mt-4 text-xl text-center text-black font-weight-bold" style = { { fontSize : '1.4rem' } } >
69+ < div className = "main-box bg-dark-600" style = { { height : 'auto !important' , minHeight : '100vh' } } >
70+ < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' } } >
71+ < Image src = { logo } alt = "logo" className = "mt-10 text-center" />
72+ < div className = "px-10 py-5 bg-white rounded whitebox mt-11" style = { { height : '546px' , width : '464px' } } >
73+ < p className = "mt-4 text-xl text-center text-black font-weight-bold" style = { { fontSize : '1.4rem' } } >
7674 Login
7775 </ p >
7876 { errorMessage && (
79- < div className = "relative block w-full p-4 mt-5 text-base leading-5 text-white bg-red-500 rounded-lg opacity-100 font-regular" >
77+ < div
78+ className = "relative block w-full p-4 mt-5 text-base leading-5 text-white bg-red-500 rounded-lg opacity-100 font-regular" >
8079 { errorMessage }
8180 </ div >
8281 ) }
8382 { successMessage && (
84- < div className = "relative block w-full p-4 mt-5 text-base leading-5 text-white bg-green-500 rounded-lg opacity-100 font-regular" >
83+ < div
84+ className = "relative block w-full p-4 mt-5 text-base leading-5 text-white bg-green-500 rounded-lg opacity-100 font-regular" >
8585 { successMessage }
8686 </ div >
8787 ) }
8888 { loading && (
8989 < div className = { 'align-items-center d-flex flex justify-center mt-3' } >
90- < Spinner height = { '1rem' } width = { '1rem' } />
90+ < Spinner height = { '1rem' } width = { '1rem' } />
9191 </ div >
9292 ) }
9393 < button
9494 type = "button"
9595 onClick = { ( ) => handleLoginWithGoogle ( ) }
9696 className = "w-full mt-5 text-center hidden justify-center focus:ring-0 focus:outline-none rounded border border-dark-200 md:text-md sm:text-sm text-[10px] px-5 py-3 inline-flex items-center mb-2"
9797 >
98- < img src = "/images/google.svg" alt = "" />
98+ < img src = "/images/google.svg" alt = "" />
9999 < span className = "uppercase font-medium text-dark-600 ml-1 sm:ml-2 tracking-[1.5px]" > continue with google</ span >
100100 </ button >
101101
102102 { /* <p className="mt-5 text-center text-black text-md font-weight-bold">or</p> */ }
103- < br />
104- < br />
105- < br />
103+ < br />
104+ < br />
105+ < br />
106106 < TextField
107107 label = "Email"
108108 id = "email"
@@ -130,12 +130,13 @@ const LoginComponent = () => {
130130 >
131131 LOGIN
132132 </ button >
133- < p className = "text-xl text-center text-black font-weight-bold mt-9" style = { { color : '#1976D2' , fontSize : '14px' } } >
133+ < p className = "text-xl text-center text-black font-weight-bold mt-9"
134+ style = { { color : '#1976D2' , fontSize : '14px' } } >
134135 Reset Password
135136 </ p >
136- < Link href = " /register" >
137- < p className = "mt-5 text-xl text-center text-black font-weight-bold" style = { { fontSize : '14px' } } >
138- No account? < span style = { { color : '#1976D2' } } > Create one</ span >
137+ < Link href = { ` /register?callBack= ${ router . query . callBack ? router . query . callBack : '/' } ` } >
138+ < p className = "mt-5 text-xl text-center text-black font-weight-bold" style = { { fontSize : '14px' } } >
139+ No account? < span style = { { color : '#1976D2' } } > Create one</ span >
139140 </ p >
140141 </ Link >
141142 < style >
@@ -186,7 +187,7 @@ const LoginComponent = () => {
186187 </ style >
187188 </ div >
188189 </ div >
189- < MiniFooter />
190+ < MiniFooter />
190191 </ div >
191192 ) ;
192193} ;
0 commit comments