diff --git a/admin-spa/src/routes/Coupons/Edit.tsx b/admin-spa/src/routes/Coupons/Edit.tsx index 6757668..d252450 100644 --- a/admin-spa/src/routes/Coupons/Edit.tsx +++ b/admin-spa/src/routes/Coupons/Edit.tsx @@ -43,11 +43,20 @@ export default function CouponEdit() { }, }); + // Smart back handler: go back in history if available, otherwise fallback to /coupons + const handleBack = () => { + if (window.history.state?.idx > 0) { + navigate(-1); // Go back in history + } else { + navigate('/coupons'); // Fallback to coupons index + } + }; + // Set contextual header useEffect(() => { const actions = (
- diff --git a/admin-spa/src/routes/Orders/Edit.tsx b/admin-spa/src/routes/Orders/Edit.tsx index e6b400f..61f57ce 100644 --- a/admin-spa/src/routes/Orders/Edit.tsx +++ b/admin-spa/src/routes/Orders/Edit.tsx @@ -60,11 +60,20 @@ export default function OrdersEdit() { } }, [order.meta]); + // Smart back handler: go back in history if available, otherwise fallback to order detail + const handleBack = () => { + if (window.history.state?.idx > 0) { + nav(-1); // Go back in history + } else { + nav(`/orders/${orderId}`); // Fallback to order detail + } + }; + // Set page header with back button and save button useEffect(() => { const actions = (
-