-
Notifications
You must be signed in to change notification settings - Fork 2
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
🐛 찜 목록 연결 안되던 오류 해결 #101
Merged
Merged
🐛 찜 목록 연결 안되던 오류 해결 #101
Changes from all commits
Commits
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
63 changes: 18 additions & 45 deletions
63
src/app/(root)/(routes)/mypage/mydibs/components/MyDibsList.tsx
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
46 changes: 46 additions & 0 deletions
46
src/app/(root)/(routes)/mypage/mydibs/components/MyDibsTemplate.tsx
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,46 @@ | ||
'use client' | ||
|
||
import { useEffect, useRef } from 'react' | ||
import ExceptionBoundary from '@/components/domain/exception-boundary' | ||
import { useMyDibsQuery } from '@/hooks/api/queries/useMyDibsQuery' | ||
import { useIntersectionObserver } from '@/hooks/useIntersectionObserver' | ||
import MyDibsList from './MyDibsList' | ||
|
||
const MyDibsTemplate = () => { | ||
const { data, fetchNextPage, isLoading, isError, isFetchingNextPage } = | ||
useMyDibsQuery() | ||
console.log(data) | ||
|
||
const lastElementRef = useRef<HTMLDivElement | null>(null) | ||
const entry = useIntersectionObserver(lastElementRef, { threshold: 1.0 }) | ||
|
||
useEffect(() => { | ||
if (isFetchingNextPage) { | ||
return | ||
} | ||
|
||
if (entry?.isIntersecting) { | ||
fetchNextPage() | ||
} | ||
}, [entry?.isIntersecting, fetchNextPage, isFetchingNextPage]) | ||
|
||
const isEmpty = data?.pages[0].data.dibList.length === 0 | ||
|
||
return ( | ||
<> | ||
<div> | ||
<ExceptionBoundary | ||
isLoading={isLoading} | ||
isError={isError} | ||
isEmpty={isEmpty} | ||
isFetchingNextPage={isFetchingNextPage} | ||
> | ||
<MyDibsList data={data} /> | ||
</ExceptionBoundary> | ||
</div> | ||
|
||
<div ref={lastElementRef} /> | ||
</> | ||
) | ||
} | ||
export default MyDibsTemplate |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { COMMON_PAGE_SIZE } from '@/constants/pageSize' | ||
import { GetCardListReq, GetMyCardListReq } from '@/services/card/card' | ||
import { | ||
GetCardListReq, | ||
GetMyCardListReq, | ||
GetMyDibsReq, | ||
} from '@/services/card/card' | ||
import { GetMyTradeHistoryListReq } from '@/services/history/history' | ||
import { GetMySuggestionListReq } from '@/services/suggestion/suggestion' | ||
import { getQueryParams } from '@/utils/getQueryParams' | ||
|
@@ -50,7 +54,11 @@ const ApiEndPoint = { | |
putUserProfile: () => '/users/profile-image', | ||
putUserNickname: () => '/users/nickname', | ||
postSuggestion: (suggestionType: string) => `/suggestions/${suggestionType}`, | ||
getMyDibsList: (cursorId: number) => `/dibs/?cursorId=${cursorId}`, | ||
getMyDibsList: ({ cursorId }: GetMyDibsReq) => | ||
`/dibs/?${getQueryParams({ | ||
cursorId, | ||
size: COMMON_PAGE_SIZE, | ||
})}`, | ||
Comment on lines
+57
to
+61
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. 요거 함수 꼭 여기 안에서 써야하나요??
자체를 cursorId 넣는 곳(사용처)에서 처리하면 좋을 것 같습니다 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. 좋은 의견 감사합니다. apiEndPoint는 문자열만 존재하는게 좋을 것 같네요. |
||
getMyTradeHistoryList: ({ cursorId }: GetMyTradeHistoryListReq) => { | ||
return `/complete-requests/user/?${getQueryParams({ | ||
cursorId, | ||
|
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import { useInfiniteQuery } from '@tanstack/react-query' | ||
import { getMyDibs } from '@/services/card/card' | ||
import { GetMyDibsRes, getMyDibs } from '@/services/card/card' | ||
|
||
export const useMyDibsQuery = () => { | ||
return useInfiniteQuery({ | ||
queryKey: ['myDibs'], | ||
queryFn: async ({ pageParam = 0 }) => await getMyDibs(pageParam), | ||
initialPageParam: 0, | ||
getNextPageParam: (lastPage, allPages, lastPageParam) => { | ||
if (lastPage.length === 0) { | ||
return undefined | ||
} | ||
return lastPageParam + 1 | ||
queryFn: async ({ pageParam = undefined }) => | ||
await getMyDibs({ cursorId: pageParam }), | ||
initialPageParam: undefined, | ||
getNextPageParam: (lastPage: GetMyDibsRes) => { | ||
return lastPage.data.nextCursorId | ||
}, | ||
}) | ||
} |
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
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.
data보단 다른 이름으로 처리해도 좋을 것 같아요!