From d9f8ac0bfd1eca8372274a94cb4f2d84a3a89a64 Mon Sep 17 00:00:00 2001 From: yooseohyeon Date: Fri, 31 Jul 2026 19:04:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B8=B0=EC=82=AC=20=EA=B2=AC=EC=A0=81?= =?UTF-8?q?=20API=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?fetchInstance=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/api/moverEstimateRequests.ts | 44 ++++------------ src/types/moverEstimateRequest.ts | 79 ++++++---------------------- 2 files changed, 25 insertions(+), 98 deletions(-) diff --git a/src/lib/api/moverEstimateRequests.ts b/src/lib/api/moverEstimateRequests.ts index d608588b..3924ca16 100644 --- a/src/lib/api/moverEstimateRequests.ts +++ b/src/lib/api/moverEstimateRequests.ts @@ -1,15 +1,15 @@ import type { MoverEstimateRequestQuery, - MoverEstimateRequestResponse, + MoverEstimateRequestListResult, RejectEstimateRequest, - RejectEstimateResponse, - RejectedEstimateRequestListResponse, + RejectedEstimate, + RejectedEstimateRequestListResult, SendEstimateRequest, - SendEstimateResponse, + SentEstimate, } from "@/types/moverEstimateRequest"; -import { API_ROUTES } from "../constants/apiRoutes"; -import axiosInstance from "./axiosInstance"; +import fetchInstance from "@/lib/api/fetchInstance"; +import { API_ROUTES } from "@/lib/constants/apiRoutes"; // 기사 견적 요청 목록 조회 // GET /api/estimates/requests @@ -34,45 +34,27 @@ export async function getMoverEstimateRequests(query: MoverEstimateRequestQuery) //이사 유형 필터 query.moveType?.forEach((moveType) => params.append("moveType", moveType)); - const response = await axiosInstance.get( + return fetchInstance.get( `${API_ROUTES.ESTIMATES.REQUESTS}?${params.toString()}`, ); - - if (!response.data.success) { - throw new Error(response.data.error.code); - } - - return response.data.data; } // 기사가 고객의 견적 요청에 견적 전송 // POST /api/estimates/requests/:estimateRequestId export async function sendMoverEstimate(estimateRequestId: number, input: SendEstimateRequest) { - const response = await axiosInstance.post( + return fetchInstance.post( API_ROUTES.ESTIMATES.SEND(estimateRequestId), input, ); - - if (!response.data.success) { - throw new Error(response.data.error.message); - } - - return response.data.data; } // 기사 견적 반려 // POST /api/estimates/requests/:id/reject export async function rejectMoverEstimate(estimateRequestId: number, input: RejectEstimateRequest) { - const response = await axiosInstance.post( + return fetchInstance.post( API_ROUTES.ESTIMATES.REJECT(estimateRequestId), input, ); - - if (!response.data.success) { - throw new Error(response.data.error.message); - } - - return response.data.data; } //기사님 반려 내역 조회 @@ -81,13 +63,7 @@ export async function getRejectedEstimateRequests(cursor?: string, limit = 10) { const params = new URLSearchParams({ limit: String(limit) }); if (cursor) params.set("cursor", cursor); - const response = await axiosInstance.get( + return fetchInstance.get( `${API_ROUTES.ESTIMATES.REJECTIONS}?${params.toString()}`, ); - - if (!response.data.success) { - throw new Error(response.data.error.message); - } - - return response.data.data; } diff --git a/src/types/moverEstimateRequest.ts b/src/types/moverEstimateRequest.ts index cdf82f4f..b0678d5e 100644 --- a/src/types/moverEstimateRequest.ts +++ b/src/types/moverEstimateRequest.ts @@ -28,25 +28,14 @@ export type MoverEstimateRequestQuery = { limit: number; }; -export type MoverEstimateRequestResponse = - | { - success: true; - data: { - items: MoverEstimateRequest[]; - pagination: { - nextCursor: string | null; - hasNextPage: boolean; - totalCount: number; - }; - }; - } - | { - success: false; - error: { - code: string; - message: string; - }; - }; +export type MoverEstimateRequestListResult = { + items: MoverEstimateRequest[]; + pagination: { + nextCursor: string | null; + hasNextPage: boolean; + totalCount: number; + }; +}; // 기사 견적 전송 요청 Body export type SendEstimateRequest = { @@ -70,20 +59,6 @@ export type SentEstimate = { createdAt: string; }; -// 기사 견적 전송 API 응답 -export type SendEstimateResponse = - | { - success: true; - data: SentEstimate; - } - | { - success: false; - error: { - code: string; - message: string; - }; - }; - export type RejectedEstimate = { id: number; estimateRequestId: number; @@ -92,19 +67,6 @@ export type RejectedEstimate = { createdAt: string; }; -export type RejectEstimateResponse = - | { - success: true; - data: RejectedEstimate; - } - | { - success: false; - error: { - code: string; - message: string; - }; - }; - //기사 견적 반려 조회 export type RejectedEstimateRequestItem = { id: number; @@ -126,21 +88,10 @@ export type RejectedEstimateRequestItem = { }; }; -export type RejectedEstimateRequestListResponse = - | { - success: true; - data: { - items: RejectedEstimateRequestItem[]; - pagination: { - nextCursor: string | null; - hasNextPage: boolean; - }; - }; - } - | { - success: false; - error: { - code: string; - message: string; - }; - }; +export type RejectedEstimateRequestListResult = { + items: RejectedEstimateRequestItem[]; + pagination: { + nextCursor: string | null; + hasNextPage: boolean; + }; +};