Skip to content

Commit

Permalink
[codesquad-kiosk-max-team-02#51] feat: 상품 담기 클릭시 해당 모달이 닫히는 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
gunoc committed Jun 27, 2023
1 parent 13f86fa commit 0b99b88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
4 changes: 2 additions & 2 deletions fe/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ function App() {
const [productList, setProductList] = useState([]);
const [loading, setLoading] = useState(false);
const [orderList, setOrderList] = useState([]);
const [isPaymentModalOpen, setIsPaymentModalOpen] = useState(false);
const [paymentModalContent, setPaymentModalContent] = useState(null);
const [isAddMenuModalOpen, setIsAddMenuModalOpen] = useState(false);
const [addMenuModalContent, setAddMenuModalContent] = useState(null);
const [isPaymentModalOpen, setIsPaymentModalOpen] = useState(false);
const [paymentModalContent, setPaymentModalContent] = useState(null);

function addPaymentModalOpenHandler(content: any) {
if (isPaymentModalOpen) {
Expand Down
20 changes: 3 additions & 17 deletions fe/src/components/Main/MainArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,11 @@ export function MainArea({
function menuCardClickHandler(index: number) {
const product = productList[index - 1];
setSelectedProduct(product);
addModalOpenHandler(<AddMenu menuId={product.id} setOrderList={setOrderList} />);
addModalOpenHandler(
<AddMenu menuId={product.id} setOrderList={setOrderList} setSelectedProduct={setSelectedProduct} />,
);
}

// function addModalOpenHandler() {
// if (isModalOpen) {
// return;
// }

// setIsModalOpen(true);
// }

// function addModalCloseHandler() {
// if (!isModalOpen) {
// return;
// }

// setIsModalOpen(false);
// }

return (
<>
<main className={classes.main}>
Expand Down
9 changes: 7 additions & 2 deletions fe/src/components/Modal/AddMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React, { useState, useEffect } from 'react';
import classes from './AddMenu.module.css';
import { OptionButton } from './OptionButton';

/* 여기에서 바뀐 수량, 가격 정보 같은걸 가지고 있어야 함 => 장바구니에 내려주기 위해 */
import { Product } from '../../utils/types';

export function AddMenu({
menuId,
setOrderList,
setSelectedProduct,
}: {
menuId: number;
setOrderList: React.Dispatch<React.SetStateAction<never[]>>;
setSelectedProduct: React.Dispatch<React.SetStateAction<Product | null>>;
}) {
const [count, setCount] = useState(1);
const [temperature, setTemperature] = useState<string | null>(null);
Expand Down Expand Up @@ -66,6 +67,8 @@ export function AddMenu({
const isActive = temperature && size;

function handleSubmit() {
console.log('handleSubmit');

const sizeNum = size === 'big' ? 2 : 1;
const temperatureNum = temperature === 'ice' ? 2 : 1;

Expand All @@ -78,6 +81,8 @@ export function AddMenu({
},
...prevOrderList,
]);

setSelectedProduct(null);
}

return (
Expand Down

0 comments on commit 0b99b88

Please sign in to comment.