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 ;
21+ const { query} = router ;
2222
23- console . log ( 'session' , session ) ;
23+ console . log ( 'session' , session ) ;
2424
2525 const handleLoginWithGoogle = async ( ) => {
2626 try {
@@ -49,7 +49,7 @@ const LoginComponent = () => {
4949 email,
5050 password,
5151 redirect : true ,
52- callbackUrl : `http://localhost:3000 ${ query ?. callBack } `,
52+ callbackUrl : query ?. callBack ? ` ${ query ?. callBack } ` : '/' ,
5353 } ) ;
5454 console . log ( 'signInResponse:' , signInResponse ) ;
5555 if ( signInResponse ?. error ) {
@@ -68,41 +68,43 @@ const LoginComponent = () => {
6868 // }, []
6969 // )
7070 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' } } >
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' } } >
7676 Login
7777 </ p >
7878 { 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" >
79+ < div
80+ className = "relative block w-full p-4 mt-5 text-base leading-5 text-white bg-red-500 rounded-lg opacity-100 font-regular" >
8081 { errorMessage }
8182 </ div >
8283 ) }
8384 { 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" >
85+ < div
86+ className = "relative block w-full p-4 mt-5 text-base leading-5 text-white bg-green-500 rounded-lg opacity-100 font-regular" >
8587 { successMessage }
8688 </ div >
8789 ) }
8890 { loading && (
8991 < div className = { 'align-items-center d-flex flex justify-center mt-3' } >
90- < Spinner height = { '1rem' } width = { '1rem' } />
92+ < Spinner height = { '1rem' } width = { '1rem' } />
9193 </ div >
9294 ) }
9395 < button
9496 type = "button"
9597 onClick = { ( ) => handleLoginWithGoogle ( ) }
9698 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"
9799 >
98- < img src = "/images/google.svg" alt = "" />
100+ < img src = "/images/google.svg" alt = "" />
99101 < span className = "uppercase font-medium text-dark-600 ml-1 sm:ml-2 tracking-[1.5px]" > continue with google</ span >
100102 </ button >
101103
102104 { /* <p className="mt-5 text-center text-black text-md font-weight-bold">or</p> */ }
103- < br />
104- < br />
105- < br />
105+ < br />
106+ < br />
107+ < br />
106108 < TextField
107109 label = "Email"
108110 id = "email"
@@ -130,12 +132,13 @@ const LoginComponent = () => {
130132 >
131133 LOGIN
132134 </ button >
133- < p className = "text-xl text-center text-black font-weight-bold mt-9" style = { { color : '#1976D2' , fontSize : '14px' } } >
135+ < p className = "text-xl text-center text-black font-weight-bold mt-9"
136+ style = { { color : '#1976D2' , fontSize : '14px' } } >
134137 Reset Password
135138 </ 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 >
139+ < Link href = { ` /register?callBack= ${ router . query . callBack ? router . query . callBack : '/' } ` } >
140+ < p className = "mt-5 text-xl text-center text-black font-weight-bold" style = { { fontSize : '14px' } } >
141+ No account? < span style = { { color : '#1976D2' } } > Create one</ span >
139142 </ p >
140143 </ Link >
141144 < style >
@@ -186,7 +189,7 @@ const LoginComponent = () => {
186189 </ style >
187190 </ div >
188191 </ div >
189- < MiniFooter />
192+ < MiniFooter />
190193 </ div >
191194 ) ;
192195} ;
0 commit comments