-
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 branch 'develop' into feat/issue-366
- Loading branch information
Showing
25 changed files
with
233 additions
and
249 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
This file was deleted.
Oops, something went wrong.
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,7 +1,5 @@ | ||
export { default as useCategoryContext } from './useCategoryContext'; | ||
export { default as useMemberActionContext } from './useMemberActionContext'; | ||
export { default as useMemberValueContext } from './useMemberValueContext'; | ||
export { default as useProductReviewContext } from './useProductReviewContext'; | ||
export { default as useProductReviewPageContext } from './useProductReviewPageContext'; | ||
export { default as useReviewFormActionContext } from './useReviewFormActionContext'; | ||
export { default as useReviewFormValueContext } from './useReviewFormValueContext'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
frontend/src/hooks/product/useInfiniteProductReviewsQuery.ts
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,29 @@ | ||
import { useInfiniteQuery } from '@tanstack/react-query'; | ||
|
||
import { productApi } from '@/apis'; | ||
import type { ProductReviewResponse } from '@/types/response'; | ||
|
||
const fetchProductReviews = async (pageParam: number, productId: number, sort: string) => { | ||
const res = await productApi.get({ | ||
params: `/${productId}/reviews`, | ||
queries: `?sort=${sort}&page=${pageParam}`, | ||
credentials: true, | ||
}); | ||
|
||
const data: ProductReviewResponse = await res.json(); | ||
return data; | ||
}; | ||
|
||
const useInfiniteProductReviewsQuery = (productId: number, sort: string) => { | ||
return useInfiniteQuery({ | ||
queryKey: ['productReviews', productId, sort], | ||
queryFn: ({ pageParam = 0 }) => fetchProductReviews(pageParam, productId, sort), | ||
getNextPageParam: (prevResponse: ProductReviewResponse) => { | ||
const isLast = prevResponse.page.lastPage; | ||
const nextPage = prevResponse.page.requestPage + 1; | ||
return isLast ? undefined : nextPage; | ||
}, | ||
}); | ||
}; | ||
|
||
export default useInfiniteProductReviewsQuery; |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import { useInfiniteQuery } from '@tanstack/react-query'; | ||
|
||
import { categoryApi } from '@/apis'; | ||
import type { CategoryProductResponse } from '@/types/response'; | ||
|
||
const fetchProducts = async (pageParam: number, categoryId: number, sort: string) => { | ||
const res = await categoryApi.get({ | ||
params: `/${categoryId}/products`, | ||
queries: `?page=${pageParam}&sort=${sort}`, | ||
}); | ||
|
||
const data: CategoryProductResponse = await res.json(); | ||
return data; | ||
}; | ||
|
||
const useInfiniteProductsQuery = (categoryId: number, sort: string) => { | ||
return useInfiniteQuery({ | ||
queryKey: ['products', categoryId, sort], | ||
queryFn: ({ pageParam = 0 }) => fetchProducts(pageParam, categoryId, sort), | ||
getNextPageParam: (prevResponse: CategoryProductResponse) => { | ||
const isLast = prevResponse.page.lastPage; | ||
const nextPage = prevResponse.page.requestPage + 1; | ||
return isLast ? undefined : nextPage; | ||
}, | ||
}); | ||
}; | ||
|
||
export default useInfiniteProductsQuery; |
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.