Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/ReviewRequest/list/apis/query-pr-reviews.ts
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;
Comment on lines +27 to +29

@jungwoo3490 jungwoo3490 Dec 7, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기 QueryPrReviewsQueryParams로 넘길 수 있는 값이랑 같으면 타입 좁혀줘도 좋을 것 같아요~!

/** PR 리뷰 요청글 제목 */
title: string;
/** 조회수 */
hitCount: number;
/** 작성일자/시각 */
createdAt: string;
}

export interface QueryPrReviewsResponse {
/** PR 리뷰 요청글 리스트 */
prReviews: PrReviewListItem[];
/** 마지막 페이지 여부 */
isLast: boolean;
}

export async function queryPrReviews(params?: QueryPrReviewsQueryParams): Promise<ApiResponse<QueryPrReviewsResponse>> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기 단언 들어가야하는거 되게 특이하네요,,, 그럼 searchParams 넘겨줄 때마다 단언이 필요하다니

Suggested change
searchParams: params as Record<string, string | number>,
searchParams: {...params}

object literal로 추론하게 요런 방법도 있네요 ㅎㅎㅎ..

@jungwoo3490 jungwoo3490 Dec 7, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
searchParams: params as Record<string, string | number>,
searchParams: {...params}

object literal로 추론하게 요런 방법도 있네요 ㅎㅎㅎ..

호오 리터럴로 추론하는 방법 좋은데요?!

});
}
6 changes: 6 additions & 0 deletions src/ReviewRequest/list/hooks/apis/querykeys.ts
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],
};
15 changes: 15 additions & 0 deletions src/ReviewRequest/list/hooks/apis/useQueryPrReviews.ts
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>({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return useQuery<ApiResponse<QueryPrReviewsResponse>, Error>({
return useQuery({

요기도 추론돼서 없어도 괜찮을 것 같아욤

queryFn: () => queryPrReviews(params),
queryKey: prListQueryKeys.prReviews(params),
});
};