/* ───── Services & Pricing section + Booking / payment modal ─────
Both render from window.SITE (see services.js — single source). */
const fmtPrice = (n) => `${window.SITE.currency}${n}`;
/* The pricing UI — themed cards grouped by category. Each item carries
its name + price forward to the booking modal via onSelect. */
const Services = ({ onSelect }) => {
const { serviceGroups } = window.SITE;
return (
Services & Pricing
Sit down, choose your reading.
Pick a service, pay by UPI or Paytm, then send your payment screenshot
on WhatsApp to confirm your booking.
{serviceGroups.map((g, gi) => (
{g.group}
{g.blurb &&
{g.blurb}
}
{g.items.map((s, i) => (
{fmtPrice(s.price)}
))}
))}
);
};
/* Booking / payment modal — shows UPI QR + Paytm, then a pre-filled
WhatsApp deep link carrying the chosen service + price. */
const BookingModal = ({ service, onClose }) => {
React.useEffect(() => {
if (!service) return;
const onKey = (e) => { if (e.key === "Escape") onClose(); };
document.addEventListener("keydown", onKey);
document.body.style.overflow = "hidden";
return () => {
document.removeEventListener("keydown", onKey);
document.body.style.overflow = "";
};
}, [service, onClose]);
if (!service) return null;
const { payment } = window.SITE;
const priceLabel = fmtPrice(service.price);
const waText = `Hi, I booked ${service.name} (${priceLabel}), sharing my payment screenshot.`;
const waHref = `https://wa.me/${payment.whatsapp}?text=${encodeURIComponent(waText)}`;
// Build the UPI pay QR live (pre-fills payee + exact amount). Falls back to
// the optional payment.qr image if the QR library isn't available.
let qrSrc = payment.qr;
if (payment.upiId && typeof window.qrcode === "function") {
try {
const upiStr =
`upi://pay?pa=${payment.upiId}` +
`&pn=${encodeURIComponent(payment.upiName || "")}` +
`&am=${service.price}&cu=INR&tn=${encodeURIComponent(service.name)}`;
const qr = window.qrcode(0, "M");
qr.addData(upiStr);
qr.make();
qrSrc = qr.createDataURL(6, 12);
} catch (e) { /* keep image fallback */ }
}
return (
e.stopPropagation()}>
Confirm your booking
{service.name}
{priceLabel}
{service.desc &&
{service.desc}
}
{ e.currentTarget.style.display = "none"; }}
/>
Scan with any UPI app to pay {priceLabel}
{payment.upiId && (
UPI ID
{payment.upiId}
)}
or pay on Paytm
{payment.paytm}
- Pay {priceLabel} using the QR code or Paytm number above.
- Take a screenshot of the successful payment.
- Tap the button below and send the screenshot on WhatsApp to confirm.
Confirm on WhatsApp
);
};
Object.assign(window, { Services, BookingModal });