-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
22 changed files
with
239 additions
and
335 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import type { GetCategoriesRes } from './types' | ||
import type { GetCategoriesRes, PostReq, PostDataInfoRes } from './types' | ||
|
||
import { http } from '@utils/http' | ||
|
||
export const getCategories = () => | ||
http.get<null, GetCategoriesRes>('/categories') | ||
|
||
export const getPostList = (param: PostReq) => { | ||
return http.get<PostReq, PostDataInfoRes>('/posts', param) | ||
} |
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,8 +1,20 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { getCategories } from './apis' | ||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query' | ||
import { getCategories, getPostList } from './apis' | ||
import type { PostReq, PostDataInfoRes } from './types' | ||
|
||
export const useGetCategoriesQuery = () => | ||
useQuery({ | ||
queryKey: ['getCategories'], | ||
queryFn: getCategories | ||
}) | ||
|
||
export const useGetPostListQuery = (param: PostReq) => | ||
useInfiniteQuery<PostDataInfoRes>({ | ||
queryKey: ['postList'], | ||
queryFn: () => getPostList(param), | ||
initialPageParam: null, | ||
getNextPageParam: lastPage => | ||
lastPage?.hasNext | ||
? lastPage.posts[lastPage.posts.length - 1].id | ||
: undefined | ||
}) |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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 |
---|---|---|
@@ -1,19 +1,11 @@ | ||
export type ProductItemProps = { | ||
productItem: { | ||
id: number | ||
mainImageUrl: string | ||
title: string | ||
price: number | ||
tradeArea: string | ||
tradeStatus: { | ||
code: number | ||
name: string | ||
} | ||
createdDate: string | ||
modifiedDate: string | ||
isLiked: boolean | ||
likeCount: number | ||
isReviewed: boolean | ||
sellerNickName: string | ||
thumnail: string | ||
location: string | ||
createdAt: string | ||
liked: boolean | ||
} | ||
} |
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,19 +1,17 @@ | ||
import type { | ||
FetchNextPageOptions, | ||
InfiniteData, | ||
InfiniteQueryObserverResult | ||
} from '@tanstack/react-query' | ||
import type { PostReq, PostDataInfoRes } from '@apis/post' | ||
|
||
export type ProductListProps = { | ||
productList: { | ||
id: number | ||
mainImageUrl: string | ||
title: string | ||
price: number | ||
tradeArea: string | ||
tradeStatus: { | ||
code: number | ||
name: string | ||
} | ||
createdDate: string | ||
modifiedDate: string | ||
isLiked: boolean | ||
likeCount: number | ||
isReviewed: boolean | ||
sellerNickName: string | ||
}[] | ||
postData?: PostDataInfoRes[] | ||
filterOption?: Pick<PostReq, 'sort' | 'category' | 'minPrice' | 'maxPrice'> | ||
hasNextPage?: boolean | ||
fetchNextPage?( | ||
options?: FetchNextPageOptions | ||
): Promise< | ||
InfiniteQueryObserverResult<InfiniteData<PostDataInfoRes, unknown>, Error> | ||
> | ||
} |
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.