-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from Team-TenTen/develop
[Release] v0.1.12
- Loading branch information
Showing
11 changed files
with
180 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
'use client' | ||
|
||
import { PROFILE_MSG } from '@/constants' | ||
import { useFollowUser, useModal } from '@/hooks' | ||
import { useCurrentUser } from '@/hooks/useCurrentUser' | ||
import { | ||
fetchGetFollowers, | ||
fetchGetFollowing, | ||
} from '@/services/user/follow/follow' | ||
import { UserProfileResBody } from '@/types' | ||
import FollowList from '../common/FollowList/FollowList' | ||
import LoginModal from '../common/Modal/LoginModal' | ||
|
||
const FollowListButton = ({ user }: { user: UserProfileResBody }) => { | ||
const { currentUser } = useCurrentUser() | ||
const myId = currentUser?.memberId | ||
const { Modal, isOpen, modalClose, currentModal, handleOpenCurrentModal } = | ||
useModal() | ||
const { followingCount, setFollowingCount, followerCount } = useFollowUser({ | ||
memberId: user?.memberId || 0, | ||
isInitFollowing: !!user?.isFollowing, | ||
followingInitCount: user?.followingCount || 0, | ||
followerInitCount: user?.followerCount || 0, | ||
handleOpenCurrentModal, | ||
}) | ||
|
||
return ( | ||
<> | ||
<div | ||
className="cursor-pointer hover:font-semibold" | ||
onClick={() => { | ||
handleOpenCurrentModal('following') | ||
}}> | ||
{PROFILE_MSG.FOLLOWING} {followingCount} | ||
</div> | ||
{PROFILE_MSG.LIST_DIVIDER} | ||
<div | ||
className="cursor-pointer hover:font-semibold" | ||
onClick={() => { | ||
handleOpenCurrentModal('follower') | ||
}}> | ||
{PROFILE_MSG.FOLLOWER} {followerCount} | ||
</div> | ||
{currentModal !== 'login' && isOpen && ( | ||
<Modal | ||
title={ | ||
currentModal === 'following' | ||
? `${PROFILE_MSG.FOLLOWING}` | ||
: `${PROFILE_MSG.FOLLOWER}` | ||
} | ||
onClose={modalClose} | ||
type={'follow'}> | ||
<div className="flex flex-col gap-2"> | ||
{currentModal === 'following' && ( | ||
<FollowList | ||
memberId={user?.memberId} | ||
fetchFn={fetchGetFollowing} | ||
myId={myId} | ||
type="following" | ||
followingCount={followingCount} | ||
setFollowingCount={setFollowingCount} | ||
/> | ||
)} | ||
{currentModal === 'follower' && ( | ||
<FollowList | ||
memberId={user?.memberId} | ||
fetchFn={fetchGetFollowers} | ||
myId={myId} | ||
type="follower" | ||
followingCount={followingCount} | ||
setFollowingCount={setFollowingCount} | ||
/> | ||
)} | ||
</div> | ||
</Modal> | ||
)} | ||
{currentModal === 'login' && ( | ||
<LoginModal | ||
Modal={Modal} | ||
isOpen={isOpen} | ||
modalClose={modalClose} | ||
/> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default FollowListButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use client' | ||
|
||
import { useFollowUser, useModal } from '@/hooks' | ||
import { useCurrentUser } from '@/hooks/useCurrentUser' | ||
import { UserProfileResBody } from '@/types' | ||
import { cls, getProfileButtonColor, getProfileButtonText } from '@/utils' | ||
import { useRouter } from 'next/navigation' | ||
import Button from '../common/Button/Button' | ||
import Spinner from '../common/Spinner/Spinner' | ||
|
||
const ProfileEditButton = ({ user }: { user: UserProfileResBody }) => { | ||
const router = useRouter() | ||
const { currentUser } = useCurrentUser() | ||
const myId = currentUser?.memberId | ||
const { handleOpenCurrentModal } = useModal() | ||
const { isFollowing, handleClickFollow } = useFollowUser({ | ||
memberId: user?.memberId || 0, | ||
isInitFollowing: !!user?.isFollowing, | ||
followingInitCount: user?.followingCount || 0, | ||
followerInitCount: user?.followerCount || 0, | ||
handleOpenCurrentModal, | ||
}) | ||
|
||
return myId ? ( | ||
<Button | ||
type="button" | ||
onClick={() => { | ||
if (user?.memberId === myId) { | ||
router.push('/user/setting') | ||
} else if (isFollowing) { | ||
handleClickFollow(isFollowing) | ||
} else { | ||
handleClickFollow(isFollowing) | ||
} | ||
}} | ||
className={cls( | ||
'button button-md button-lg', | ||
getProfileButtonColor({ | ||
isFollowing, | ||
memberId: user?.memberId, | ||
myId, | ||
}), | ||
)}> | ||
{getProfileButtonText({ | ||
isFollowing, | ||
memberId: user?.memberId, | ||
myId, | ||
})} | ||
</Button> | ||
) : ( | ||
<Spinner /> | ||
) | ||
} | ||
|
||
export default ProfileEditButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.