Show package inclusions in bundles
This commit is contained in:
@@ -2286,6 +2286,41 @@
|
||||
.filter(Boolean))];
|
||||
}
|
||||
|
||||
function formatComponentLabel(value) {
|
||||
const key = String(value || '').trim().toLowerCase();
|
||||
const labels = {
|
||||
flight: 'Flight',
|
||||
flights: 'Flight',
|
||||
hotel: 'Hotel',
|
||||
hoteltransfer: 'Hotel transfer',
|
||||
hoteltransfers: 'Hotel transfers',
|
||||
transfer: 'Transfer',
|
||||
transfers: 'Transfers',
|
||||
golf: 'Golf',
|
||||
nightlife: 'Nightlife',
|
||||
excursion: 'Excursion',
|
||||
incidentals: 'Incidentals',
|
||||
amenities: 'Amenities',
|
||||
};
|
||||
if (labels[key]) return labels[key];
|
||||
return String(value || '')
|
||||
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
||||
.replace(/[_-]+/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.replace(/\b\w/g, (char) => char.toUpperCase());
|
||||
}
|
||||
|
||||
function renderComponentChips(items) {
|
||||
const chips = normalizeTextList(items).map(formatComponentLabel);
|
||||
if (!chips.length) return '';
|
||||
return `
|
||||
<div class="option-detail-list">
|
||||
${chips.map(item => `<span class="option-detail-chip">${escapeHtml(item)}</span>`).join('')}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderTextChips(items) {
|
||||
const chips = normalizeTextList(items);
|
||||
if (!chips.length) return '';
|
||||
@@ -2390,7 +2425,9 @@
|
||||
const inclusions = filterStandaloneDetails(selectedPoint?.inclusions || opt.automationInsights?.inclusions);
|
||||
const limitations = filterStandaloneDetails(selectedPoint?.limitations || opt.automationInsights?.limitations);
|
||||
const includedComponents = normalizeTextList(selectedPoint?.includedComponents || opt.automationInsights?.includedComponents);
|
||||
const flightsIncluded = includedComponents.some(item => /flight/i.test(item));
|
||||
const excludedComponents = normalizeTextList(selectedPoint?.excludedComponents || opt.automationInsights?.excludedComponents);
|
||||
const packageHighlights = normalizeTextList(selectedPoint?.highlights || opt.automationInsights?.highlights);
|
||||
const packageInclusions = normalizeTextList(selectedPoint?.inclusions || opt.automationInsights?.inclusions);
|
||||
const sourceMetaLine = selectedMeta
|
||||
? [formatSourcePrice(selectedMeta) || priceLabel, selectedMeta.pointCount ? `${selectedMeta.pointCount} point${selectedMeta.pointCount === 1 ? '' : 's'}` : '']
|
||||
.filter(Boolean)
|
||||
@@ -2465,11 +2502,38 @@
|
||||
`);
|
||||
}
|
||||
|
||||
if (tabId === BUNDLE_TAB_ID && flightsIncluded) {
|
||||
if (tabId === BUNDLE_TAB_ID && includedComponents.length) {
|
||||
sections.push(`
|
||||
<div class="option-detail-section">
|
||||
<div class="option-detail-title">Flights included</div>
|
||||
${renderTextChips(includedComponents)}
|
||||
<div class="option-detail-title">What's included</div>
|
||||
${renderComponentChips(includedComponents)}
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
if (tabId === BUNDLE_TAB_ID && excludedComponents.length) {
|
||||
sections.push(`
|
||||
<div class="option-detail-section">
|
||||
<div class="option-detail-title">Not included</div>
|
||||
${renderComponentChips(excludedComponents)}
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
if (tabId === BUNDLE_TAB_ID && packageHighlights.length) {
|
||||
sections.push(`
|
||||
<div class="option-detail-section">
|
||||
<div class="option-detail-title">Package perks</div>
|
||||
${renderTextChips(packageHighlights)}
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
if (tabId === BUNDLE_TAB_ID && packageInclusions.length) {
|
||||
sections.push(`
|
||||
<div class="option-detail-section">
|
||||
<div class="option-detail-title">Package inclusions</div>
|
||||
${renderTextChips(packageInclusions)}
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user