fix: sidebar highlight on detail pages with numeric IDs
When visiting /merchants/billing/subscriptions/3, currentPage was set to '3' instead of 'subscriptions'. Now skips numeric trailing segments so the parent page stays highlighted. Applied to both merchant and store init-alpine.js. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,11 @@ function data() {
|
|||||||
const segments = path.split('/').filter(Boolean);
|
const segments = path.split('/').filter(Boolean);
|
||||||
// For /merchants/dashboard -> 'dashboard'
|
// For /merchants/dashboard -> 'dashboard'
|
||||||
// For /merchants/billing/subscriptions -> 'subscriptions'
|
// For /merchants/billing/subscriptions -> 'subscriptions'
|
||||||
this.currentPage = segments[segments.length - 1] || 'dashboard';
|
// For /merchants/billing/subscriptions/3 -> 'subscriptions' (skip numeric IDs)
|
||||||
|
const last = segments[segments.length - 1] || 'dashboard';
|
||||||
|
this.currentPage = /^\d+$/.test(last) && segments.length > 2
|
||||||
|
? segments[segments.length - 2]
|
||||||
|
: last;
|
||||||
|
|
||||||
// Load merchant name from JWT token
|
// Load merchant name from JWT token
|
||||||
const token = localStorage.getItem('merchant_token');
|
const token = localStorage.getItem('merchant_token');
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ function data() {
|
|||||||
// Set current page from URL
|
// Set current page from URL
|
||||||
const path = window.location.pathname;
|
const path = window.location.pathname;
|
||||||
const segments = path.split('/').filter(Boolean);
|
const segments = path.split('/').filter(Boolean);
|
||||||
this.currentPage = segments[segments.length - 1] || 'dashboard';
|
// For /store/ABC/orders/123 -> 'orders' (skip numeric IDs)
|
||||||
|
const last = segments[segments.length - 1] || 'dashboard';
|
||||||
|
this.currentPage = /^\d+$/.test(last) && segments.length > 2
|
||||||
|
? segments[segments.length - 2]
|
||||||
|
: last;
|
||||||
|
|
||||||
// Get store code from URL
|
// Get store code from URL
|
||||||
if (segments[0] === 'store' && segments[1]) {
|
if (segments[0] === 'store' && segments[1]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user