@@ -6,52 +6,50 @@ import { UserProfileResBody } from '@/types'
66import { cls , getProfileButtonColor , getProfileButtonText } from '@/utils'
77import { useRouter } from 'next/navigation'
88import Button from '../common/Button/Button'
9- import DeferredComponent from '../common/DeferedComponent/DeferedComponent'
10- import Spinner from '../common/Spinner/Spinner'
119
1210const ProfileEditButton = ( { user } : { user : UserProfileResBody } ) => {
1311 const router = useRouter ( )
1412 const { currentUser } = useCurrentUser ( )
1513 const myId = currentUser ?. memberId
1614 const { handleOpenCurrentModal } = useModal ( )
17- const { isFollowing, handleClickFollow } = useFollowUser ( {
18- memberId : user ?. memberId || 0 ,
19- isInitFollowing : ! ! user ?. isFollowing ,
20- followingInitCount : user ?. followingCount || 0 ,
21- followerInitCount : user ?. followerCount || 0 ,
15+ const { handleClickFollow } = useFollowUser ( {
16+ profileId : user ?. memberId || 0 ,
17+ memberId : currentUser ?. memberId || 0 ,
18+ myId : myId || 0 ,
2219 handleOpenCurrentModal,
2320 } )
2421
25- return myId ? (
26- < Button
27- type = "button"
28- onClick = { ( ) => {
29- if ( user ?. memberId === myId ) {
30- router . push ( '/user/setting' )
31- } else if ( isFollowing ) {
32- handleClickFollow ( isFollowing )
33- } else {
34- handleClickFollow ( isFollowing )
35- }
36- } }
37- className = { cls (
38- 'button button-md button-lg' ,
39- getProfileButtonColor ( {
40- isFollowing,
41- memberId : user ?. memberId ,
42- myId,
43- } ) ,
44- ) } >
45- { getProfileButtonText ( {
46- isFollowing,
47- memberId : user ?. memberId ,
48- myId,
49- } ) }
50- </ Button >
51- ) : (
52- < DeferredComponent >
53- < Spinner />
54- </ DeferredComponent >
22+ const buttonColor = getProfileButtonColor ( {
23+ isFollowing : user ?. isFollowing ,
24+ memberId : user ?. memberId ,
25+ myId,
26+ } )
27+
28+ const buttonText = getProfileButtonText ( {
29+ isFollowing : user ?. isFollowing ,
30+ memberId : user ?. memberId ,
31+ myId,
32+ } )
33+
34+ return (
35+ < >
36+ { user ?. memberId && myId && (
37+ < Button
38+ type = "button"
39+ onClick = { ( ) => {
40+ if ( user ?. memberId === myId ) {
41+ router . push ( '/user/setting' )
42+ } else if ( user ?. isFollowing ) {
43+ handleClickFollow ( user ?. isFollowing )
44+ } else {
45+ handleClickFollow ( user ?. isFollowing )
46+ }
47+ } }
48+ className = { cls ( 'button button-md button-lg' , buttonColor ) } >
49+ { buttonText }
50+ </ Button >
51+ ) }
52+ </ >
5553 )
5654}
5755
0 commit comments