diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-08-18 11:02:39 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-08-18 11:02:39 +0700 |
| commit | b6f6bf23f90ff0dfadf9bf0af8866c2cfc17aa9c (patch) | |
| tree | 55030557d97f8c3376cdf3547bd619b6ab3a8b9c /src/lib/auth/components/LoginMobile.jsx | |
| parent | f01f28a7eac76c6da5bf857bfc80fd347586ce7f (diff) | |
handling redirect login
Diffstat (limited to 'src/lib/auth/components/LoginMobile.jsx')
| -rw-r--r-- | src/lib/auth/components/LoginMobile.jsx | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/lib/auth/components/LoginMobile.jsx b/src/lib/auth/components/LoginMobile.jsx index 68ceb769..095f4174 100644 --- a/src/lib/auth/components/LoginMobile.jsx +++ b/src/lib/auth/components/LoginMobile.jsx @@ -9,27 +9,41 @@ import { useSession, signIn, SignOut } from 'next-auth/react' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { setCookie } from 'cookies-next' +import BottomPopup from '@/core/components/elements/Popup/BottomPopup' +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' +import odooApi from '@/core/api/odooApi' +import { getAuth } from '@/core/utils/auth' const LoginMobile = () => { - const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = + const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef, handleGoogleSubmit } = useLogin() const router = useRouter() const [query, setQuery] = useState(router?.query?.next || '/') const { data: session } = useSession() + const auth = getAuth() const handleGoogle = async () => { - const url = query != '/' ? '/login?next=' + query : '/login' + const url = query != '/' ? '/login?source=google&next=' + query : '/login?source=google' await signIn('google', { callbackUrl: url }) - setCookie('auth', JSON.stringify(session?.odooUser)) } useEffect(() => { if (session) { - setCookie('auth', JSON.stringify(session?.odooUser)) - router.push(query) + handleGoogleSubmit(session) } }, [session]) + if (router.query.source) { + return ( + <BottomPopup active={true} close={true}> + <div className='leading-7 text-gray_r-12/80 flex justify-center'>Mohon Tunggu</div> + <div className='container flex justify-center my-4'> + <LogoSpinner width={48} height={48} /> + </div> + </BottomPopup> + ) + } + return ( <MobileView> <div className='p-6 pt-10 flex flex-col items-center min-h-screen'> |
