#26 - Loading animation + success message fix
This commit was merged in pull request #31.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { render_slot_items } from '../RsvSlotItems.js';
|
||||
|
||||
export function reservation_summary_renderer(symbols) {
|
||||
const slots = symbols.slots ?? [];
|
||||
const pricing = symbols.pricing ?? {};
|
||||
|
||||
if (!Array.isArray(slots) || slots.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const s = ReservairStrings.summary;
|
||||
const locale = navigator.language;
|
||||
const currency = pricing.currency ?? s.currency;
|
||||
|
||||
const items = render_slot_items(slots, locale, currency);
|
||||
const itemsHtml = items.map(li => li.outerHTML).join('');
|
||||
|
||||
const footerRows = [];
|
||||
const subtotal = pricing.subtotal ?? 0;
|
||||
footerRows.push(`
|
||||
<div class="rsv-summary-footer-row rsv-summary-subtotal">
|
||||
<span class="rsv-summary-footer-label">${s.subtotal}</span>
|
||||
<span class="rsv-summary-footer-value">${subtotal} ${currency}</span>
|
||||
</div>
|
||||
`);
|
||||
|
||||
if (pricing.discount && pricing.discount.percent > 0) {
|
||||
const amount = pricing.discount.amount ?? 0;
|
||||
const reason = pricing.discount.reason ?? '';
|
||||
footerRows.push(`
|
||||
<div class="rsv-summary-footer-row rsv-summary-discount">
|
||||
<span class="rsv-summary-footer-label">${s.discount}: ${reason}</span>
|
||||
<span class="rsv-summary-footer-value">-${amount} ${currency}</span>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
const total = pricing.total ?? 0;
|
||||
footerRows.push(`
|
||||
<div class="rsv-summary-footer-row rsv-summary-total">
|
||||
<span class="rsv-summary-footer-label">${s.total}</span>
|
||||
<span class="rsv-summary-footer-value">${total} ${currency}</span>
|
||||
</div>
|
||||
`);
|
||||
|
||||
return `
|
||||
<div class="rsv-summary rsv-summary-snapshot">
|
||||
<div class="rsv-summary-header">
|
||||
<span class="rsv-summary-title">${s.title}</span>
|
||||
</div>
|
||||
<ul class="rsv-summary-list">${itemsHtml}</ul>
|
||||
<div class="rsv-summary-footer rsv-summary-footer--pricing">
|
||||
${footerRows.join('')}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
function esc_html(str) {
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
export function reset_form_button_renderer(symbols) {
|
||||
const label = symbols.label ?? 'Odeslat znova';
|
||||
return `<button type="button" class="rsv-form-btn" data-rsv-reset>${esc_html(label)}</button>`;
|
||||
}
|
||||
Reference in New Issue
Block a user