Fix add-menu wizard: skip hours validation, show menu name, hide irrelevant sections

- Pass menuName in redirect URL from menu-builder
- Show menu name in wizard header and final review
- Skip hours validation in both JS and backend for add-menu mode
- Hide menu name, hours, and community meal fields in final step
- Add id to community meal card for toggling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-28 17:19:55 -08:00
parent 02a19f52be
commit 2fc30b8568
2 changed files with 40 additions and 29 deletions

View file

@ -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');

View file

@ -837,7 +837,7 @@
</div>
<!-- Community Meal Participation -->
<div class="summary-card" style="margin-top: 16px;">
<div class="summary-card" id="communityMealCard" style="margin-top: 16px;">
<div class="summary-card-header">
<h3>Community Meal Participation</h3>
<p style="margin: 4px 0 0; color: var(--gray-500); font-size: 14px;">Choose how this location participates.</p>
@ -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', `
<p>Your menu is ready to save!</p>
${config.menuId ? '' : `<p><strong>${business.name || 'Your Restaurant'}</strong></p>`}
${config.menuId && config.menuName
? `<p>Adding to: <strong>${config.menuName}</strong></p>`
: `<p><strong>${business.name || 'Your Restaurant'}</strong></p>`}
<ul style="margin: 12px 0; padding-left: 20px; color: var(--gray-600);">
<li>${categories.length} categories</li>
<li>${modifiers.length} modifier templates</li>
@ -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 = '<div class="loading-spinner" style="width:16px;height:16px;border-width:2px;"></div> Saving...';