From 7a6e7031aaa17aef3e5aa0bac55765c9066a0e3b Mon Sep 17 00:00:00 2001 From: abcxj123 Date: Tue, 30 Apr 2024 17:04:36 +0900 Subject: [PATCH] =?UTF-8?q?Rename:=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/apiClient.ts | 2 +- src/components/molecules/CategoryList.tsx | 5 +++++ src/components/molecules/MenuButtonList.tsx | 5 ----- .../{MenuSelectComp.tsx => MenuCard.tsx} | 4 ++-- src/components/ui/Category.tsx | 16 ++++++++++++++ src/components/ui/MenuButton.tsx | 0 .../basketContext.tsx} | 22 +++++++++++-------- src/contexts/menu.d.ts | 7 ------ src/types/menu.d.ts | 9 +++++++- 9 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 src/components/molecules/CategoryList.tsx delete mode 100644 src/components/molecules/MenuButtonList.tsx rename src/components/organisms/{MenuSelectComp.tsx => MenuCard.tsx} (81%) create mode 100644 src/components/ui/Category.tsx delete mode 100644 src/components/ui/MenuButton.tsx rename src/{contexts/basket-context.tsx => context/basketContext.tsx} (85%) delete mode 100644 src/contexts/menu.d.ts diff --git a/src/apis/apiClient.ts b/src/apis/apiClient.ts index 65f63a0..0fbe7da 100644 --- a/src/apis/apiClient.ts +++ b/src/apis/apiClient.ts @@ -2,7 +2,7 @@ import axios, { AxiosInstance } from "axios"; import { menuApi } from "./interfaces/menuApi"; import { API_BASE_URL } from "./url"; import { getCookie } from "../utils/cookie"; -import MenuType from "../types/menu"; +import { MenuType } from "../types/menu"; export class ApiClient implements menuApi { private static instance: ApiClient; diff --git a/src/components/molecules/CategoryList.tsx b/src/components/molecules/CategoryList.tsx new file mode 100644 index 0000000..4f172f5 --- /dev/null +++ b/src/components/molecules/CategoryList.tsx @@ -0,0 +1,5 @@ +const CategoryList = () => { + return
; +}; + +export default CategoryList; diff --git a/src/components/molecules/MenuButtonList.tsx b/src/components/molecules/MenuButtonList.tsx deleted file mode 100644 index f0a1458..0000000 --- a/src/components/molecules/MenuButtonList.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const MenuButtonList = () => { - return
; -}; - -export default MenuButtonList; diff --git a/src/components/organisms/MenuSelectComp.tsx b/src/components/organisms/MenuCard.tsx similarity index 81% rename from src/components/organisms/MenuSelectComp.tsx rename to src/components/organisms/MenuCard.tsx index 3535733..7459cfe 100644 --- a/src/components/organisms/MenuSelectComp.tsx +++ b/src/components/organisms/MenuCard.tsx @@ -1,4 +1,4 @@ -const MenuSelectComp = () => { +const MenuCard = () => { return (
{/* 메뉴 버튼 영역 */} @@ -9,4 +9,4 @@ const MenuSelectComp = () => { ); }; -export default MenuSelectComp; +export default MenuCard; diff --git a/src/components/ui/Category.tsx b/src/components/ui/Category.tsx new file mode 100644 index 0000000..00c1d75 --- /dev/null +++ b/src/components/ui/Category.tsx @@ -0,0 +1,16 @@ +import { FC } from "react"; + +interface IProps { + categoryIdx: number; + categoryName: string; +} + +const Category: FC = ({ categoryIdx, categoryName }) => { + const setMenus = (categoryIdx: number) => { + // react-query를 사용해서 메뉴리스트 카테고리별로 갱신 + }; + + return
dasd
; +}; + +export default Category; diff --git a/src/components/ui/MenuButton.tsx b/src/components/ui/MenuButton.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/contexts/basket-context.tsx b/src/context/basketContext.tsx similarity index 85% rename from src/contexts/basket-context.tsx rename to src/context/basketContext.tsx index ecb3d30..4d41264 100644 --- a/src/contexts/basket-context.tsx +++ b/src/context/basketContext.tsx @@ -5,11 +5,12 @@ import { useContext, useReducer, } from "react"; +import { BasketMenuType } from "../types/menu"; type BasketContextProp = { - basket: Menu[]; + basket: BasketMenuType[]; // 장바구니에 담는 함수 - addBasket: (menu: Menu) => void; + addBasket: (menu: BasketMenuType) => void; // 장바구니에서 삭제하는 함수 removeBasket: (basketIdx: number) => void; // 장바구니에서 개수 +1하는 함수 @@ -26,22 +27,25 @@ type ProviderProps = { type Action = | { type: "addBasket"; - payload: Menu; + payload: BasketMenuType; } | { type: "removeBasket" | "plusMenu" | "minusMenu"; payload: number }; -const DefaultBasket: Menu[] = []; +const DefaultBasket: BasketMenuType[] = []; const BasketContext = createContext({ - basket: [] as Menu[], - addBasket: (menu: Menu) => {}, + basket: [] as BasketMenuType[], + addBasket: (menu: BasketMenuType) => {}, removeBasket: (basketIdx: number) => {}, plusMenu: (basketIdx: number) => {}, minusMenu: (basketIdx: number) => {}, }); -const reducer = (basketList: Menu[], { type, payload }: Action): Menu[] => { - let newer: Menu[] = []; +const reducer = ( + basketList: BasketMenuType[], + { type, payload }: Action, +): BasketMenuType[] => { + let newer: BasketMenuType[] = []; switch (type) { case "addBasket": @@ -95,7 +99,7 @@ const reducer = (basketList: Menu[], { type, payload }: Action): Menu[] => { export const BasketProvider = ({ children }: ProviderProps) => { const [basket, dispatch] = useReducer(reducer, DefaultBasket); - const addBasket = useCallback((menu: Menu) => { + const addBasket = useCallback((menu: BasketMenuType) => { dispatch({ type: "addBasket", payload: menu }); }, []); diff --git a/src/contexts/menu.d.ts b/src/contexts/menu.d.ts deleted file mode 100644 index 6b3b718..0000000 --- a/src/contexts/menu.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -type Menu = { - basketIdx: number; - menuIdx: number; - orderDetailCount: number; - menuTemperature?: string | null; - menuSize?: string | null; -}; diff --git a/src/types/menu.d.ts b/src/types/menu.d.ts index 7044eef..7f3e3e8 100644 --- a/src/types/menu.d.ts +++ b/src/types/menu.d.ts @@ -7,5 +7,12 @@ type MenuType = { menuDate: string; categoryIdx: number; }; +type BasketMenuType = { + basketIdx: number; + menuIdx: number; + orderDetailCount: number; + menuTemperature?: string | null; + menuSize?: string | null; +}; -export default MenuType; +export { MenuType, BasketMenuType };