From f01f28a7eac76c6da5bf857bfc80fd347586ce7f Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 16 Aug 2023 09:39:47 +0700
Subject: register google

---
 src/lib/auth/components/RegisterDesktop.jsx | 39 +++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

(limited to 'src/lib/auth/components/RegisterDesktop.jsx')

diff --git a/src/lib/auth/components/RegisterDesktop.jsx b/src/lib/auth/components/RegisterDesktop.jsx
index 93b505ab..86a5027d 100644
--- a/src/lib/auth/components/RegisterDesktop.jsx
+++ b/src/lib/auth/components/RegisterDesktop.jsx
@@ -5,6 +5,11 @@ import Alert from '@/core/components/elements/Alert/Alert'
 import PageContent from '@/lib/content/components/PageContent'
 import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
 import ReCAPTCHA from 'react-google-recaptcha'
+import Image from 'next/image'
+import { useEffect } from 'react'
+import { setCookie } from 'cookies-next'
+import { signIn, useSession } from 'next-auth/react'
+import { useRouter } from 'next/router'
 
 const RegisterDesktop = () => {
   const {
@@ -21,6 +26,20 @@ const RegisterDesktop = () => {
     tnd,
     setTnd
   } = useRegister()
+  
+  const { data: session } = useSession()
+  const router = useRouter()
+  
+  const handleGoogle = async () => {
+    await signIn('google', { callbackUrl: '/register' })
+  }
+
+  useEffect(() => {
+    if(session){
+      setCookie('auth', JSON.stringify(session?.odooUser))
+      router.push('/')
+    }
+  },[session])
 
   return (
     <DesktopView>
@@ -121,6 +140,26 @@ const RegisterDesktop = () => {
                 <PageContent path='/register#tnd'></PageContent>
               </BottomPopup>
             </div>
+            <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>Daftar dengan Google</p>
+            </button>
 
             <div className='text-gray_r-11 mt-10'>
               Sudah punya akun Indoteknik?{' '}
-- 
cgit v1.2.3

