/* global React */ const { useState: useStateC, useEffect: useEffectC, useMemo: useMemoC } = React; // Shared helpers ============================================================ window.LQ_fmtINR = (n) => '₹' + (Number(n) || 0).toLocaleString('en-IN'); window.LQ_fmtDate = (s) => { if (!s) return ''; const d = new Date(s); if (isNaN(d)) return s; return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }); }; window.LQ_fmtDateTime = (s) => { if (!s) return ''; const d = new Date(s.replace(' ', 'T')); if (isNaN(d)) return s; return d.toLocaleString('en-IN', { day: '2-digit', month: 'short', hour: '2-digit', minute: '2-digit', hour12: true }); }; window.LQ_phone = (m) => (m || '').replace(/[^\d+]/g, ''); window.LQ_waLink = (mobile, msg) => `https://wa.me/${(mobile || '').replace(/^\+/, '').replace(/[^\d]/g, '')}?text=${encodeURIComponent(msg || '')}`; // ============================================================================= // DASHBOARD // ============================================================================= window.DashboardSection = function DashboardSection({ user }) { const [data, setData] = useStateC(null); const [err, setErr] = useStateC(''); useEffectC(() => { window.LQ.request('/dashboard').then(setData).catch((e) => setErr(e.message)); }, []); if (err) return
Welcome back, {user.name.split(' ')[0]}.
| Name | Service | Date · Time | Source | Status | Actions |
|---|---|---|---|---|---|
|
{a.name}
{a.mobile}
|
{a.service} |
{window.LQ_fmtDate(a.appt_date)}
{a.appt_time}
|
{a.source} | {a.status} |
{a.status === 'pending' && }
{(a.status === 'pending' || a.status === 'confirmed') && <>
>}
WA
|
| Name | Mobile | Visits | Spend | Last visit | Refill due | Actions |
|---|---|---|---|---|---|---|
|
{c.name}
{c.email && {c.email} }
|
{c.mobile} | {c.total_visits} | {window.LQ_fmtINR(c.total_spend)} | {window.LQ_fmtDate(c.last_visit_at)}{c.last_service && {c.last_service} } |
{c.refill_due_at ? {window.LQ_fmtDate(c.refill_due_at)} : —} |
{total} reminders pending. Open WhatsApp to send each — pre-filled message included.