1
- import { Button , Card , TextInput } from 'flowbite-react'
1
+ import { Button , Card } from 'flowbite-react'
2
2
import Link from 'next/link'
3
3
import { useRouter } from 'next/router'
4
+
5
+ import { signIn , signOut , useSession } from 'next-auth/react'
4
6
import React , { useState } from 'react'
5
7
6
8
const SignIn = ( ) => {
@@ -16,16 +18,22 @@ const SignIn = () => {
16
18
[ e . target . id ] : e . target . value ,
17
19
} )
18
20
}
19
-
20
- const handleSignIn = async ( e ) => {
21
- e . preventDefault ( )
22
-
23
- // Perform sign-in logic here with formData
24
-
25
- // Redirect to /publisher route after sign-in
26
- router . push ( '/publisher' )
21
+ const handleSignInGoogle = async ( provider ) => {
22
+ try {
23
+ await signIn ( provider , { callbackUrl : '/nodes' } )
24
+ } catch ( error ) {
25
+ console . error ( 'Sign in error:' , error )
26
+ // Handle sign-in error
27
+ }
28
+ }
29
+ const handleSignInGithub = async ( provider ) => {
30
+ try {
31
+ await signIn ( provider , { callbackUrl : '/nodes' } )
32
+ } catch ( error ) {
33
+ console . error ( 'Sign in error:' , error )
34
+ // Handle sign-in error
35
+ }
27
36
}
28
-
29
37
return (
30
38
< section >
31
39
< div className = "flex items-center justify-center max-w-screen-xl px-4 py-16 mx-auto lg:grid lg:grid-cols-12 lg:gap-20 h-[100vh]" >
@@ -49,8 +57,8 @@ const SignIn = () => {
49
57
< div className = "mt-10 space-y-3 sm:space-x-4 sm:space-y-0" >
50
58
< Button
51
59
color = "gray"
52
- href = "#"
53
- className = "font-bold "
60
+ onClick = { ( ) => handleSignInGoogle ( 'google' ) }
61
+ className = "w-full font-bold"
54
62
>
55
63
< svg
56
64
className = "w-5 h-5 mr-2"
@@ -94,7 +102,7 @@ const SignIn = () => {
94
102
</ div >
95
103
< Button
96
104
color = "gray"
97
- href = "#"
105
+ onClick = { ( ) => handleSignInGithub ( 'github' ) }
98
106
className = "mt-2 font-bold hover:bg-gray-50"
99
107
>
100
108
< svg
@@ -118,11 +126,10 @@ const SignIn = () => {
118
126
</ Button >
119
127
< p className = "flex justify-center mt-4 text-sm font-medium text-gray-50 " >
120
128
New to Comfy Registry?
121
- < Link
122
- href = "/auth/signup"
123
- className = "font-medium text-blue-600 text-primary-500 hover:underline "
124
- >
125
- Sign up
129
+ < Link href = "/auth/signup" >
130
+ < a className = "font-medium text-blue-600 hover:underline" >
131
+ Sign up
132
+ </ a >
126
133
</ Link >
127
134
</ p >
128
135
</ Card >
0 commit comments