@@ -6,8 +6,6 @@ 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 ( )
@@ -21,32 +19,37 @@ const ProfileEditButton = ({ user }: { user: UserProfileResBody }) => {
2119 handleOpenCurrentModal,
2220 } )
2321
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+
2434 return (
25- < Button
26- type = "button"
27- onClick = { ( ) => {
28- if ( user ?. memberId === myId ) {
29- router . push ( '/user/setting' )
30- } else if ( user ?. isFollowing ) {
31- handleClickFollow ( user ?. isFollowing )
32- } else {
33- handleClickFollow ( user ?. isFollowing )
34- }
35- } }
36- className = { cls (
37- 'button button-md button-lg' ,
38- getProfileButtonColor ( {
39- isFollowing : user ?. isFollowing ,
40- memberId : user ?. memberId ,
41- myId,
42- } ) ,
43- ) } >
44- { getProfileButtonText ( {
45- isFollowing : user ?. isFollowing ,
46- memberId : user ?. memberId ,
47- myId,
48- } ) }
49- </ Button >
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+ </ >
5053 )
5154}
5255
0 commit comments