@@ -17,6 +17,14 @@ import "./PurchaseSuccess.css";
1717import useWindowDimensions from "@/hooks/useWindowDimensions" ;
1818
1919const 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