diff --git a/portal/menu-builder.html b/portal/menu-builder.html index 79411ec..048592b 100644 --- a/portal/menu-builder.html +++ b/portal/menu-builder.html @@ -3505,7 +3505,7 @@ if (data.OK) { if (data.ACTION === 'created') { // New menu — redirect to wizard to populate it - window.location.href = `${BASE_PATH}/portal/setup-wizard.html?businessId=${this.config.businessId}&menuId=${data.MENUID}`; + window.location.href = `${BASE_PATH}/portal/setup-wizard.html?businessId=${this.config.businessId}&menuId=${data.MENUID}&menuName=${encodeURIComponent(menuName)}`; return; } this.toast(`Menu ${data.ACTION}!`, 'success'); diff --git a/portal/setup-wizard.html b/portal/setup-wizard.html index 5c84729..edb88e6 100644 --- a/portal/setup-wizard.html +++ b/portal/setup-wizard.html @@ -837,7 +837,7 @@ -
+

Community Meal Participation

Choose how this location participates.

@@ -1045,6 +1045,12 @@ initializeConfig(); setupUploadZone(); loadBusinessInfo(); + + // In add-menu mode, update the header to show the menu name + if (config.menuId && config.menuName) { + document.querySelector('.wizard-header h1').textContent = `Setup: ${config.menuName}`; + document.querySelector('.wizard-header p').textContent = 'Upload menu images or PDFs to extract categories, items, and modifiers for this menu.'; + } }); function initializeConfig() { @@ -1055,6 +1061,7 @@ config.businessId = paramBusinessId ? parseInt(paramBusinessId) : null; config.menuId = paramMenuId ? parseInt(paramMenuId) : null; + config.menuName = params.get('menuName') || null; // Determine API base URL const basePath = window.location.pathname.includes('/biz.payfrit.com/') @@ -2169,6 +2176,7 @@ if (config.menuId) { document.getElementById('menuNameInput').parentElement.style.display = 'none'; document.getElementById('menuStartTime').closest('.summary-stat').style.display = 'none'; + document.getElementById('communityMealCard').style.display = 'none'; } else { // Set default menu hours based on business hours (earliest open, latest close) const hoursSchedule = business.hoursSchedule || []; @@ -2186,7 +2194,9 @@ addMessage('ai', `

Your menu is ready to save!

- ${config.menuId ? '' : `

${business.name || 'Your Restaurant'}

`} + ${config.menuId && config.menuName + ? `

Adding to: ${config.menuName}

` + : `

${business.name || 'Your Restaurant'}

`}
  • ${categories.length} categories
  • ${modifiers.length} modifier templates
  • @@ -2203,38 +2213,39 @@ console.log('=== SAVE MENU CALLED ==='); console.log('Data to save:', config.extractedData); - // In add-menu mode, menu name/time were already set — skip these fields - const menuNameEl = document.getElementById('menuNameInput'); - const menuName = menuNameEl ? menuNameEl.value.trim() || 'Main Menu' : 'Main Menu'; - const menuStartTime = document.getElementById('menuStartTime')?.value || ''; - const menuEndTime = document.getElementById('menuEndTime')?.value || ''; + // In add-menu mode, skip menu name/hours/community meal — already set + if (!config.menuId) { + const menuName = document.getElementById('menuNameInput').value.trim() || 'Main Menu'; + const menuStartTime = document.getElementById('menuStartTime')?.value || ''; + const menuEndTime = document.getElementById('menuEndTime')?.value || ''; - // Validate menu hours fall within business operating hours - if (menuStartTime && menuEndTime) { - const hoursSchedule = config.extractedData.business.hoursSchedule || []; - if (hoursSchedule.length > 0) { - let earliestOpen = '23:59'; - let latestClose = '00:00'; - hoursSchedule.forEach(day => { - if (day.open && day.open < earliestOpen) earliestOpen = day.open; - if (day.close && day.close > latestClose) latestClose = day.close; - }); + // Validate menu hours fall within business operating hours + if (menuStartTime && menuEndTime) { + const hoursSchedule = config.extractedData.business.hoursSchedule || []; + if (hoursSchedule.length > 0) { + let earliestOpen = '23:59'; + let latestClose = '00:00'; + hoursSchedule.forEach(day => { + if (day.open && day.open < earliestOpen) earliestOpen = day.open; + if (day.close && day.close > latestClose) latestClose = day.close; + }); - if (menuStartTime < earliestOpen || menuEndTime > latestClose) { - showToast(`Menu hours must be within business operating hours (${earliestOpen} - ${latestClose})`, 'error'); - return; + if (menuStartTime < earliestOpen || menuEndTime > latestClose) { + showToast(`Menu hours must be within business operating hours (${earliestOpen} - ${latestClose})`, 'error'); + return; + } } } + + config.extractedData.menuName = menuName; + config.extractedData.menuStartTime = menuStartTime; + config.extractedData.menuEndTime = menuEndTime; + + // Community meal participation type (1=provide meals, 2=food bank) + const communityMealRadio = document.querySelector('input[name="communityMealType"]:checked'); + config.extractedData.communityMealType = communityMealRadio ? parseInt(communityMealRadio.value) : 1; } - config.extractedData.menuName = menuName; - config.extractedData.menuStartTime = menuStartTime; - config.extractedData.menuEndTime = menuEndTime; - - // Community meal participation type (1=provide meals, 2=food bank) - const communityMealRadio = document.querySelector('input[name="communityMealType"]:checked'); - config.extractedData.communityMealType = communityMealRadio ? parseInt(communityMealRadio.value) : 1; - const saveBtn = document.querySelector('#finalActions .btn-success'); const originalText = saveBtn.innerHTML; saveBtn.innerHTML = '
    Saving...';