-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: pr 리뷰 요청 글 전체 조회 api 단 구현 #43
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||||||
| import { apiClient } from "@/common/api"; | ||||||||||
| import type { ApiResponse } from "@/common/types/api"; | ||||||||||
|
|
||||||||||
| export interface QueryPrReviewsQueryParams { | ||||||||||
| /** PR 현재 상태 : 보내지 않을시 모든 상태 조회 */ | ||||||||||
| status?: "open" | "closed"; | ||||||||||
| /** 정렬 순서 */ | ||||||||||
| order?: "createdAt-desc" | "createdAt-asc" | "hitCount-desc" | "hitCount-asc"; | ||||||||||
| /** 직군별 필터링 */ | ||||||||||
| position?: "BACKEND" | "FRONTEND"; | ||||||||||
| /** 마지막으로 조회된 요청글 id */ | ||||||||||
| lastReviewId?: number; | ||||||||||
| /** 페이지 사이즈 (기본 20) */ | ||||||||||
| size?: number; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * PR 리뷰 요청글 리스트 아이템 | ||||||||||
| * @ | ||||||||||
| */ | ||||||||||
| export interface PrReviewListItem { | ||||||||||
| /** 작성자 프로필 사진 URL */ | ||||||||||
| profileImageUrl: string; | ||||||||||
| /** 작성자 유저 태그 */ | ||||||||||
| username: string; | ||||||||||
| /** 요청글 상태 */ | ||||||||||
| status: string; | ||||||||||
| /** 분야 태그 */ | ||||||||||
| position: string; | ||||||||||
| /** PR 리뷰 요청글 제목 */ | ||||||||||
| title: string; | ||||||||||
| /** 조회수 */ | ||||||||||
| hitCount: number; | ||||||||||
| /** 작성일자/시각 */ | ||||||||||
| createdAt: string; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export interface QueryPrReviewsResponse { | ||||||||||
| /** PR 리뷰 요청글 리스트 */ | ||||||||||
| prReviews: PrReviewListItem[]; | ||||||||||
| /** 마지막 페이지 여부 */ | ||||||||||
| isLast: boolean; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export async function queryPrReviews(params?: QueryPrReviewsQueryParams): Promise<ApiResponse<QueryPrReviewsResponse>> { | ||||||||||
|
Member
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. 요기 반환 타입 명시 빼줘도 괜찮을 것 같아요-! |
||||||||||
| return apiClient.get<QueryPrReviewsResponse>("api/v1/pr-reviews", { | ||||||||||
| searchParams: params as Record<string, string | number>, | ||||||||||
|
Member
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. 요기 단언 들어가야하는거 되게 특이하네요,,, 그럼 searchParams 넘겨줄 때마다 단언이 필요하다니
Suggested change
object literal로 추론하게 요런 방법도 있네요 ㅎㅎㅎ..
Member
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.
호오 리터럴로 추론하는 방법 좋은데요?! |
||||||||||
| }); | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import type { QueryPrReviewsQueryParams } from "../../apis/query-pr-reviews"; | ||
|
|
||
| export const prListQueryKeys = { | ||
| all: () => ["pr-list"], | ||
| prReviews: (params?: QueryPrReviewsQueryParams) => [...prListQueryKeys.all(), "pr-reviews", params], | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||
| import type { ApiResponse } from "@/common/types/api"; | ||||||
| import { useQuery } from "@tanstack/react-query"; | ||||||
| import { | ||||||
| type QueryPrReviewsQueryParams, | ||||||
| type QueryPrReviewsResponse, | ||||||
| queryPrReviews, | ||||||
| } from "../../apis/query-pr-reviews"; | ||||||
| import { prListQueryKeys } from "./querykeys"; | ||||||
|
|
||||||
| export const useQueryPrReviews = (params?: QueryPrReviewsQueryParams) => { | ||||||
| return useQuery<ApiResponse<QueryPrReviewsResponse>, Error>({ | ||||||
|
Member
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.
Suggested change
요기도 추론돼서 없어도 괜찮을 것 같아욤 |
||||||
| queryFn: () => queryPrReviews(params), | ||||||
| queryKey: prListQueryKeys.prReviews(params), | ||||||
| }); | ||||||
| }; | ||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
요기
QueryPrReviewsQueryParams로 넘길 수 있는 값이랑 같으면 타입 좁혀줘도 좋을 것 같아요~!