diff --git a/apps/nowait-user/src/api/menu.ts b/apps/nowait-user/src/api/menu.ts index e8e7e0f..5e1a0f8 100644 --- a/apps/nowait-user/src/api/menu.ts +++ b/apps/nowait-user/src/api/menu.ts @@ -1,5 +1,5 @@ -import UserApi from "../utils/UserApi"; import type { MenuType } from "../types/order/menu"; +import axios from "axios"; interface AllMenuServerResponse { success: boolean; @@ -17,11 +17,17 @@ interface MenuServerResponse { status: number; } +const API_URI = import.meta.env.VITE_SERVER_URI; + +const UserApi = axios.create({ + baseURL: `${API_URI}/v1`, +}); + //주점에 해당하는 모든 메뉴 조회 export const getStoreMenus = async (publicCode: string) => { try { const res = await UserApi.get( - `/v1/stores/${publicCode}/menus` + `/stores/${publicCode}/menus` ); if (res?.data.success) return res.data; } catch (error) { @@ -34,6 +40,6 @@ export const getStoreMenu = async ( publicCode: string, menuId: number ): Promise => { - const res = await UserApi.get(`/v1/stores/${publicCode}/menus/${menuId}`); + const res = await UserApi.get(`/stores/${publicCode}/menus/${menuId}`); return res.data; }; diff --git a/apps/nowait-user/src/api/order.ts b/apps/nowait-user/src/api/order.ts index dee4058..258c20a 100644 --- a/apps/nowait-user/src/api/order.ts +++ b/apps/nowait-user/src/api/order.ts @@ -1,10 +1,16 @@ -import UserApi from "../utils/UserApi"; import type { CreateOrderServerResponse, OrderDetailsServerResponse, OrderType, StorePaymentsResponse, } from "../types/order/order"; +import axios from "axios"; + +const API_URI = import.meta.env.VITE_SERVER_URI; + +const UserApi = axios.create({ + baseURL: `${API_URI}/v1`, +}); //주문 생성 export const createOrder = async ( @@ -13,7 +19,7 @@ export const createOrder = async ( payload: OrderType ): Promise => { const res = await UserApi.post( - `/v1/stores/${publicCode}/tables/${tableId}/orders`, + `/stores/${publicCode}/tables/${tableId}/orders`, payload ); return res.data; @@ -24,18 +30,16 @@ export const getOrderDetails = async ( publicCode: string, tableId: number ): Promise => { - const res = await UserApi.get(`/v1/stores/${publicCode}/tables/${tableId}/orders`); + const res = await UserApi.get( + `/stores/${publicCode}/tables/${tableId}/orders` + ); return res.data; }; //주점 QR, 계좌번호 조회 export const getStorePayments = async (publicCode: string) => { - try { - const res = await UserApi.get( - `/v1/stores/${publicCode}/payments` - ); - return res.data; - } catch (error) { - console.log(error); - } + const res = await UserApi.get( + `/stores/${publicCode}/payments` + ); + return res.data; }; diff --git a/apps/nowait-user/src/api/reservation.ts b/apps/nowait-user/src/api/reservation.ts index 67e81e9..bcaa5a6 100644 --- a/apps/nowait-user/src/api/reservation.ts +++ b/apps/nowait-user/src/api/reservation.ts @@ -14,7 +14,7 @@ interface ServerResponse { // 모든 주점 정보 가져오기 export const getAllStores = async () => { - const response = await UserApi.get("/v1/stores", { + const response = await UserApi.get("/stores", { params: { page: 0, size: 50, @@ -27,7 +27,7 @@ export const getAllStores = async () => { export const getInfiniteAllStores = async ( pageParam: number ): Promise<{ storePageReadResponses: StoreType[]; hasNext: boolean }> => { - const response = await UserApi.get("/v1/stores", { + const response = await UserApi.get("/stores", { params: { page: pageParam, size: 5, @@ -39,7 +39,7 @@ export const getInfiniteAllStores = async ( // 주점 상세 정보 가져오기 export const getStore = async (publicCode: string) => { try { - const res = await UserApi.get(`/v1/stores/${publicCode}`); + const res = await UserApi.get(`/stores/${publicCode}`); return res.data; } catch (error) { console.log(error); @@ -51,18 +51,18 @@ export const createReservation = async ( storeId: number, payload: { partySize: number } ) => { - const res = await UserApi.post(`/v1/users/me/waitings/${storeId}`, payload); + const res = await UserApi.post(`/users/me/waitings/${storeId}`, payload); return res.data; }; export const getMyReservations = async () => { - const res = await UserApi.get("/v1/users/me/waitings"); + const res = await UserApi.get("/users/me/waitings"); return res.data; }; // 북마크 조회 export const getBookmark = async (): Promise => { - const res = await UserApi.get("/v1/users/me/bookmarks"); + const res = await UserApi.get("/users/me/bookmarks"); return res.data; }; @@ -71,7 +71,7 @@ export const createBookmark = async ( storeId: number | undefined, signal: AbortSignal ) => { - await UserApi.post(`/v1/users/me/bookmarks/${storeId}`, null, { signal }); + await UserApi.post(`/users/me/bookmarks/${storeId}`, null, { signal }); }; // 북마크 삭제 @@ -79,7 +79,7 @@ export const deleteBookmark = async ( storeId: number | undefined, signal: AbortSignal ) => { - const res = await UserApi.delete(`/v1/users/me/bookmarks/${storeId}`, { + const res = await UserApi.delete(`/users/me/bookmarks/${storeId}`, { signal, }); return res.data;