-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] 팔로잉/팔로워 리스트 페이지 #484
Merged
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9bd8f9a
feat: 팔로우 리스트 페이지 추가
sumi-0011 6352661
feat: 팔로워 페이지 구현 중
sumi-0011 a2ea316
feat: 팔로잉 리스트 개발 중.
sumi-0011 e8b21d3
feat: tab 클릭하면 링크 이동할 수 있도록 수정
sumi-0011 4b03435
feat: member item 컴포넌트 생성
sumi-0011 721dcbc
feat: stagger warpper 컴포넌트 추가
sumi-0011 dd091fa
feat: stagger motion 추가
sumi-0011 340fef0
refactor: my follower list refactor
sumi-0011 abb9fd7
feat: following 버튼 클릭하면 리스트 업데이트
sumi-0011 b2af1bd
feat: following 하는 경우에도 리패칭 하지 않음
sumi-0011 bbee91f
chore: 이 코드는 뭐가 이상한걸까
sumi-0011 0ae72b0
feat: 팔로잉 팔로워 리스트 개발
sumi-0011 2287d44
feat: 리스트 sorting 중
sumi-0011 a52216e
feat: 팔로워 리스트에서 내가 맞팔하지 않은 사람은 팔로우 버튼 띄우기
sumi-0011 0b80aeb
refactor: useViewList 커스텀 훅 사용
sumi-0011 096ef33
refactor: useGetMeId 커스텀 훅 사용
sumi-0011 47298a8
refactor: button 이벤트 핸들링
sumi-0011 6fecf6b
refactor: FollowingItem 컴포넌트 제거
sumi-0011 ac807cd
refactor: list 업데이트는 하되, view list는 다르게
sumi-0011 dae2ca9
feat: search page 애니매이션
sumi-0011 b41984b
fix: dom 중첩 문제 수정
sumi-0011 a776b56
fix: build error fix
sumi-0011 3bf4785
refactor: isMySelf 네이밍 변경
sumi-0011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,67 @@ | ||
import Link from 'next/link'; | ||
import { type FollowerMemberWithStatusType, FollowStatus } from '@/apis/schema/member'; | ||
import { useGetMeId, useViewList } from '@/app/profile/[id]/follows/index.hooks'; | ||
import { | ||
FollowingMember, | ||
type MemberItemProps, | ||
MineMemberItem, | ||
NotFollowingMember, | ||
} from '@/components/ListItem/Follow/MemberItem'; | ||
import { stagger } from '@/components/Motion/Motion.constants'; | ||
import StaggerWrapper from '@/components/Motion/StaggerWrapper'; | ||
import { ROUTER } from '@/constants/router'; | ||
import { css } from '@/styled-system/css'; | ||
|
||
interface Props { | ||
list: FollowerMemberWithStatusType[]; | ||
refetch: () => void; | ||
} | ||
|
||
function FollowingList(props: Props) { | ||
const { list, onUpdateItem } = useViewList(props.list); | ||
|
||
return ( | ||
<StaggerWrapper wrapperOverrideCss={containerCss} staggerVariants={stagger(0.1)}> | ||
{list.map((item) => ( | ||
<Link key={item.memberId} href={ROUTER.PROFILE.DETAIL(item.memberId)} passHref> | ||
<Item | ||
{...item} | ||
onUpdateList={(_item) => { | ||
onUpdateItem(_item); | ||
props.refetch(); | ||
}} | ||
/> | ||
</Link> | ||
))} | ||
</StaggerWrapper> | ||
); | ||
} | ||
|
||
export default FollowingList; | ||
|
||
interface ItemProps extends Omit<MemberItemProps, 'onButtonClick'> { | ||
onUpdateList: (item: FollowerMemberWithStatusType) => void; | ||
} | ||
|
||
function Item({ onUpdateList, ...props }: ItemProps) { | ||
const myId = useGetMeId(); | ||
|
||
if (props.memberId === myId) { | ||
return <MineMemberItem {...props} />; | ||
} | ||
|
||
switch (props.followStatus) { | ||
case FollowStatus.FOLLOWING: | ||
return <FollowingMember {...props} onButtonClick={onUpdateList} />; | ||
case FollowStatus.NOT_FOLLOWING: | ||
case FollowStatus.FOLLOWED_BY_ME: | ||
return <NotFollowingMember {...props} onButtonClick={onUpdateList} />; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
const containerCss = css({ | ||
padding: '16px', | ||
width: '100%', | ||
}); |
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,80 @@ | ||
import Link from 'next/link'; | ||
import { useAddFollow } from '@/apis/follow'; | ||
import { type FollowerMemberWithStatusType, FollowStatus } from '@/apis/schema/member'; | ||
import { useViewList } from '@/app/profile/[id]/follows/index.hooks'; | ||
import { ProfileListItem } from '@/components/ListItem'; | ||
import { stagger } from '@/components/Motion/Motion.constants'; | ||
import StaggerWrapper from '@/components/Motion/StaggerWrapper'; | ||
import { ROUTER } from '@/constants/router'; | ||
import { css } from '@/styled-system/css'; | ||
|
||
interface Props { | ||
list: FollowerMemberWithStatusType[]; | ||
refetch: () => void; | ||
} | ||
|
||
function MyFollowerList(props: Props) { | ||
const { list, onUpdateItem } = useViewList(props.list); | ||
|
||
return ( | ||
<StaggerWrapper wrapperOverrideCss={containerCss} staggerVariants={stagger(0.1)}> | ||
{list.map((item) => ( | ||
<Item | ||
key={`${item.memberId}-${item.followStatus}`} | ||
item={item} | ||
onUpdateItem={(_item) => { | ||
onUpdateItem(_item); | ||
props.refetch(); | ||
}} | ||
/> | ||
))} | ||
</StaggerWrapper> | ||
); | ||
} | ||
|
||
export default MyFollowerList; | ||
|
||
interface ItemProps { | ||
item: FollowerMemberWithStatusType; | ||
onUpdateItem: (member: FollowerMemberWithStatusType) => void; | ||
} | ||
|
||
function Item({ item, onUpdateItem }: ItemProps) { | ||
const { mutate } = useAddFollow({ | ||
onSuccess: () => { | ||
onUpdateItem({ ...item, followStatus: FollowStatus.FOLLOWING }); | ||
}, | ||
}); | ||
|
||
const isFollowing = item.followStatus === FollowStatus.FOLLOWING; | ||
|
||
return ( | ||
<Link key={item.memberId} href={ROUTER.PROFILE.DETAIL(item.memberId)}> | ||
<ProfileListItem | ||
variant={isFollowing ? 'one-button' : 'two-button'} | ||
subElement={ | ||
!isFollowing && ( | ||
<span className={followLabelCss} onClick={() => mutate(item.memberId)}> | ||
팔로우 | ||
</span> | ||
) | ||
} | ||
buttonElement={ | ||
// TODO : 삭제 버튼 추가 필요 (맞팔 관계 팔로우 삭제, 맞팔 x, 팔로워 관계 삭제) | ||
// 일정 상 무리라고 판단 (2/6) 추후 수정 | ||
<div></div> | ||
} | ||
thumbnailUrl={item.profileImageUrl} | ||
name={item.nickname} | ||
/> | ||
</Link> | ||
); | ||
} | ||
|
||
const containerCss = css({ | ||
padding: '16px', | ||
}); | ||
|
||
const followLabelCss = css({ | ||
padding: '8px 12px', | ||
}); |
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,27 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useGetMembersMe } from '@/apis/member'; | ||
import { type FollowerMemberWithStatusType } from '@/apis/schema/member'; | ||
import { sorFollowerList } from '@/app/profile/[id]/follows/index.utils'; | ||
|
||
export const useViewList = (list: FollowerMemberWithStatusType[]) => { | ||
const myId = useGetMeId(); | ||
const [viewList, setViewList] = useState(list); | ||
|
||
const onUpdateItem = (member: FollowerMemberWithStatusType) => { | ||
setViewList((prev) => prev.map((item) => (item.memberId === member.memberId ? member : item))); | ||
}; | ||
|
||
useEffect(() => { | ||
const sortList = sorFollowerList(list, Number(myId)); | ||
setViewList(sortList); | ||
}, []); | ||
|
||
return { list: viewList, onUpdateItem }; | ||
}; | ||
|
||
// @description 현재 로그인한 사용자의 memberId를 가져옵니다. | ||
export const useGetMeId = () => { | ||
const { data } = useGetMembersMe(); | ||
const memberId = data?.memberId ?? 0; | ||
return memberId; | ||
}; |
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,15 @@ | ||
import { type FollowerMemberWithStatusType, FollowStatus } from '@/apis/schema/member'; | ||
|
||
export const sorFollowerList = (list: FollowerMemberWithStatusType[], myId: number): FollowerMemberWithStatusType[] => { | ||
// 1순위) 내 계정, 내가 팔로잉 중인 계정, 내가 팔로우 중이지 않은 계정 순으로 리스트 나열 | ||
// 2순위) 가나다 순, ABC순으로 나열 | ||
|
||
const myAccount = list.filter((item) => item.memberId === myId); | ||
const followingList = list.filter((item) => item.followStatus === FollowStatus.FOLLOWING); | ||
const followedByMeList = list.filter((item) => item.followStatus === FollowStatus.FOLLOWED_BY_ME); | ||
const notFollowingList = list.filter((item) => item.followStatus === FollowStatus.NOT_FOLLOWING); | ||
|
||
const sortedList = [...myAccount, ...followingList, ...followedByMeList, ...notFollowingList]; | ||
|
||
return sortedList; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석 굿