Use discovered header image URL in setup wizard
- Store headerImageUrl from discovery response - Show preview of discovered header in header image step - Download header via server-side downloadImages.php when no file uploaded - Remove outdated Lucee comment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8537c78fe2
commit
390f409cf8
1 changed files with 33 additions and 7 deletions
|
|
@ -1552,9 +1552,10 @@
|
|||
const menuPages = discoverResult.menuPages || [];
|
||||
const siteName = discoverResult.siteName || '';
|
||||
|
||||
// Store business info and platform URLs from discovery
|
||||
// Store business info, platform URLs, and header image from discovery
|
||||
config.discoveredBusinessInfo = discoverResult.businessInfo || {};
|
||||
config.platformPages = discoverResult.platformPages || [];
|
||||
config.discoveredHeaderImageUrl = discoverResult.headerImageUrl || '';
|
||||
|
||||
if (menuPages.length > 1) {
|
||||
// Multiple menus found — show confirmation step
|
||||
|
|
@ -2728,7 +2729,8 @@
|
|||
// Header Image step - between business info and categories
|
||||
function showHeaderImageStep() {
|
||||
const hasAutoHeader = config.headerImageFile != null;
|
||||
const headerText = hasAutoHeader
|
||||
const hasDiscoveredHeader = !hasAutoHeader && !!config.discoveredHeaderImageUrl;
|
||||
const headerText = (hasAutoHeader || hasDiscoveredHeader)
|
||||
? `<p>I found an image that would work great as your menu header!</p>`
|
||||
: `<p>This image appears at the top of your menu in the Payfrit app. It's the first thing customers see!</p>`;
|
||||
|
||||
|
|
@ -2743,14 +2745,14 @@
|
|||
<li><strong>Content:</strong> Your restaurant, food, or branding</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="headerUploadPreview" style="width:100%;aspect-ratio:3/1;background:#333;border-radius:8px;margin:12px 0;background-size:cover;background-position:center;display:${hasAutoHeader ? 'block' : 'none'};overflow:hidden;"></div>
|
||||
<div id="headerUploadPreview" style="width:100%;aspect-ratio:3/1;background:#333;border-radius:8px;margin:12px 0;background-size:cover;background-position:center;display:${(hasAutoHeader || hasDiscoveredHeader) ? 'block' : 'none'};overflow:hidden;"></div>
|
||||
<div style="display:flex;gap:12px;margin-top:12px;">
|
||||
<label class="btn btn-secondary" style="cursor:pointer;flex:1;text-align:center;">
|
||||
<input type="file" id="wizardHeaderFile" accept="image/png,image/jpeg,image/jpg" style="display:none;" onchange="previewWizardHeader(this)">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right:6px;vertical-align:middle;">
|
||||
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12"/>
|
||||
</svg>
|
||||
${hasAutoHeader ? 'Choose Different Image' : 'Choose Image'}
|
||||
${(hasAutoHeader || hasDiscoveredHeader) ? 'Choose Different Image' : 'Choose Image'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="action-buttons" style="margin-top:16px;">
|
||||
|
|
@ -2758,7 +2760,7 @@
|
|||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="20 6 9 17 4 12"/>
|
||||
</svg>
|
||||
${hasAutoHeader ? 'Use This Image' : 'Continue'}
|
||||
${(hasAutoHeader || hasDiscoveredHeader) ? 'Use This Image' : 'Continue'}
|
||||
</button>
|
||||
<button class="btn btn-secondary" onclick="skipHeaderImage()">Skip for Now</button>
|
||||
</div>
|
||||
|
|
@ -2775,6 +2777,13 @@
|
|||
}
|
||||
};
|
||||
reader.readAsDataURL(config.headerImageFile);
|
||||
} else if (hasDiscoveredHeader) {
|
||||
// Show preview from discovered URL
|
||||
const preview = document.getElementById('headerUploadPreview');
|
||||
if (preview) {
|
||||
preview.style.backgroundImage = `url(${config.discoveredHeaderImageUrl})`;
|
||||
preview.style.display = 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3671,14 +3680,31 @@
|
|||
showToast('Menu saved successfully!', 'success');
|
||||
|
||||
// Use the businessId from the response (in case it was newly created)
|
||||
// Lucee serializes struct keys as uppercase, so check both cases
|
||||
const summary = result.summary || result.SUMMARY || {};
|
||||
const finalBusinessId = summary.businessId || summary.BUSINESSID || summary.businessid || config.businessId;
|
||||
|
||||
// Update localStorage with the new business ID to keep user logged in
|
||||
localStorage.setItem('payfrit_portal_business', finalBusinessId);
|
||||
|
||||
// Upload header image if one was selected
|
||||
// Upload header image if one was selected, or download from discovered URL
|
||||
if (!config.headerImageFile && config.discoveredHeaderImageUrl && finalBusinessId) {
|
||||
// Download header from discovered URL server-side
|
||||
try {
|
||||
const dlResp = await fetch(`${config.apiBaseUrl}/setup/downloadImages.php`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ businessID: finalBusinessId, headerUrl: config.discoveredHeaderImageUrl })
|
||||
});
|
||||
const dlResult = await dlResp.json();
|
||||
if (dlResult.OK) {
|
||||
console.log('Header image downloaded from URL:', config.discoveredHeaderImageUrl);
|
||||
} else {
|
||||
console.warn('Header URL download failed:', dlResult);
|
||||
}
|
||||
} catch (dlErr) {
|
||||
console.warn('Header URL download error:', dlErr);
|
||||
}
|
||||
}
|
||||
if (config.headerImageFile && finalBusinessId) {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
|
|
|
|||
Reference in a new issue