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:
parent
02a19f52be
commit
2fc30b8568
2 changed files with 40 additions and 29 deletions
|
|
@ -3505,7 +3505,7 @@
|
||||||
if (data.OK) {
|
if (data.OK) {
|
||||||
if (data.ACTION === 'created') {
|
if (data.ACTION === 'created') {
|
||||||
// New menu — redirect to wizard to populate it
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
this.toast(`Menu ${data.ACTION}!`, 'success');
|
this.toast(`Menu ${data.ACTION}!`, 'success');
|
||||||
|
|
|
||||||
|
|
@ -837,7 +837,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Community Meal Participation -->
|
<!-- 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">
|
<div class="summary-card-header">
|
||||||
<h3>Community Meal Participation</h3>
|
<h3>Community Meal Participation</h3>
|
||||||
<p style="margin: 4px 0 0; color: var(--gray-500); font-size: 14px;">Choose how this location participates.</p>
|
<p style="margin: 4px 0 0; color: var(--gray-500); font-size: 14px;">Choose how this location participates.</p>
|
||||||
|
|
@ -1045,6 +1045,12 @@
|
||||||
initializeConfig();
|
initializeConfig();
|
||||||
setupUploadZone();
|
setupUploadZone();
|
||||||
loadBusinessInfo();
|
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() {
|
function initializeConfig() {
|
||||||
|
|
@ -1055,6 +1061,7 @@
|
||||||
|
|
||||||
config.businessId = paramBusinessId ? parseInt(paramBusinessId) : null;
|
config.businessId = paramBusinessId ? parseInt(paramBusinessId) : null;
|
||||||
config.menuId = paramMenuId ? parseInt(paramMenuId) : null;
|
config.menuId = paramMenuId ? parseInt(paramMenuId) : null;
|
||||||
|
config.menuName = params.get('menuName') || null;
|
||||||
|
|
||||||
// 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/')
|
||||||
|
|
@ -2169,6 +2176,7 @@
|
||||||
if (config.menuId) {
|
if (config.menuId) {
|
||||||
document.getElementById('menuNameInput').parentElement.style.display = 'none';
|
document.getElementById('menuNameInput').parentElement.style.display = 'none';
|
||||||
document.getElementById('menuStartTime').closest('.summary-stat').style.display = 'none';
|
document.getElementById('menuStartTime').closest('.summary-stat').style.display = 'none';
|
||||||
|
document.getElementById('communityMealCard').style.display = 'none';
|
||||||
} else {
|
} else {
|
||||||
// Set default menu hours based on business hours (earliest open, latest close)
|
// Set default menu hours based on business hours (earliest open, latest close)
|
||||||
const hoursSchedule = business.hoursSchedule || [];
|
const hoursSchedule = business.hoursSchedule || [];
|
||||||
|
|
@ -2186,7 +2194,9 @@
|
||||||
|
|
||||||
addMessage('ai', `
|
addMessage('ai', `
|
||||||
<p>Your menu is ready to save!</p>
|
<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);">
|
<ul style="margin: 12px 0; padding-left: 20px; color: var(--gray-600);">
|
||||||
<li>${categories.length} categories</li>
|
<li>${categories.length} categories</li>
|
||||||
<li>${modifiers.length} modifier templates</li>
|
<li>${modifiers.length} modifier templates</li>
|
||||||
|
|
@ -2203,38 +2213,39 @@
|
||||||
console.log('=== SAVE MENU CALLED ===');
|
console.log('=== SAVE MENU CALLED ===');
|
||||||
console.log('Data to save:', config.extractedData);
|
console.log('Data to save:', config.extractedData);
|
||||||
|
|
||||||
// In add-menu mode, menu name/time were already set — skip these fields
|
// In add-menu mode, skip menu name/hours/community meal — already set
|
||||||
const menuNameEl = document.getElementById('menuNameInput');
|
if (!config.menuId) {
|
||||||
const menuName = menuNameEl ? menuNameEl.value.trim() || 'Main Menu' : 'Main Menu';
|
const menuName = document.getElementById('menuNameInput').value.trim() || 'Main Menu';
|
||||||
const menuStartTime = document.getElementById('menuStartTime')?.value || '';
|
const menuStartTime = document.getElementById('menuStartTime')?.value || '';
|
||||||
const menuEndTime = document.getElementById('menuEndTime')?.value || '';
|
const menuEndTime = document.getElementById('menuEndTime')?.value || '';
|
||||||
|
|
||||||
// Validate menu hours fall within business operating hours
|
// Validate menu hours fall within business operating hours
|
||||||
if (menuStartTime && menuEndTime) {
|
if (menuStartTime && menuEndTime) {
|
||||||
const hoursSchedule = config.extractedData.business.hoursSchedule || [];
|
const hoursSchedule = config.extractedData.business.hoursSchedule || [];
|
||||||
if (hoursSchedule.length > 0) {
|
if (hoursSchedule.length > 0) {
|
||||||
let earliestOpen = '23:59';
|
let earliestOpen = '23:59';
|
||||||
let latestClose = '00:00';
|
let latestClose = '00:00';
|
||||||
hoursSchedule.forEach(day => {
|
hoursSchedule.forEach(day => {
|
||||||
if (day.open && day.open < earliestOpen) earliestOpen = day.open;
|
if (day.open && day.open < earliestOpen) earliestOpen = day.open;
|
||||||
if (day.close && day.close > latestClose) latestClose = day.close;
|
if (day.close && day.close > latestClose) latestClose = day.close;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (menuStartTime < earliestOpen || menuEndTime > latestClose) {
|
if (menuStartTime < earliestOpen || menuEndTime > latestClose) {
|
||||||
showToast(`Menu hours must be within business operating hours (${earliestOpen} - ${latestClose})`, 'error');
|
showToast(`Menu hours must be within business operating hours (${earliestOpen} - ${latestClose})`, 'error');
|
||||||
return;
|
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 saveBtn = document.querySelector('#finalActions .btn-success');
|
||||||
const originalText = saveBtn.innerHTML;
|
const originalText = saveBtn.innerHTML;
|
||||||
saveBtn.innerHTML = '<div class="loading-spinner" style="width:16px;height:16px;border-width:2px;"></div> Saving...';
|
saveBtn.innerHTML = '<div class="loading-spinner" style="width:16px;height:16px;border-width:2px;"></div> Saving...';
|
||||||
|
|
|
||||||
Reference in a new issue