From 8886cfaef87a3764d92b459c46577d08a2ee197f Mon Sep 17 00:00:00 2001 From: YuJin020303 Date: Tue, 25 Nov 2025 21:41:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=209=EC=A3=BC=EC=B0=A8=20=EB=AF=B8?= =?UTF-8?q?=EC=85=982(=EB=AA=A8=EB=8B=AC)=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Chap9_mission/src/components/ClearBtn.tsx | 30 ++++-- .../src/components/DeleteModal.tsx | 99 +++++++++++++++++++ .../Chap9_mission/src/slices/modalSlice.ts | 35 +++++++ .../mission/Chap9_mission/src/store/store.ts | 2 + 4 files changed, 156 insertions(+), 10 deletions(-) create mode 100644 week09/mission/Chap9_mission/src/components/DeleteModal.tsx create mode 100644 week09/mission/Chap9_mission/src/slices/modalSlice.ts diff --git a/week09/mission/Chap9_mission/src/components/ClearBtn.tsx b/week09/mission/Chap9_mission/src/components/ClearBtn.tsx index 9be65ab..79c3716 100644 --- a/week09/mission/Chap9_mission/src/components/ClearBtn.tsx +++ b/week09/mission/Chap9_mission/src/components/ClearBtn.tsx @@ -1,20 +1,30 @@ import { useDispatch } from "../hooks/useCustomRedux"; -import { clearCart } from "../slices/cartSlice"; +import { useSelector } from "../hooks/useCustomRedux"; +import DeleteModal from "./DeleteModal"; +import { openModal } from "../slices/modalSlice"; export const ClearBtn = () => { + const { isOpen } = useSelector((state) => state.modal); + const dispatch = useDispatch(); - const handleClearCart = () => { - // 수량 증가 액션 디스패치 - dispatch(clearCart()); + const handleModalOpen = () => { + // 모달 열기 액션 디스패치 + dispatch(openModal()); }; return ( - + <> + + {/* 모달 표시 */} + {isOpen && ( + + )} + ); }; diff --git a/week09/mission/Chap9_mission/src/components/DeleteModal.tsx b/week09/mission/Chap9_mission/src/components/DeleteModal.tsx new file mode 100644 index 0000000..5030946 --- /dev/null +++ b/week09/mission/Chap9_mission/src/components/DeleteModal.tsx @@ -0,0 +1,99 @@ +import { useDispatch } from "../hooks/useCustomRedux"; +import { clearCart } from "../slices/cartSlice"; +import { closeModal } from "../slices/modalSlice"; + +const DeleteModal = () => { + const dispatch = useDispatch(); + + const handleClearCart = () => { + // 수량 증가 액션 디스패치 + dispatch(clearCart()); + dispatch(closeModal()); + }; + + const handleModalClose = () => { + // 모달 닫기 액션 디스패치 + dispatch(closeModal()); + }; + + return ( +
+ {/* 오버레이 */} +