Skip to content

Commit

Permalink
Rename: 컴포넌트 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
abcxj123 committed Apr 30, 2024
1 parent 9e99f6e commit 7a6e703
Showing 9 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/apis/apiClient.ts
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions src/components/molecules/CategoryList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const CategoryList = () => {
return <div></div>;
};

export default CategoryList;
5 changes: 0 additions & 5 deletions src/components/molecules/MenuButtonList.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const MenuSelectComp = () => {
const MenuCard = () => {
return (
<div className="flex flex-row grid grid-cols-4 gap-2 bg-starbucksBeige h-[55vh] ">
{/* 메뉴 버튼 영역 */}
@@ -9,4 +9,4 @@ const MenuSelectComp = () => {
);
};

export default MenuSelectComp;
export default MenuCard;
16 changes: 16 additions & 0 deletions src/components/ui/Category.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FC } from "react";

interface IProps {
categoryIdx: number;
categoryName: string;
}

const Category: FC<IProps> = ({ categoryIdx, categoryName }) => {
const setMenus = (categoryIdx: number) => {
// react-query를 사용해서 메뉴리스트 카테고리별로 갱신
};

return <div>dasd</div>;
};

export default Category;
Empty file removed src/components/ui/MenuButton.tsx
Empty file.
22 changes: 13 additions & 9 deletions src/contexts/basket-context.tsx → src/context/basketContext.tsx
Original file line number Diff line number Diff line change
@@ -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<BasketContextProp>({
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 });
}, []);

7 changes: 0 additions & 7 deletions src/contexts/menu.d.ts

This file was deleted.

9 changes: 8 additions & 1 deletion src/types/menu.d.ts
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 7a6e703

Please sign in to comment.