-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] 당겨서 새로 고침 기능 추가 #181
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e4465cd
✨ [feat] 당겨서 새로 고침 훅 추가
yummjin f35d07a
✨ [feat] 멤버 관리 페이지에 당겨서 새로 고침 기능 추가
yummjin 539ab00
✨ [feat] 사용자 모델에 RequiredDeep 타입 추가 및 멤버 관리 페이지 데이터 타입 오류 개선
yummjin 7ebc833
Merge branch 'develop' into feature/112
yummjin 982c694
⚡ [perf] 활성화 반경을 100에서 1000으로 변경
yummjin 35d0610
♻️ [refactor] 빌드 타입에러 해결
yummjin 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { | |
| useQuery, | ||
| useQueryClient, | ||
| } from '@tanstack/react-query'; | ||
| import { useState } from 'react'; | ||
| import { useCallback, useState } from 'react'; | ||
|
|
||
| import * as styles from '@/pages/mypage/styles/MemberManagePage.css'; | ||
|
|
||
|
|
@@ -20,9 +20,11 @@ import { RequestList } from '@/features/crew-manage/ui'; | |
|
|
||
| import { MEMBER_ROLE } from '@/shared/constants/member-role'; | ||
| import { useInfiniteScroll } from '@/shared/lib/useInfiniteScroll'; | ||
| import { usePullToRefresh } from '@/shared/lib/usePullToRefresh'; | ||
| import { memberQueries } from '@/shared/queries'; | ||
| import { BackButton } from '@/shared/ui/button'; | ||
| import { AppLayout } from '@/shared/ui/layout'; | ||
| import { spinner as pageLoaderSpinner } from '@/shared/ui/loading/PageLoader.css.ts'; | ||
|
|
||
| import type { MemberRequestItem } from '@/entities/crew/model/crew.types'; | ||
| import type { MemberItem } from '@/entities/user/model'; | ||
|
|
@@ -40,44 +42,66 @@ export function MemberManagePage({ params }: { params?: { id?: string } }) { | |
| fetchNextPage, | ||
| hasNextPage, | ||
| isFetchingNextPage, | ||
| refetch: refetchMembers, | ||
| } = useInfiniteQuery({ | ||
| ...memberQueries.crewMembersQuery(crewId), | ||
| enabled: crewId > 0 && activeTab === 'member', | ||
| }); | ||
|
|
||
| const { scrollRef, bottomSentinelRef } = useInfiniteScroll({ | ||
| hasNextPage: hasNextPage ?? false, | ||
| isFetchingNextPage, | ||
| fetchNextPage, | ||
| }); | ||
| const { scrollRef: infiniteScrollRef, bottomSentinelRef } = useInfiniteScroll( | ||
| { | ||
| hasNextPage: hasNextPage ?? false, | ||
| isFetchingNextPage, | ||
| fetchNextPage, | ||
| } | ||
| ); | ||
|
|
||
| const members: MemberItem[] = | ||
| membersData?.pages.flatMap( | ||
| (page) => | ||
| page.result?.content.map((member) => ({ | ||
| id: member.id ?? 0, | ||
| memberId: member.memberId ?? member.id ?? 0, | ||
| nickname: member.nickname ?? '', | ||
| profileImageUrl: member.profileImageUrl ?? '', | ||
| role: member.role ?? 'MEMBER', | ||
| joinedDate: member.joinedDate ?? '', | ||
| page.result.content?.map((member) => ({ | ||
| id: member.id!, | ||
| memberId: member.memberId!, | ||
| nickname: member.nickname!, | ||
| profileImageUrl: member.profileImageUrl!, | ||
| role: member.role!, | ||
| joinedDate: member.joinedDate!, | ||
| })) ?? [] | ||
| ) ?? []; | ||
|
|
||
| const totalCount = membersData?.pages[0]?.result?.totalCount; | ||
|
|
||
| const { data: joinRequestsData } = useQuery({ | ||
| const { data: joinRequestsData, refetch: refetchRequests } = useQuery({ | ||
| ...memberQueries.joinRequestsQuery(crewId), | ||
| enabled: crewId > 0, | ||
| }); | ||
|
|
||
| const requests = joinRequestsData?.result ?? []; | ||
|
|
||
| if (isLoading || !myInfoData?.result) { | ||
| return <></>; | ||
| } | ||
| const { | ||
| scrollRef: pullToRefreshScrollRef, | ||
| isRefreshing: isPullRefreshing, | ||
| pullProgress, | ||
| } = usePullToRefresh({ | ||
| enabled: crewId > 0, | ||
| onRefresh: async () => { | ||
| if (crewId <= 0) return; | ||
|
|
||
| if (activeTab === 'member') { | ||
| await refetchMembers(); | ||
| } else { | ||
| await refetchRequests(); | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| const isLeader = myInfo?.crewMemberRole === MEMBER_ROLE.LEADER; | ||
| const setMainContainerRef = useCallback( | ||
| (el: HTMLDivElement | null) => { | ||
| pullToRefreshScrollRef.current = el; | ||
| infiniteScrollRef.current = activeTab === 'member' ? el : null; | ||
| }, | ||
| [activeTab, infiniteScrollRef, pullToRefreshScrollRef] | ||
| ); | ||
|
|
||
| const queryClient = useQueryClient(); | ||
|
|
||
|
|
@@ -90,6 +114,12 @@ export function MemberManagePage({ params }: { params?: { id?: string } }) { | |
| }, | ||
| }); | ||
|
|
||
| if (isLoading || !myInfoData?.result) { | ||
| return <></>; | ||
| } | ||
|
|
||
| const isLeader = myInfo?.crewMemberRole === MEMBER_ROLE.LEADER; | ||
|
|
||
| const handleDeleteMember = isLeader | ||
| ? (targetMemberId: number) => | ||
| deleteMutation.mutate({ crewId, targetMemberId }) | ||
|
|
@@ -106,10 +136,21 @@ export function MemberManagePage({ params }: { params?: { id?: string } }) { | |
| requestCount={requests.length} | ||
| /> | ||
| </div> | ||
| <div | ||
| className={styles.mainContainer} | ||
| ref={activeTab === 'member' ? scrollRef : undefined} | ||
| > | ||
| <div className={styles.mainContainer} ref={setMainContainerRef}> | ||
| {(isPullRefreshing || pullProgress > 0) && ( | ||
| <div className={styles.pullIndicator} aria-hidden> | ||
| {isPullRefreshing ? ( | ||
| <> | ||
| <div className={pageLoaderSpinner} /> | ||
| <p className={styles.pullText}>새로고침 중</p> | ||
| </> | ||
| ) : ( | ||
| <p className={styles.pullHint}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| {pullProgress >= 1 ? '놓으면 새로고침' : '당겨서 새로고침'} | ||
| </p> | ||
| )} | ||
| </div> | ||
| )} | ||
| {activeTab === 'request' ? ( | ||
| <RequestListView crewId={crewId} requests={requests} /> | ||
| ) : ( | ||
|
|
||
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.
❌ 위반 사항: 중복 스타일
pullHint스타일은 바로 아래에 정의된pullText스타일과 완전히 동일합니다. 스타일 가이드의 중복 스타일 제거 규칙에 따라 하나로 통합해야 합니다.🔧 개선 제안
pullHint를 제거하고, 이 스타일을 사용하는 곳에서는pullText를 대신 사용하도록 변경하는 것을 제안합니다. 이렇게 하면 코드 중복을 줄이고 유지보수성을 높일 수 있습니다.References