-
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.
- Loading branch information
Showing
110 changed files
with
1,768 additions
and
1,013 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,8 +1,9 @@ | ||
import type { DefaultError } from '@tanstack/react-query' | ||
import { useMutation } from '@tanstack/react-query' | ||
import { createUploadImages } from './apis' | ||
import type { CreateUploadImagesReq } from './types' | ||
import type { CreateUploadImagesReq, CreateUploadImagesRes } from './types' | ||
|
||
export const useCreateUploadImagesMutation = () => | ||
useMutation({ | ||
mutationFn: (files: CreateUploadImagesReq) => createUploadImages(files) | ||
useMutation<CreateUploadImagesRes, DefaultError, CreateUploadImagesReq>({ | ||
mutationFn: files => createUploadImages(files) | ||
}) |
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,12 @@ | ||
import type { UpdateLikeStatusReq } from './types' | ||
import type { | ||
GetLikedPostsReq, | ||
GetLikedPostsRes, | ||
UpdateLikeStatusReq | ||
} from './types' | ||
import { http } from '@utils/http' | ||
|
||
export const updateLikeStatus = (postId: number) => | ||
http.put<UpdateLikeStatusReq, null>('/posts/likes', { postId }) | ||
|
||
export const getLikedPosts = (params: GetLikedPostsReq) => | ||
http.get<GetLikedPostsReq, GetLikedPostsRes>('/posts/likes', params) |
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,2 +1,3 @@ | ||
export * from './types' | ||
export * from './apis' | ||
export * from './queries' |
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,15 @@ | ||
import { useMutation } from '@tanstack/react-query' | ||
import { updateLikeStatus } from './apis' | ||
import type { DefaultError } from '@tanstack/react-query' | ||
import { useQuery, useMutation } from '@tanstack/react-query' | ||
import { getLikedPosts, updateLikeStatus } from './apis' | ||
import type { GetLikedPostsReq, UpdateLikeStatusReq } from './types' | ||
|
||
export const useGetLikedPostsQuery = (searchOptions: GetLikedPostsReq) => | ||
useQuery({ | ||
queryKey: ['likedPosts', searchOptions], | ||
queryFn: () => getLikedPosts(searchOptions) | ||
}) | ||
|
||
export const useUpdateLikeStatusMutation = () => | ||
useMutation({ | ||
mutationFn: (postId: number) => updateLikeStatus(postId) | ||
useMutation<null, DefaultError, UpdateLikeStatusReq['postId']>({ | ||
mutationFn: postId => updateLikeStatus(postId) | ||
}) |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './types' | ||
export * from './apis' | ||
export * from './queries' |
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,20 @@ | ||
import type { | ||
GetReviewsReq, | ||
GetReviewsRes, | ||
CreateReviewReq, | ||
CreateReviewRes, | ||
GetReviewsCountsReq, | ||
GetReviewsCountsRes | ||
} from './types' | ||
import { http } from '@utils/http' | ||
|
||
export const getReviews = (params: GetReviewsReq) => | ||
http.get<GetReviewsReq, GetReviewsRes>('/reviews', params) | ||
|
||
export const createReviews = (payload: CreateReviewReq) => | ||
http.post<CreateReviewReq, CreateReviewRes>('/reviews', payload) | ||
|
||
export const getReviewsCounts = (params: GetReviewsCountsReq) => | ||
http.get<GetReviewsCountsReq, GetReviewsCountsRes>( | ||
`/reviews/counts?memberId=${params.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,16 @@ | ||
import type { TradeReviewActivityCodes } from '@types' | ||
|
||
export type SelectReviewCounts = { | ||
[key in TradeReviewActivityCodes]: number | ||
} | ||
|
||
export const initialReviewsCounts = { | ||
all: 0, | ||
seller: 0, | ||
buyer: 0 | ||
} | ||
|
||
export const initialReviews = { | ||
hasNext: false, | ||
reviews: [] | ||
} |
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 +1,3 @@ | ||
export * from './types' | ||
export * from './apis' | ||
export * from './queries' |
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,33 @@ | ||
import type { DefaultError } from '@tanstack/react-query' | ||
import { useMutation, useQuery } from '@tanstack/react-query' | ||
import { createReviews, getReviews, getReviewsCounts } from './apis' | ||
import type { SelectReviewCounts } from './data' | ||
import { initialReviewsCounts, initialReviews } from './data' | ||
import type { CreateReviewReq, CreateReviewRes, GetReviewsReq } from './types' | ||
import type { ReviewCount } from '@types' | ||
|
||
export const useGetReviewsCountsQuery = (memberId: number) => | ||
useQuery<ReviewCount, Error, SelectReviewCounts>({ | ||
queryKey: ['reviewsCounts', memberId], | ||
queryFn: async () => getReviewsCounts({ memberId }), | ||
select: ({ all, seller, buyer }) => ({ | ||
ALL: all, | ||
SELLER: seller, | ||
BUYER: buyer | ||
}), | ||
enabled: Boolean(memberId), | ||
initialData: initialReviewsCounts | ||
}) | ||
|
||
export const useGetReviewsQuery = (searchOptions: GetReviewsReq) => | ||
useQuery({ | ||
queryKey: ['reviews', searchOptions], | ||
queryFn: async () => getReviews({ ...searchOptions }), | ||
enabled: Boolean(searchOptions.memberId), | ||
initialData: initialReviews | ||
}) | ||
|
||
export const useReviewsMutation = () => | ||
useMutation<CreateReviewRes, DefaultError, CreateReviewReq>({ | ||
mutationFn: payload => createReviews(payload) | ||
}) |
Oops, something went wrong.