@@ -14,7 +14,7 @@ import { Markdown, A } from '@/components'
14
14
import { useMutation , useQuery } from 'react-query'
15
15
import classNames from 'classnames'
16
16
import { useEffect , useReducer , useState } from 'react'
17
- import { useSession } from 'next-auth/client'
17
+ import { signIn , useSession } from 'next-auth/client'
18
18
import {
19
19
NewComment ,
20
20
NewUpdate ,
@@ -311,14 +311,14 @@ function HomePageSideNavBar() {
311
311
) }
312
312
{ ! session && (
313
313
< >
314
- < A
315
- href = "/join"
314
+ < button
315
+ onClick = { ( ) => signIn ( 'github' ) }
316
316
className = "text-gray-600 hover:bg-gray-50 group flex items-center px-3 py-2 text-sm font-medium rounded-md"
317
317
aria-current = "false"
318
318
>
319
319
< RocketLaunch className = "text-gray-400 group-hover:text-gray-500 flex-shrink-0 -ml-1 mr-3 h-6 w-6" />
320
320
< span className = "truncate" > Get Started</ span >
321
- </ A >
321
+ </ button >
322
322
< A
323
323
href = "/members"
324
324
className = "text-gray-600 hover:bg-gray-50 group flex items-center px-3 py-2 text-sm font-medium rounded-md"
@@ -336,6 +336,7 @@ function HomePageSideNavBar() {
336
336
}
337
337
338
338
function FollowButton ( { user } : { user : User } ) {
339
+ const [ session ] = useSession ( )
339
340
const { toggleFollow } = useFollowUser ( user . id )
340
341
const [ isFollowing , setIsFollowing ] = useState ( false )
341
342
return (
@@ -358,6 +359,10 @@ function FollowButton({ user }: { user: User }) {
358
359
type = "button"
359
360
className = "inline-flex items-center px-3 py-0.5 rounded-full bg-brand-50 text-sm font-medium text-brand-700 hover:bg-brand-100"
360
361
onClick = { ( ) => {
362
+ if ( ! session ) {
363
+ signIn ( 'github' )
364
+ return
365
+ }
361
366
setIsFollowing ( true )
362
367
toggleFollow ( )
363
368
} }
@@ -453,12 +458,12 @@ function HomePageAside({ updates }: { updates: HomePageFeedUpdateType[] }) {
453
458
</ div >
454
459
) : (
455
460
< div className = "mt-6" >
456
- < A
457
- href = "/join"
461
+ < button
462
+ onClick = { ( ) => signIn ( 'github' ) }
458
463
className = "w-full block text-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
459
464
>
460
465
Join
461
- </ A >
466
+ </ button >
462
467
</ div >
463
468
) }
464
469
</ div >
@@ -484,12 +489,21 @@ function HomePageAside({ updates }: { updates: HomePageFeedUpdateType[] }) {
484
489
</ ul >
485
490
</ div >
486
491
< div className = "mt-6" >
487
- < A
488
- href = "/members"
489
- className = "w-full block text-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
490
- >
491
- View all
492
- </ A >
492
+ { session ? (
493
+ < A
494
+ href = "/members"
495
+ className = "w-full block text-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
496
+ >
497
+ View all
498
+ </ A >
499
+ ) : (
500
+ < button
501
+ onClick = { ( ) => signIn ( 'github' ) }
502
+ className = "w-full block text-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
503
+ >
504
+ Join
505
+ </ button >
506
+ ) }
493
507
</ div >
494
508
</ div >
495
509
</ div >
0 commit comments