diff --git a/public/index.html b/public/index.html index 21a3362..e09bae9 100644 --- a/public/index.html +++ b/public/index.html @@ -1887,6 +1887,23 @@ `; } + function formatSourcePrice(source) { + if (!source) return ''; + return typeof source.latestPrice === 'number' + ? formatCurrency(source.latestPrice, source.currency || 'USD') + : source.latestDisplayPrice || ''; + } + + function getPointContext(point) { + if (!point) return ''; + const unitContext = point.tripNights && point.unitPrice + ? `${formatCurrency(point.unitPrice, point.currency || 'USD')} x ${point.tripNights} nights` + : ''; + return [unitContext, point.unitDisplayPrice || point.displayPrice || point.decisionNote || ''] + .filter(Boolean) + .join(' · '); + } + function renderSourceSelect(opt) { const sources = getAvailableSources(opt); if (sources.length <= 1) { @@ -1894,7 +1911,7 @@ const sourceLabel = source?.sourceLabel || opt.automationInsights?.source || 'Unknown source'; const meta = source ? [ formatBookingType(source.bookingType, source.priceBasis), - source.latestDisplayPrice || (typeof source.latestPrice === 'number' ? formatCurrency(source.latestPrice, source.currency || 'USD') : ''), + formatSourcePrice(source), source.pointCount ? `${source.pointCount} point${source.pointCount === 1 ? '' : 's'}` : '', ].filter(Boolean).join(' · ') : ''; return ` @@ -1909,7 +1926,7 @@ const labelParts = [ source.sourceLabel || 'Unknown source', formatBookingType(source.bookingType, source.priceBasis), - source.latestDisplayPrice || (typeof source.latestPrice === 'number' ? formatCurrency(source.latestPrice, source.currency || 'USD') : ''), + formatSourcePrice(source), source.pointCount ? `${source.pointCount} pt${source.pointCount === 1 ? '' : 's'}` : '', ].filter(Boolean); return ``; @@ -1935,7 +1952,8 @@ currency: selectedPoint.currency || 'USD', } : (opt.automationInsights || {}); const currentPrice = typeof selectedPoint?.price === 'number' ? formatCurrency(selectedPoint.price, insights.currency || 'USD') : ''; - const priceLabel = selectedPoint?.displayPrice || insights.displayPrice || currentPrice || 'Not yet tracked'; + const priceLabel = currentPrice || insights.displayPrice || 'Not yet tracked'; + const priceContext = getPointContext(selectedPoint); const sourceLabel = selectedMeta?.sourceLabel || insights.source || 'Automation feed'; const bookingLabel = formatBookingType( selectedMeta?.bookingType || insights.bookingType, @@ -1949,7 +1967,7 @@ const inclusions = normalizeTextList(selectedPoint?.inclusions || opt.automationInsights?.inclusions); const limitations = normalizeTextList(selectedPoint?.limitations || opt.automationInsights?.limitations); const sourceMetaLine = selectedMeta - ? [selectedMeta.latestDisplayPrice || priceLabel, selectedMeta.pointCount ? `${selectedMeta.pointCount} point${selectedMeta.pointCount === 1 ? '' : 's'}` : ''] + ? [formatSourcePrice(selectedMeta) || priceLabel, selectedMeta.pointCount ? `${selectedMeta.pointCount} point${selectedMeta.pointCount === 1 ? '' : 's'}` : ''] .filter(Boolean) .join(' · ') : ''; @@ -1961,6 +1979,7 @@
Current price
${escapeHtml(priceLabel)}
+ ${priceContext ? `
${escapeHtml(priceContext)}
` : ''}
Source @@ -2088,13 +2107,16 @@ : `${delta > 0 ? '+' : '−'}${formatCurrency(Math.abs(delta), latest.currency)}`; const checkedLabel = latest.checkedAt ? formatTrackedDate(latest.checkedAt) : ''; const sourceLabel = selectedMeta?.sourceLabel || latest.source || 'Tracked source'; + const latestPriceLabel = formatCurrency(latest.price, latest.currency) || 'Tracked price'; + const latestContext = getPointContext(latest); return `
Automation price trail
-
${escapeHtml(sourceLabel)} · ${escapeHtml(latest.displayPrice || formatCurrency(latest.price, latest.currency) || 'Tracked price')}
+
${escapeHtml(sourceLabel)} · ${escapeHtml(latestPriceLabel)}
+ ${latestContext ? `
${escapeHtml(latestContext)}
` : ''}
${series.length} point${series.length === 1 ? '' : 's'}${checkedLabel ? ` · ${checkedLabel}` : ''}
@@ -2113,7 +2135,7 @@ ${points.map((point, index) => ` - ${(point.displayPrice || formatCurrency(point.price, point.currency) || 'Tracked price')} · ${formatTrackedDate(point.checkedAt) || 'automation run'} + ${formatCurrency(point.price, point.currency) || 'Tracked price'}${getPointContext(point) ? ` · ${getPointContext(point)}` : ''} · ${formatTrackedDate(point.checkedAt) || 'automation run'} `).join('')}