Skip to content

Commit ab3ba51

Browse files
authored
fix: 결제 성공 페이지에서 orderId를 query param으로도 처리하도록 수정 (#413)
1 parent 5d709a3 commit ab3ba51

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/pages/payment/Purchase.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ const Purchase = () => {
228228
}
229229
);
230230
const orderData = response.data[0];
231-
navigate("/purchase/success", {
232-
state: { orderId: orderData.id },
233-
});
231+
// navigate("/purchase/success", {
232+
// state: { orderId: orderData.id },
233+
// });
234234
setIsLoading(false);
235235
return;
236236
}

src/pages/payment/PurchaseSuccess.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ import "./PurchaseSuccess.css";
1717
import useWindowDimensions from "@/hooks/useWindowDimensions";
1818

1919
const PurchaseSuccess = () => {
20+
const navigate = useNavigate();
21+
const location = useLocation();
22+
const stateOrderId = location.state?.orderId;
23+
24+
const queryParams = new URLSearchParams(location.search);
25+
const queryOrderId = queryParams.get("orderId");
26+
const orderId = stateOrderId || queryOrderId;
27+
2028
const [orderDate, setOrderDate] = useState("");
2129
const [scriptTitle, setScriptTitle] = useState("");
2230
const [buyScript, setBuyScript] = useState(false);
@@ -26,8 +34,6 @@ const PurchaseSuccess = () => {
2634

2735
const [isLoading, setIsLoading] = useState(false);
2836

29-
const navigate = useNavigate();
30-
const location = useLocation();
3137
const { orderId } = location.state || {};
3238
const { isSmallMobile } = useWindowDimensions().widthConditions;
3339

@@ -63,6 +69,10 @@ const PurchaseSuccess = () => {
6369
return <Loading />;
6470
}
6571

72+
if (!orderId) {
73+
// orderId가 정말 없으면 에러 처리 가능
74+
return <div>잘못된 접근입니다.</div>;
75+
}
6676
return (
6777
<div className="PurchaseSuccess">
6878
<div className="purchase-success">

0 commit comments

Comments
 (0)