diff --git a/apps/nowait-user/src/api/client.ts b/apps/nowait-user/src/api/client.ts new file mode 100644 index 00000000..848232a0 --- /dev/null +++ b/apps/nowait-user/src/api/client.ts @@ -0,0 +1,13 @@ +// api/client.ts +import axios from "axios"; + +const API_URI = import.meta.env.VITE_SERVER_URI; + +export const authApi = axios.create({ + baseURL: `${API_URI}/v1`, + withCredentials: true, +}); + +export const publicApi = axios.create({ + baseURL: `${API_URI}/v1`, +}); \ No newline at end of file diff --git a/apps/nowait-user/src/api/menu.ts b/apps/nowait-user/src/api/menu.ts index 5e1a0f8a..dcfba61c 100644 --- a/apps/nowait-user/src/api/menu.ts +++ b/apps/nowait-user/src/api/menu.ts @@ -1,5 +1,5 @@ import type { MenuType } from "../types/order/menu"; -import axios from "axios"; +import { publicApi } from "./client"; interface AllMenuServerResponse { success: boolean; @@ -17,16 +17,10 @@ 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( + const res = await publicApi.get( `/stores/${publicCode}/menus` ); if (res?.data.success) return res.data; @@ -40,6 +34,6 @@ export const getStoreMenu = async ( publicCode: string, menuId: number ): Promise => { - const res = await UserApi.get(`/stores/${publicCode}/menus/${menuId}`); + const res = await publicApi.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 258c20a9..1a960fb0 100644 --- a/apps/nowait-user/src/api/order.ts +++ b/apps/nowait-user/src/api/order.ts @@ -4,13 +4,7 @@ import type { 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`, -}); +import { authApi, publicApi } from "./client"; //주문 생성 export const createOrder = async ( @@ -18,7 +12,7 @@ export const createOrder = async ( tableId: number, payload: OrderType ): Promise => { - const res = await UserApi.post( + const res = await authApi.post( `/stores/${publicCode}/tables/${tableId}/orders`, payload ); @@ -30,7 +24,7 @@ export const getOrderDetails = async ( publicCode: string, tableId: number ): Promise => { - const res = await UserApi.get( + const res = await authApi.get( `/stores/${publicCode}/tables/${tableId}/orders` ); return res.data; @@ -38,7 +32,7 @@ export const getOrderDetails = async ( //주점 QR, 계좌번호 조회 export const getStorePayments = async (publicCode: string) => { - const res = await UserApi.get( + const res = await publicApi.get( `/stores/${publicCode}/payments` ); return res.data; diff --git a/apps/nowait-user/src/components/common/MenuList.tsx b/apps/nowait-user/src/components/common/MenuList.tsx index 5e2a3d04..913485b4 100644 --- a/apps/nowait-user/src/components/common/MenuList.tsx +++ b/apps/nowait-user/src/components/common/MenuList.tsx @@ -1,5 +1,6 @@ import type { MenuType } from "../../types/order/menu"; import MenuItem from "./MenuItem"; +import MenuListSkeleton from "./MenuListSkeleton"; const MenuList = ({ mode, @@ -10,32 +11,16 @@ const MenuList = ({ menus: MenuType[] | undefined; isLoading: boolean; }) => { + + if (isLoading) return ; return (

메뉴

    - {!isLoading ? ( - menus?.map((menu: MenuType) => { - return ; - }) - ) : ( - <> - {Array.from({ length: 5 }).map((_, i) => { - return ( -
  • -
    -
    -

    -

    -

    -
    -
    -
  • - ); - })} - - )} + {menus?.map((menu: MenuType) => { + return ; + })}
); diff --git a/apps/nowait-user/src/components/common/MenuListSkeleton.tsx b/apps/nowait-user/src/components/common/MenuListSkeleton.tsx new file mode 100644 index 00000000..f3a081cf --- /dev/null +++ b/apps/nowait-user/src/components/common/MenuListSkeleton.tsx @@ -0,0 +1,22 @@ +const MenuListSkeleton = () => { + return ( +
+

메뉴

+
    + {Array.from({ length: 5 }).map((_, i) => ( +
  • +
    +
    +
    +
    +
    +
    +
    +
  • + ))} +
+
+ ); +}; + +export default MenuListSkeleton; diff --git a/apps/nowait-user/src/pages/order/home/StorePage.tsx b/apps/nowait-user/src/pages/order/home/StorePage.tsx index f9dabe09..380b036f 100644 --- a/apps/nowait-user/src/pages/order/home/StorePage.tsx +++ b/apps/nowait-user/src/pages/order/home/StorePage.tsx @@ -29,12 +29,12 @@ const StorePage = () => { } }, [added]); + const hasCartItems = cart.length > 0; + const pagePaddingBottom = hasCartItems ? "pb-[116px]" : ""; return (
0 ? "pb-[116px]" : "" - } px-5`} + className={`flex flex-col grow min-h-dvh pt-7.5 ${pagePaddingBottom} px-5`} >
@@ -46,14 +46,13 @@ const StorePage = () => { />
- {cart && cart.length > 0 && ( + {hasCartItems && ( {modal.isOpen && ( { - if (remitValue === "kakao") { - window.open(`${remittance?.kakaoPayUrl}`, "_blank"); - } else if (remitValue === "toss") { - window.open(`${remittance?.tossUrl}`, "_blank"); - } else if (remitValue === "naver") { - window.open(`${remittance?.naverPayUrl}`, "_blank"); - } - navigate(`/${storeId}/remittanceWait`, { state: payer }); - }} + open={handleConfirm} close={modal.close} title={`${ remitValue === "direct" ? "직접 " : "" diff --git a/apps/nowait-user/src/pages/waiting/storeDetail/StoreDetailPage.tsx b/apps/nowait-user/src/pages/waiting/storeDetail/StoreDetailPage.tsx index c68cafa9..a8cc80a0 100644 --- a/apps/nowait-user/src/pages/waiting/storeDetail/StoreDetailPage.tsx +++ b/apps/nowait-user/src/pages/waiting/storeDetail/StoreDetailPage.tsx @@ -19,7 +19,7 @@ const StoreDetailPage = () => { return (
-
+