summaryrefslogtreecommitdiff
path: root/src/lib/auth/components/LoginDesktop.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/auth/components/LoginDesktop.jsx')
-rw-r--r--src/lib/auth/components/LoginDesktop.jsx57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 8ce2e4e3..838054cd 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -3,11 +3,46 @@ import useLogin from '../hooks/useLogin'
import Link from '@/core/components/elements/Link/Link'
import PageContent from '@/lib/content/components/PageContent'
import Alert from '@/core/components/elements/Alert/Alert'
+import { useSession, signIn, SignOut } from 'next-auth/react'
+import Image from 'next/image'
+import { useRouter } from 'next/router'
+import { useContext, useEffect, useState } from 'react'
+import { getAuth, setAuth } from '@/core/utils/auth'
+import { setCookie } from 'cookies-next'
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
+import Spinner from '@/core/components/elements/Spinner/Spinner'
+import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
+import odooApi from '@/core/api/odooApi'
const LoginDesktop = () => {
- 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 handleGoogle = async () => {
+ const url = query != '/' ? '/login?source=google&next=' + query : '/login?source=google'
+ await signIn('google', { callbackUrl: url })
+ }
+ useEffect(() => {
+ if (session) {
+ handleGoogleSubmit(session)
+ }
+ }, [session])
+
+ if (router.query.source) {
+ return (
+ <BottomPopup active={true} close=''>
+ <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 (
<DesktopView>
<div className='container mx-auto'>
@@ -60,6 +95,26 @@ const LoginDesktop = () => {
{!isLoading ? 'Masuk' : 'Loading...'}
</button>
</form>
+ {/* <div className='flex items-center mt-3 mb-3'>
+ <hr className='flex-1' />
+ <p className='text-gray-400'>ATAU</p>
+ <hr className='flex-1' />
+ </div> */}
+
+ {/* <button
+ type='submit'
+ className='border border-gray-500 p-2 rounded-md hover:bg-gray-100 w-full mt-2 flex items-center justify-center gap-x-2'
+ onClick={() => handleGoogle()}
+ >
+ <Image
+ src='/images/icons8-google.svg'
+ alt='google image'
+ className='h-7 w-7'
+ width={10}
+ height={10}
+ />
+ <p>Masuk dengan Google</p>
+ </button> */}
<div className='text-gray_r-11 mt-10'>
Belum punya akun Indoteknik?{' '}