diff --git a/src/components/Promotion/index.tsx b/src/components/Promotion/index.tsx index 7428a947..5529ab4d 100644 --- a/src/components/Promotion/index.tsx +++ b/src/components/Promotion/index.tsx @@ -7,7 +7,7 @@ import { memo, } from "react"; import { POST } from "@/utils/axios"; -import { ConfirmModal } from "@/components"; +import { CheckModal, ConfirmModal } from "@/components"; import clsx from "clsx"; interface Props { @@ -17,8 +17,9 @@ interface Props { function Promotion({ price, setPromotionId }: Props) { const [promotionCode, setPromotionCode] = useState(""); - const [isApply, setIsApply] = useState(false); + const [showCheckModal, setShowCheckModal] = useState(false); const [showConfirmModal, setShowConfirmModal] = useState(false); + const [checkMsg, setCheckMsg] = useState(""); const [confirmMsg, setConfirmMsg] = useState(""); const disable = useMemo(() => promotionCode.length === 0, [promotionCode]); @@ -30,9 +31,15 @@ function Promotion({ price, setPromotionId }: Props) { price: price, }; const response = await POST("/promotion/check", body, true); - setConfirmMsg(response.payload ?? response.message); - setShowConfirmModal(true); - if (response.statusCode === 200) setIsApply(true); + if (response.payload) { + setCheckMsg( + `'${promotionCode}' 코드를 사용할 수 있어요. \n 프로모션 코드를 적용하시겠어요?` + ); + setShowCheckModal(true); + } else { + setConfirmMsg(response.message); + setShowConfirmModal(true); + } } catch (e) { console.log(e); } @@ -58,7 +65,7 @@ function Promotion({ price, setPromotionId }: Props) { }, [promotionCode]); return ( -
프로모션 코드
(선택)
@@ -76,20 +83,21 @@ function Promotion({ price, setPromotionId }: Props) { disable ? "bg-[#cde5ff]" : "bg-primary" )} > - 확인 - - -