Use sessionStorage instead of URL params for wizard menu context
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ec6bfdd9c9
commit
61c10d9175
2 changed files with 20 additions and 10 deletions
|
|
@ -3504,8 +3504,13 @@
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.OK) {
|
if (data.OK) {
|
||||||
if (data.ACTION === 'created') {
|
if (data.ACTION === 'created') {
|
||||||
// New menu — redirect to wizard to populate it
|
// New menu — store context and redirect to wizard to populate it
|
||||||
window.location.href = `${BASE_PATH}/portal/setup-wizard.html?businessId=${this.config.businessId}&menuId=${data.MENUID}&menuName=${encodeURIComponent(menuName)}`;
|
sessionStorage.setItem('payfrit_wizard_menu', JSON.stringify({
|
||||||
|
businessId: this.config.businessId,
|
||||||
|
menuId: data.MENUID,
|
||||||
|
menuName: menuName
|
||||||
|
}));
|
||||||
|
window.location.href = `${BASE_PATH}/portal/setup-wizard.html`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.toast(`Menu ${data.ACTION}!`, 'success');
|
this.toast(`Menu ${data.ACTION}!`, 'success');
|
||||||
|
|
|
||||||
|
|
@ -1054,14 +1054,19 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
function initializeConfig() {
|
function initializeConfig() {
|
||||||
// Parse URL parameters for add-menu mode
|
// Check for add-menu context from sessionStorage
|
||||||
const params = new URLSearchParams(window.location.search);
|
const wizardMenu = sessionStorage.getItem('payfrit_wizard_menu');
|
||||||
const paramBusinessId = params.get('businessId');
|
if (wizardMenu) {
|
||||||
const paramMenuId = params.get('menuId');
|
try {
|
||||||
|
const ctx = JSON.parse(wizardMenu);
|
||||||
config.businessId = paramBusinessId ? parseInt(paramBusinessId) : null;
|
config.businessId = ctx.businessId || null;
|
||||||
config.menuId = paramMenuId ? parseInt(paramMenuId) : null;
|
config.menuId = ctx.menuId || null;
|
||||||
config.menuName = params.get('menuName') || null;
|
config.menuName = ctx.menuName || null;
|
||||||
|
sessionStorage.removeItem('payfrit_wizard_menu');
|
||||||
|
} catch (e) {
|
||||||
|
sessionStorage.removeItem('payfrit_wizard_menu');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Determine API base URL
|
// Determine API base URL
|
||||||
const basePath = window.location.pathname.includes('/biz.payfrit.com/')
|
const basePath = window.location.pathname.includes('/biz.payfrit.com/')
|
||||||
|
|
|
||||||
Reference in a new issue