Donation checkout via Ladill Pay (9% fee), church/giving QR pages, SSO, and platform scan forwarding. Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
/**
|
|
* Lightweight modal dispatch helpers (optional — balanceGate in layout is primary).
|
|
*/
|
|
|
|
export function openLadillModal(name) {
|
|
if (!name) {
|
|
return false;
|
|
}
|
|
|
|
window.dispatchEvent(new CustomEvent('open-modal', { detail: name, bubbles: true }));
|
|
|
|
return true;
|
|
}
|
|
|
|
export function closeLadillModal(name) {
|
|
if (!name) {
|
|
return false;
|
|
}
|
|
|
|
window.dispatchEvent(new CustomEvent('close-modal', { detail: name, bubbles: true }));
|
|
|
|
return true;
|
|
}
|
|
|
|
export function ladillNeedsTopup(balance, price) {
|
|
const normalizedBalance = Number.parseFloat(balance);
|
|
const normalizedPrice = Number.parseFloat(price);
|
|
|
|
if (!Number.isFinite(normalizedBalance) || !Number.isFinite(normalizedPrice)) {
|
|
return false;
|
|
}
|
|
|
|
return normalizedBalance <= 0 || normalizedBalance < normalizedPrice;
|
|
}
|
|
|
|
export function registerLadillConfirmStore(Alpine) {
|
|
Alpine.store('ladillConfirm', {
|
|
open: false,
|
|
title: '',
|
|
message: '',
|
|
confirmLabel: 'Confirm',
|
|
cancelLabel: 'Cancel',
|
|
variant: 'danger',
|
|
_resolve: null,
|
|
|
|
ask(options = {}) {
|
|
return new Promise((resolve) => {
|
|
this.title = options.title || 'Are you sure?';
|
|
this.message = options.message || '';
|
|
this.confirmLabel = options.confirmLabel || 'Confirm';
|
|
this.cancelLabel = options.cancelLabel || 'Cancel';
|
|
this.variant = options.variant || 'danger';
|
|
this._resolve = resolve;
|
|
this.open = true;
|
|
});
|
|
},
|
|
|
|
answer(confirmed) {
|
|
if (this._resolve) {
|
|
this._resolve(confirmed);
|
|
}
|
|
|
|
this.open = false;
|
|
this._resolve = null;
|
|
},
|
|
});
|
|
|
|
window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options);
|
|
}
|
|
|
|
export function registerLadillModalHelpers() {
|
|
window.openLadillModal = openLadillModal;
|
|
window.closeLadillModal = closeLadillModal;
|
|
window.ladillNeedsTopup = ladillNeedsTopup;
|
|
}
|