Files
Reservair/assets/js/templating/RsvSlotItems.js
T
2026-06-22 11:20:28 +02:00

22 lines
969 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Renders an array of slot objects into <li> DOM nodes for display in summary lists.
* Each slot must have start_utc, end_utc, price fields.
*/
export function render_slot_items(slots, locale, currency) {
const time_opts = { hour: '2-digit', minute: '2-digit' };
return slots.map(slot => {
const start = new Date(slot.start_utc);
const end = new Date(slot.end_utc);
const li = document.createElement('li');
li.className = 'rsv-summary-item';
li.innerHTML = `
<div class="rsv-summary-item-info">
<span class="rsv-summary-item-date">${start.toLocaleDateString(locale, { weekday: 'long', day: 'numeric', month: 'long' })}</span>
<span class="rsv-summary-item-time">${start.toLocaleTimeString(locale, time_opts)} ${end.toLocaleTimeString(locale, time_opts)}</span>
</div>
${slot.price > 0 ? `<span class="rsv-summary-item-price">${slot.price} ${currency}</span>` : ''}
`;
return li;
});
}