Skip to content
Merged
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
12 changes: 9 additions & 3 deletions apps/nowait-user/src/api/menu.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UserApi from "../utils/UserApi";
import type { MenuType } from "../types/order/menu";
import axios from "axios";

interface AllMenuServerResponse {
success: boolean;
Expand All @@ -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<AllMenuServerResponse>(
`/v1/stores/${publicCode}/menus`
`/stores/${publicCode}/menus`
);
if (res?.data.success) return res.data;
} catch (error) {
Expand All @@ -34,6 +40,6 @@ export const getStoreMenu = async (
publicCode: string,
menuId: number
): Promise<MenuServerResponse> => {
const res = await UserApi.get(`/v1/stores/${publicCode}/menus/${menuId}`);
const res = await UserApi.get(`/stores/${publicCode}/menus/${menuId}`);
return res.data;
};
26 changes: 15 additions & 11 deletions apps/nowait-user/src/api/order.ts
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -13,7 +19,7 @@ export const createOrder = async (
payload: OrderType
): Promise<CreateOrderServerResponse> => {
const res = await UserApi.post(
`/v1/stores/${publicCode}/tables/${tableId}/orders`,
`/stores/${publicCode}/tables/${tableId}/orders`,
payload
);
return res.data;
Expand All @@ -24,18 +30,16 @@ export const getOrderDetails = async (
publicCode: string,
tableId: number
): Promise<OrderDetailsServerResponse> => {
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<StorePaymentsResponse>(
`/v1/stores/${publicCode}/payments`
);
return res.data;
} catch (error) {
console.log(error);
}
const res = await UserApi.get<StorePaymentsResponse>(
`/stores/${publicCode}/payments`
);
return res.data;
};
16 changes: 8 additions & 8 deletions apps/nowait-user/src/api/reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ServerResponse {

// 모든 주점 정보 가져오기
export const getAllStores = async () => {
const response = await UserApi.get<ServerResponse>("/v1/stores", {
const response = await UserApi.get<ServerResponse>("/stores", {
params: {
page: 0,
size: 50,
Expand All @@ -27,7 +27,7 @@ export const getAllStores = async () => {
export const getInfiniteAllStores = async (
pageParam: number
): Promise<{ storePageReadResponses: StoreType[]; hasNext: boolean }> => {
const response = await UserApi.get<ServerResponse>("/v1/stores", {
const response = await UserApi.get<ServerResponse>("/stores", {
params: {
page: pageParam,
size: 5,
Expand All @@ -39,7 +39,7 @@ export const getInfiniteAllStores = async (
// 주점 상세 정보 가져오기
export const getStore = async (publicCode: string) => {
try {
const res = await UserApi.get<StoreResponse>(`/v1/stores/${publicCode}`);
const res = await UserApi.get<StoreResponse>(`/stores/${publicCode}`);
return res.data;
} catch (error) {
console.log(error);
Expand All @@ -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<BookmarkResponse> => {
const res = await UserApi.get("/v1/users/me/bookmarks");
const res = await UserApi.get("/users/me/bookmarks");
return res.data;
};

Expand All @@ -71,15 +71,15 @@ 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 });
};

// 북마크 삭제
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;
Expand Down