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 = (
-
navigate('/coupons')}>
+
{__('Back')}
{
+ if (window.history.state?.idx > 0) {
+ navigate(-1); // Go back in history
+ } else {
+ navigate('/customers'); // Fallback to customers index
+ }
+ };
+
// Page header
React.useEffect(() => {
if (!customer) {
@@ -46,7 +55,7 @@ export default function CustomerDetail() {
const actions = (
-
navigate('/customers')}>
+
{__('Back')}
navigate(`/customers/${customerId}/edit`)}>
diff --git a/admin-spa/src/routes/Customers/Edit.tsx b/admin-spa/src/routes/Customers/Edit.tsx
index 2955820..a31303a 100644
--- a/admin-spa/src/routes/Customers/Edit.tsx
+++ b/admin-spa/src/routes/Customers/Edit.tsx
@@ -46,11 +46,20 @@ export default function CustomerEdit() {
await updateMutation.mutateAsync(data);
};
+ // Smart back handler: go back in history if available, otherwise fallback to /customers
+ const handleBack = () => {
+ if (window.history.state?.idx > 0) {
+ navigate(-1); // Go back in history
+ } else {
+ navigate('/customers'); // Fallback to customers index
+ }
+ };
+
// Set page header with back button and save button
useEffect(() => {
const actions = (
-
navigate('/customers')}>
+
{__('Back')}
{
+ if (window.history.state?.idx > 0) {
+ nav(-1); // Go back in history
+ } else {
+ nav('/orders'); // Fallback to orders index
+ }
+ };
+
// Set contextual header with Back button and Edit action
useEffect(() => {
if (!order || isPrintMode) {
@@ -152,7 +161,7 @@ export default function OrderShow() {
const actions = (
-
nav('/orders')}>
+
{__('Back')}
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 = (
-
nav(`/orders/${orderId}`)}>
+
{__('Back')}
{
+ if (window.history.state?.idx > 0) {
+ navigate(-1); // Go back in history
+ } else {
+ navigate('/products'); // Fallback to products index
+ }
+ };
+
// Set page header with back button and save button
useEffect(() => {
const actions = (
- navigate('/products')}>
+
{__('Back')}