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
4 changes: 2 additions & 2 deletions apps/nowait-user/src/api/reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export const getInfiniteAllStores = async (
};

// 주점 상세 정보 가져오기
export const getStore = async (storeId: number) => {
export const getStore = async (publicCode: string) => {
try {
const res = await UserApi.get<StoreResponse>(`/v1/stores/${storeId}`);
const res = await UserApi.get<StoreResponse>(`/v1/stores/${publicCode}`);
return res.data;
} catch (error) {
console.log(error);
Expand Down
30 changes: 7 additions & 23 deletions apps/nowait-user/src/pages/order/home/StorePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import MenuList from "../../../components/common/MenuList";
import SectionDivider from "../../../components/SectionDivider";
import { useQuery } from "@tanstack/react-query";
import { getStoreMenus } from "../../../api/menu";
import { getStore } from "../../../api/reservation";

const StorePage = () => {
const navigate = useNavigate();
Expand All @@ -28,35 +27,20 @@ const StorePage = () => {
navigate(location.pathname, { replace: true });
}, [added]);

// 매장 정보 조회
const { data: store, isLoading: storeLoading } = useQuery({
queryKey: ["store", storeId],
queryFn: () => getStore(Number(storeId)),
const { data: menus, isLoading } = useQuery({
queryKey: ["storeMenus", storeId],
queryFn: () => getStoreMenus(storeId!),
select: (data) => data?.response,
});

// 메뉴 조회 (publicCode 사용)
const { data: menus, isLoading: menusLoading } = useQuery({
queryKey: ["storeMenus", store?.publicCode],
queryFn: () => getStoreMenus(store!.publicCode),
select: (data) => data?.response,
enabled: !!store?.publicCode,
});

const isLoading = storeLoading || menusLoading;

console.log(menus, "asd");
console.log(menus,"asd")
return (
<div>
<div className="flex flex-col flex-grow pb-[112px] min-h-dvh pt-7.5 px-5">
<div className="flex-grow">
<StoreHeader storeName={menus?.storeName} isLoading={isLoading} />
<StoreHeader storeName={menus?.storeName} isLoading={isLoading}/>
<SectionDivider />
<MenuList
mode="order"
menus={menus?.menuReadDto}
isLoading={isLoading}
/>
<MenuList mode="order" menus={menus?.menuReadDto} isLoading={isLoading}/>
</div>
</div>
{cart && cart.length > 0 && (
Expand All @@ -77,4 +61,4 @@ const StorePage = () => {
);
};

export default StorePage;
export default StorePage;
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ const StoreDetailPage = () => {
isError,
} = useQuery({
queryKey: ["store", storeId],
queryFn: () => getStore(Number(storeId)),
queryFn: () => getStore(storeId!),
select: (data) => data?.response,
});

const { data: menus, isLoading: menusIsLoading } = useQuery({
queryKey: ["storeMenus", store?.publicCode],
queryFn: () => getStoreMenus(store!.publicCode),
queryKey: ["storeMenus", storeId],
queryFn: () => getStoreMenus(storeId!),
select: (data) => data?.response,
enabled: !!store?.publicCode,
});

const handleBookmarkButton = async () => {
Expand Down Expand Up @@ -174,4 +174,4 @@ const StoreDetailPage = () => {
);
};

export default StoreDetailPage;
export default StoreDetailPage;
1 change: 1 addition & 0 deletions apps/nowait-user/src/types/order/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export interface MenuType {
menuId: number;
storeId: number;
publicCode: string;
name: string;
description: string;
price: number;
Expand Down