diff --git a/src/components/StampProgressBar.jsx b/src/components/StampProgressBar.jsx index 8d52645..0312f67 100644 --- a/src/components/StampProgressBar.jsx +++ b/src/components/StampProgressBar.jsx @@ -1,8 +1,9 @@ import React, { useState, useEffect } from "react"; import dummyStores from "../data/dummyStores"; -const StampProgressBar = ({ selectedStoreIdx }) => { +const StampProgressBar = ({ selectedStoreIdx, isSuccess }) => { const [lastStampedDiffText, setLastStampedDiffText] = useState(""); + useEffect(() => { if (selectedStoreIdx === null) { setLastStampedDiffText(""); @@ -26,6 +27,14 @@ const StampProgressBar = ({ selectedStoreIdx }) => { else setLastStampedDiffText(`${diffDays}일 전 완료`); }, [selectedStoreIdx]); + // 기존 도장 개수 + const baseCount = + selectedStoreIdx !== null + ? dummyStores[selectedStoreIdx].stampCount ?? 0 + : 0; + // 성공이면 UI상으로만 +1 + const displayCount = isSuccess ? baseCount + 1 : baseCount; + return (