@@ -2,7 +2,6 @@ import { Avatar } from '@/ui'
2
2
import {
3
3
ChatCenteredDots ,
4
4
Gear ,
5
- Plus ,
6
5
RocketLaunch ,
7
6
ShareNetwork ,
8
7
ThumbsUp ,
@@ -26,8 +25,8 @@ import {
26
25
import { User } from 'src/pages/members'
27
26
import AppNavBar from './AppNavBar'
28
27
import AppFooter from './AppFooter'
29
- import { IconPlus } from 'tabler-icons'
30
28
import { useRouter } from 'next/router'
29
+ import useFollowUser from './profile/useFollowUser'
31
30
32
31
type LikeData = {
33
32
count : number
@@ -336,6 +335,56 @@ function HomePageSideNavBar() {
336
335
)
337
336
}
338
337
338
+ function FollowButton ( { user } : { user : User } ) {
339
+ const { toggleFollow } = useFollowUser ( user . id )
340
+ const [ isFollowing , setIsFollowing ] = useState ( false )
341
+ return (
342
+ < li className = "flex items-center py-4 space-x-3" >
343
+ < div className = "flex-shrink-0" >
344
+ < img className = "h-8 w-8 rounded-full" src = { user . image } alt = "" />
345
+ </ div >
346
+ < div className = "min-w-0 flex-1" >
347
+ < p className = "text-sm font-medium text-gray-900" >
348
+ < A href = { `/${ user . username } ` } >
349
+ { user . account ?. firstName ?? user . name }
350
+ </ A >
351
+ </ p >
352
+ < p className = "text-sm text-gray-500" >
353
+ < A href = { `/${ user . username } ` } > @{ user . username } </ A >
354
+ </ p >
355
+ </ div >
356
+ < div className = "flex-shrink-0" >
357
+ < button
358
+ type = "button"
359
+ 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
+ onClick = { ( ) => {
361
+ setIsFollowing ( true )
362
+ toggleFollow ( )
363
+ } }
364
+ >
365
+ { ! isFollowing && (
366
+ < svg
367
+ className = "-ml-1 mr-0.5 h-5 w-5 text-brand-400"
368
+ xmlns = "http://www.w3.org/2000/svg"
369
+ viewBox = "0 0 20 20"
370
+ fill = "currentColor"
371
+ aria-hidden = "true"
372
+ >
373
+ < path
374
+ fillRule = "evenodd"
375
+ d = "M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z"
376
+ clipRule = "evenodd"
377
+ />
378
+ </ svg >
379
+ ) }
380
+
381
+ < span > { isFollowing ? 'Following' : 'Follow' } </ span >
382
+ </ button >
383
+ </ div >
384
+ </ li >
385
+ )
386
+ }
387
+
339
388
function HomePageAside ( { updates } : { updates : HomePageFeedUpdateType [ ] } ) {
340
389
const router = useRouter ( )
341
390
const [ session , loading ] = useSession ( )
@@ -430,50 +479,7 @@ function HomePageAside({ updates }: { updates: HomePageFeedUpdateType[] }) {
430
479
{ ! isLoading &&
431
480
! isError &&
432
481
response . users . map ( ( user : User ) => (
433
- < li
434
- className = "flex items-center py-4 space-x-3"
435
- key = { user . id }
436
- >
437
- < div className = "flex-shrink-0" >
438
- < img
439
- className = "h-8 w-8 rounded-full"
440
- src = { user . image }
441
- alt = ""
442
- />
443
- </ div >
444
- < div className = "min-w-0 flex-1" >
445
- < p className = "text-sm font-medium text-gray-900" >
446
- < A href = { `/${ user . username } ` } >
447
- { user . account ?. firstName ?? user . name }
448
- </ A >
449
- </ p >
450
- < p className = "text-sm text-gray-500" >
451
- < A href = { `/${ user . username } ` } > @{ user . username } </ A >
452
- </ p >
453
- </ div >
454
- < div className = "flex-shrink-0" >
455
- < button
456
- type = "button"
457
- 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"
458
- onClick = { ( ) => router . push ( `/${ user . username } ` ) }
459
- >
460
- < svg
461
- className = "-ml-1 mr-0.5 h-5 w-5 text-brand-400"
462
- xmlns = "http://www.w3.org/2000/svg"
463
- viewBox = "0 0 20 20"
464
- fill = "currentColor"
465
- aria-hidden = "true"
466
- >
467
- < path
468
- fillRule = "evenodd"
469
- d = "M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z"
470
- clipRule = "evenodd"
471
- />
472
- </ svg >
473
- < span > Follow</ span >
474
- </ button >
475
- </ div >
476
- </ li >
482
+ < FollowButton user = { user } key = { user . id } />
477
483
) ) }
478
484
</ ul >
479
485
</ div >
0 commit comments