@apextelemed/partner-core 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/api/index.d.ts +2 -2
  2. package/dist/api/index.js +3 -3
  3. package/dist/api/index.jsx +5 -3
  4. package/dist/{cart-CBH8Em8f.d.ts → cart-BwUwSzWh.d.ts} +25 -2
  5. package/dist/chunk/{OJSQZEB3.js → 4W5ONAFF.js} +7 -6
  6. package/dist/chunk/4W5ONAFF.js.map +1 -0
  7. package/dist/chunk/{DS4E7FAI.js → 4YUUZ532.js} +14 -4
  8. package/dist/chunk/4YUUZ532.js.map +1 -0
  9. package/dist/chunk/{T6IKS76T.jsx → 5CXUPFZU.jsx} +33 -15
  10. package/dist/chunk/{EIXZJX6R.js → 6MDLP62Y.js} +34 -17
  11. package/dist/chunk/6MDLP62Y.js.map +1 -0
  12. package/dist/chunk/{NYLIUR7O.jsx → 6QC4BETO.jsx} +6 -5
  13. package/dist/chunk/{ID67FV6R.js → 7COJH6FZ.js} +1014 -892
  14. package/dist/chunk/7COJH6FZ.js.map +1 -0
  15. package/dist/chunk/{MEF3FUQB.jsx → B5RBZKAK.jsx} +1 -1
  16. package/dist/chunk/{STEVQZ6U.jsx → CXBPVQ7W.jsx} +2 -2
  17. package/dist/chunk/{NP4CMOLW.jsx → GGY7VMZ2.jsx} +5 -3
  18. package/dist/chunk/{2XJBOTK5.js → ITK5F5AI.js} +2 -2
  19. package/dist/chunk/{2XJBOTK5.js.map → ITK5F5AI.js.map} +1 -1
  20. package/dist/chunk/{YHWX4NMV.js → NNTB7KL5.js} +3 -3
  21. package/dist/chunk/{YHWX4NMV.js.map → NNTB7KL5.js.map} +1 -1
  22. package/dist/chunk/{XMYPS7PT.js → O4V2YXBF.js} +5 -4
  23. package/dist/chunk/O4V2YXBF.js.map +1 -0
  24. package/dist/chunk/{HM27UGZM.jsx → YPZVHEBG.jsx} +1163 -1048
  25. package/dist/chunk/{I46Y2J5W.jsx → Z2CR6WKF.jsx} +15 -2
  26. package/dist/{client-DUrhrzOG.d.ts → client-Cm6n4V0r.d.ts} +8 -0
  27. package/dist/flows/index.d.ts +49 -3
  28. package/dist/flows/index.js +6 -6
  29. package/dist/flows/index.jsx +10 -8
  30. package/dist/index/index.d.ts +3 -3
  31. package/dist/index/index.js +7 -7
  32. package/dist/index/index.jsx +13 -9
  33. package/dist/pages/index.d.ts +1 -1
  34. package/dist/pages/index.js +5 -5
  35. package/dist/pages/index.jsx +5 -5
  36. package/dist/stores/index.d.ts +1 -1
  37. package/dist/stores/index.js +2 -2
  38. package/dist/stores/index.jsx +2 -2
  39. package/package.json +1 -1
  40. package/dist/chunk/DS4E7FAI.js.map +0 -1
  41. package/dist/chunk/EIXZJX6R.js.map +0 -1
  42. package/dist/chunk/ID67FV6R.js.map +0 -1
  43. package/dist/chunk/OJSQZEB3.js.map +0 -1
  44. package/dist/chunk/XMYPS7PT.js.map +0 -1
@@ -48,10 +48,10 @@ import {
48
48
  useSurveyFlow,
49
49
  useSurveyV2Flow,
50
50
  useUpdatePaymentMethodFlow
51
- } from "./NYLIUR7O.jsx";
51
+ } from "./6QC4BETO.jsx";
52
52
  import {
53
53
  fetchFunnelConfig
54
- } from "./I46Y2J5W.jsx";
54
+ } from "./Z2CR6WKF.jsx";
55
55
  import {
56
56
  usePrimitives
57
57
  } from "./J63XPQP4.jsx";
@@ -59,7 +59,7 @@ import {
59
59
  affiliateAuth_default,
60
60
  auth_default,
61
61
  cart_default
62
- } from "./STEVQZ6U.jsx";
62
+ } from "./CXBPVQ7W.jsx";
63
63
  import {
64
64
  ApiError,
65
65
  SUPPORT_ATTACHMENT_MAX_BYTES,
@@ -73,7 +73,7 @@ import {
73
73
  membersApi,
74
74
  subscriptionsApi,
75
75
  usersApi
76
- } from "./MEF3FUQB.jsx";
76
+ } from "./B5RBZKAK.jsx";
77
77
 
78
78
  // src/pages/Survey.tsx
79
79
  import { Show, For, createEffect, on } from "solid-js";
@@ -3873,7 +3873,7 @@ var US_STATES3 = [
3873
3873
  var US_STATE_OPTIONS3 = US_STATES3.map((s) => ({ value: s, label: s }));
3874
3874
 
3875
3875
  // src/pages/AdminDashboard.tsx
3876
- import { createEffect as createEffect10, createSignal as createSignal28, ErrorBoundary, Match as Match2, Show as Show44, Switch as Switch2, For as For32 } from "solid-js";
3876
+ import { createEffect as createEffect10, createSignal as createSignal28, ErrorBoundary, Match as Match2, Show as Show43, Switch as Switch2, For as For31 } from "solid-js";
3877
3877
 
3878
3878
  // src/pages/admin/Affiliates.tsx
3879
3879
  import { createSignal as createSignal10, For as For14, Match, Switch } from "solid-js";
@@ -3908,6 +3908,9 @@ function datetimeLocalToIso(value) {
3908
3908
  return new Date(value).toISOString();
3909
3909
  }
3910
3910
  var LIVE_SUBSCRIPTION_STATUSES = /* @__PURE__ */ new Set(["active", "paused", "past_due"]);
3911
+ function subscriptionLabel(s, fallback = "Subscription") {
3912
+ return s.medicationName || s.medication || fallback;
3913
+ }
3911
3914
 
3912
3915
  // src/pages/admin/shared.tsx
3913
3916
  function StatusBadge(props) {
@@ -9518,10 +9521,10 @@ function Categories() {
9518
9521
  }
9519
9522
 
9520
9523
  // src/pages/admin/Customers.tsx
9521
- import { createSignal as createSignal19, onCleanup, onMount, Show as Show34 } from "solid-js";
9524
+ import { createSignal as createSignal19, onCleanup, onMount, Show as Show33 } from "solid-js";
9522
9525
 
9523
9526
  // src/pages/admin/customers/CustomerDetail.tsx
9524
- import { createMemo as createMemo9, createResource as createResource10, createSignal as createSignal17, For as For22, Show as Show32 } from "solid-js";
9527
+ import { createMemo as createMemo9, createResource as createResource10, createSignal as createSignal17, For as For21, Show as Show31 } from "solid-js";
9525
9528
 
9526
9529
  // src/pages/admin/adminNav.ts
9527
9530
  import { createContext, useContext } from "solid-js";
@@ -9530,545 +9533,258 @@ function useAdminNav() {
9530
9533
  return useContext(AdminNavContext);
9531
9534
  }
9532
9535
 
9533
- // src/pages/admin/PatientDashboardPreview.tsx
9534
- import { Show as Show22, For as For16 } from "solid-js";
9535
- function PatientDashboardPreview(props) {
9536
- const data = useDashboardData({ authToken: () => props.token });
9537
- return <div
9538
- class="app-admin-modal-backdrop"
9539
- onClick={(e) => {
9540
- if (e.target === e.currentTarget) props.onClose();
9541
- }}
9542
- >
9543
- <div class="app-admin-card app-admin-modal" style={{ "max-width": "32rem" }}>
9544
- <div class="app-admin-modal-header">
9545
- <h3 class="app-admin-heading" style={{ "font-size": "1rem", margin: 0 }}>
9546
- Customer dashboard preview
9547
- </h3>
9548
- <button
9549
- type="button"
9550
- onClick={props.onClose}
9551
- class="app-admin-btn app-admin-btn-ghost"
9552
- style={{ border: "none", padding: "0.25rem 0.5rem", "font-size": "1.25rem" }}
9553
- >
9554
- ×
9555
- </button>
9556
- </div>
9557
-
9558
- <div class="app-admin-modal-body">
9559
- <div
9560
- style={{
9561
- padding: "0.5rem 0.75rem",
9562
- "border-radius": "var(--app-admin-radius-sm)",
9563
- background: "var(--app-admin-warning-bg)",
9564
- color: "var(--app-admin-warning-fg)",
9565
- "font-size": "0.75rem",
9566
- "font-weight": "500"
9567
- }}
9568
- >
9569
- Viewing as {props.customerName || "customer"} — read-only
9570
- </div>
9536
+ // src/pages/admin/customers/LifecycleBadge.tsx
9537
+ function LifecycleBadge(props) {
9538
+ const bucket = () => props.lifecycle?.bucket ?? props.bucket ?? null;
9539
+ const label = () => props.lifecycle?.label || (bucket() ? LIFECYCLE_LABEL[bucket()] : "Unknown");
9540
+ const tone = () => bucket() ? LIFECYCLE_TONE[bucket()] : "neutral";
9541
+ return <span class={`app-admin-badge app-admin-badge--${tone()}`} style={{ "text-transform": "none" }}>
9542
+ {label()}
9543
+ </span>;
9544
+ }
9571
9545
 
9572
- {
9573
- /* A failed read is an error with a retry — never presented as an
9574
- empty dashboard (the customer may have plenty of data). */
9575
- }
9576
- <Show22 when={data.error()} keyed>
9577
- {(msg) => <div
9578
- style={{
9579
- display: "flex",
9580
- "align-items": "center",
9581
- "justify-content": "space-between",
9582
- gap: "0.75rem",
9583
- padding: "0.5rem 0.75rem",
9584
- "border-radius": "var(--app-admin-radius-sm)",
9585
- background: "var(--app-admin-danger-bg)",
9586
- color: "var(--app-admin-danger-fg)",
9587
- "font-size": "0.75rem",
9588
- "font-weight": "500"
9589
- }}
9590
- >
9591
- <span>{msg}</span>
9592
- <button
9593
- type="button"
9594
- class="app-admin-btn app-admin-btn-ghost"
9595
- style={{ padding: "0.25rem 0.75rem" }}
9596
- onClick={() => data.retry()}
9546
+ // src/pages/admin/customers/modals/EditAmountModal.tsx
9547
+ import { createSignal as createSignal12, Show as Show22 } from "solid-js";
9548
+ function EditAmountModal(props) {
9549
+ const current2 = () => props.subscription.amountCents ?? 0;
9550
+ const [dollars, setDollars] = createSignal12((current2() / 100).toFixed(2));
9551
+ const [saving, setSaving] = createSignal12(false);
9552
+ const [error, setError] = createSignal12(null);
9553
+ const cents = () => {
9554
+ const n = Number(dollars());
9555
+ if (!Number.isFinite(n)) return null;
9556
+ return Math.round(n * 100);
9557
+ };
9558
+ const valid = () => {
9559
+ const c = cents();
9560
+ return c !== null && c >= 0 && c !== current2();
9561
+ };
9562
+ const discountActive = () => props.subscription.discountRecurringIndefinite || (props.subscription.discountRecurringRemaining ?? 0) > 0;
9563
+ const submit = async (e) => {
9564
+ e.preventDefault();
9565
+ const c = cents();
9566
+ if (c === null || !valid()) return;
9567
+ setSaving(true);
9568
+ setError(null);
9569
+ try {
9570
+ await props.onSave(c);
9571
+ props.onClose();
9572
+ } catch (err) {
9573
+ setError(err instanceof Error ? err.message : "Could not change the amount");
9574
+ } finally {
9575
+ setSaving(false);
9576
+ }
9577
+ };
9578
+ return <Modal
9579
+ title="Change subscription amount"
9580
+ onClose={props.onClose}
9581
+ footer={<>
9582
+ <button type="submit" form="edit-amount-form" class="app-admin-btn app-admin-btn-primary" disabled={saving() || !valid()}>
9583
+ {saving() ? "Saving\u2026" : "Save new amount"}
9584
+ </button>
9585
+ <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={props.onClose} disabled={saving()}>
9586
+ Cancel
9587
+ </button>
9588
+ </>}
9597
9589
  >
9598
- Retry
9599
- </button>
9600
- </div>}
9601
- </Show22>
9590
+ <form id="edit-amount-form" onSubmit={submit} style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
9591
+ <p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>
9592
+ {subscriptionLabel(props.subscription)} currently charges {centsToUsd(current2())} every{" "}
9593
+ {props.subscription.intervalDays ?? 30} days. The new amount applies to the next charge and every charge after it.
9594
+ </p>
9595
+ <FormRow label="New amount (USD)">
9596
+ <input
9597
+ class="app-admin-input"
9598
+ type="number"
9599
+ inputmode="decimal"
9600
+ min="0"
9601
+ step="0.01"
9602
+ value={dollars()}
9603
+ onInput={(e) => setDollars(e.currentTarget.value)}
9604
+ autofocus
9605
+ />
9606
+ </FormRow>
9607
+ <Show22 when={discountActive()}>
9608
+ <p class="app-admin-notice" style={{ margin: 0 }}>
9609
+ A recurring discount is still running on this subscription. Saving a new amount replaces it: the customer pays the new amount every period.
9610
+ </p>
9611
+ </Show22>
9612
+ <Show22 when={props.subscription.billingMode === "gateway"}>
9613
+ <p class="app-admin-notice" style={{ margin: 0 }}>
9614
+ This subscription is billed by the payment gateway, which holds the price. The change will be refused until it is moved to platform billing.
9615
+ </p>
9616
+ </Show22>
9617
+ <Show22 when={error()}>
9618
+ <p style={{ margin: 0, "font-size": "0.875rem", color: "var(--app-admin-danger-fg)" }} role="alert">
9619
+ {error()}
9620
+ </p>
9621
+ </Show22>
9622
+ </form>
9623
+ </Modal>;
9624
+ }
9602
9625
 
9603
- <Show22 when={!data.profile.loading} fallback={<LoadingSpinner />}>
9604
- <Show22
9605
- when={data.profile()}
9606
- fallback={<p style={{ color: "var(--app-admin-fg-muted)", "font-size": "0.875rem" }}>
9607
- Could not load this customer's dashboard.
9608
- </p>}
9626
+ // src/pages/admin/customers/modals/EditScheduleModal.tsx
9627
+ import { createSignal as createSignal13, Show as Show23 } from "solid-js";
9628
+ function EditScheduleModal(props) {
9629
+ const [nextCharge, setNextCharge] = createSignal13(isoToDatetimeLocal(props.subscription.nextChargeAt));
9630
+ const [periodStart, setPeriodStart] = createSignal13(isoToDatetimeLocal(props.subscription.currentPeriodStart));
9631
+ const [periodEnd, setPeriodEnd] = createSignal13(isoToDatetimeLocal(props.subscription.currentPeriodEnd));
9632
+ const [saving, setSaving] = createSignal13(false);
9633
+ const [error, setError] = createSignal13(null);
9634
+ const patch = () => {
9635
+ const p = {};
9636
+ const nc = datetimeLocalToIso(nextCharge());
9637
+ if (nc !== (props.subscription.nextChargeAt ?? null) && nextCharge() !== isoToDatetimeLocal(props.subscription.nextChargeAt)) {
9638
+ if (nc) p.nextChargeAt = nc;
9639
+ }
9640
+ const ps = datetimeLocalToIso(periodStart());
9641
+ if (ps && periodStart() !== isoToDatetimeLocal(props.subscription.currentPeriodStart)) p.currentPeriodStart = ps;
9642
+ const pe = datetimeLocalToIso(periodEnd());
9643
+ if (pe && periodEnd() !== isoToDatetimeLocal(props.subscription.currentPeriodEnd)) p.currentPeriodEnd = pe;
9644
+ return p;
9645
+ };
9646
+ const dirty = () => Object.keys(patch()).length > 0;
9647
+ const windowInverted = () => {
9648
+ const s = datetimeLocalToIso(periodStart());
9649
+ const e = datetimeLocalToIso(periodEnd());
9650
+ return !!(s && e && Date.parse(s) >= Date.parse(e));
9651
+ };
9652
+ const submit = async (ev) => {
9653
+ ev.preventDefault();
9654
+ if (!dirty() || windowInverted()) return;
9655
+ setSaving(true);
9656
+ setError(null);
9657
+ try {
9658
+ await props.onSave(patch());
9659
+ props.onClose();
9660
+ } catch (err) {
9661
+ setError(err instanceof Error ? err.message : "Could not change the schedule");
9662
+ } finally {
9663
+ setSaving(false);
9664
+ }
9665
+ };
9666
+ return <Modal
9667
+ title="Change billing schedule"
9668
+ onClose={props.onClose}
9669
+ footer={<>
9670
+ <button type="submit" form="edit-schedule-form" class="app-admin-btn app-admin-btn-primary" disabled={saving() || !dirty() || windowInverted()}>
9671
+ {saving() ? "Saving\u2026" : "Save schedule"}
9672
+ </button>
9673
+ <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={props.onClose} disabled={saving()}>
9674
+ Cancel
9675
+ </button>
9676
+ </>}
9609
9677
  >
9610
- {(profile) => <>
9611
- {
9612
- /* Profile */
9613
- }
9614
- <div>
9615
- <h3 style={panelSectionHeader}>Profile</h3>
9616
- <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
9617
- <p style={{ "font-weight": "600", "font-size": "0.9375rem", margin: 0 }}>
9618
- {[profile().firstName, profile().lastName].filter(Boolean).join(" ") || "Member"}
9619
- </p>
9620
- <p
9621
- style={{
9622
- "font-size": "0.8125rem",
9623
- color: "var(--app-admin-fg-muted)",
9624
- margin: "0.25rem 0 0"
9625
- }}
9678
+ <form id="edit-schedule-form" onSubmit={submit} style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
9679
+ <Show23 when={props.subscription.billingMode === "gateway"}>
9680
+ <p class="app-admin-notice" style={{ margin: 0 }}>
9681
+ This subscription is billed by the payment gateway. The gateway decides when to charge; these dates only change what the admin displays.
9682
+ </p>
9683
+ </Show23>
9684
+ <FormRow
9685
+ label="Next charge"
9686
+ hint={props.subscription.nextChargeAt ? `Currently ${fmtDate(props.subscription.nextChargeAt)}. Moving it later gives the customer more time; moving it earlier charges sooner.` : "No next charge is scheduled. Setting one restarts billing on that date."}
9626
9687
  >
9627
- {profile().email}
9628
- </p>
9629
- </div>
9630
- </div>
9688
+ <input
9689
+ class="app-admin-input"
9690
+ type="datetime-local"
9691
+ value={nextCharge()}
9692
+ onInput={(e) => setNextCharge(e.currentTarget.value)}
9693
+ autofocus
9694
+ />
9695
+ </FormRow>
9696
+ <FormRow label="Current period start">
9697
+ <input class="app-admin-input" type="datetime-local" value={periodStart()} onInput={(e) => setPeriodStart(e.currentTarget.value)} />
9698
+ </FormRow>
9699
+ <FormRow label="Current period end" hint="Shown to the customer as the end of their paid period.">
9700
+ <input class="app-admin-input" type="datetime-local" value={periodEnd()} onInput={(e) => setPeriodEnd(e.currentTarget.value)} />
9701
+ </FormRow>
9702
+ <Show23 when={windowInverted()}>
9703
+ <p style={{ margin: 0, "font-size": "0.875rem", color: "var(--app-admin-danger-fg)" }} role="alert">
9704
+ The period end must be after its start.
9705
+ </p>
9706
+ </Show23>
9707
+ <Show23 when={error()}>
9708
+ <p style={{ margin: 0, "font-size": "0.875rem", color: "var(--app-admin-danger-fg)" }} role="alert">
9709
+ {error()}
9710
+ </p>
9711
+ </Show23>
9712
+ </form>
9713
+ </Modal>;
9714
+ }
9631
9715
 
9632
- {
9633
- /* Subscription */
9634
- }
9635
- <div>
9636
- <h3 style={panelSectionHeader}>Subscription</h3>
9637
- <Show22
9638
- when={data.subscription()}
9639
- fallback={<p
9640
- style={{
9641
- color: "var(--app-admin-fg-muted)",
9642
- "font-size": "0.875rem"
9643
- }}
9644
- >
9645
- No active subscription.
9646
- </p>}
9647
- >
9648
- {(sub) => <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
9649
- <div
9650
- style={{
9651
- display: "flex",
9652
- "align-items": "center",
9653
- "justify-content": "space-between"
9654
- }}
9655
- >
9656
- <span style={{ "font-size": "0.875rem", "font-weight": "500" }}>
9657
- <Show22 when={sub().amount != null} fallback="Subscription">
9658
- {centsToUsd(sub().amount)}/mo
9659
- </Show22>
9660
- </span>
9661
- <StatusBadge status={sub().status} />
9662
- </div>
9663
- <Show22 when={sub().nextBillingDate}>
9664
- <p
9665
- style={{
9666
- "font-size": "0.75rem",
9667
- color: "var(--app-admin-fg-muted)",
9668
- margin: "0.25rem 0 0"
9669
- }}
9670
- >
9671
- Next charge {fmtDate(sub().nextBillingDate)}
9672
- </p>
9673
- </Show22>
9674
- </div>}
9675
- </Show22>
9676
- </div>
9677
-
9678
- {
9679
- /* Prescription status */
9680
- }
9681
- <Show22 when={data.rxStatus()}>
9682
- {(rx) => <div>
9683
- <h3 style={panelSectionHeader}>Prescription status</h3>
9684
- <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
9685
- <div
9686
- style={{
9687
- display: "flex",
9688
- "align-items": "center",
9689
- "justify-content": "space-between"
9690
- }}
9691
- >
9692
- <span style={{ "font-size": "0.875rem", "font-weight": "500" }}>
9693
- Current request
9694
- </span>
9695
- <StatusBadge status={rx().status} />
9696
- </div>
9697
- <Show22 when={rx().reason}>
9698
- <p
9699
- style={{
9700
- "font-size": "0.75rem",
9701
- color: "var(--app-admin-fg-muted)",
9702
- margin: "0.25rem 0 0"
9703
- }}
9704
- >
9705
- {rx().reason}
9706
- </p>
9707
- </Show22>
9708
- </div>
9709
- </div>}
9710
- </Show22>
9711
-
9712
- {
9713
- /* Prescription requests */
9714
- }
9715
- <div>
9716
- <h3 style={panelSectionHeader}>Prescription requests</h3>
9717
- <Show22
9718
- when={(data.rxList() ?? []).length > 0}
9719
- fallback={<p
9720
- style={{
9721
- color: "var(--app-admin-fg-muted)",
9722
- "font-size": "0.875rem"
9723
- }}
9724
- >
9725
- No prescription requests.
9726
- </p>}
9727
- >
9728
- <div style={{ display: "flex", "flex-direction": "column", gap: "0.5rem" }}>
9729
- <For16 each={data.rxList()}>
9730
- {(req) => <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
9731
- <div
9732
- style={{
9733
- display: "flex",
9734
- "align-items": "center",
9735
- "justify-content": "space-between"
9736
- }}
9737
- >
9738
- <div>
9739
- <span
9740
- style={{ "font-size": "0.875rem", "font-weight": "500" }}
9741
- >
9742
- {req.drugName || req.drugId || "Prescription"}
9743
- </span>
9744
- <Show22 when={req.dosage}>
9745
- <span
9746
- style={{
9747
- "font-size": "0.75rem",
9748
- color: "var(--app-admin-fg-muted)",
9749
- "margin-left": "0.5rem"
9750
- }}
9751
- >
9752
- {req.dosage}
9753
- </span>
9754
- </Show22>
9755
- </div>
9756
- <StatusBadge status={req.status} />
9757
- </div>
9758
- <div
9759
- style={{
9760
- "font-size": "0.75rem",
9761
- color: "var(--app-admin-fg-muted)",
9762
- "margin-top": "0.25rem"
9763
- }}
9764
- >
9765
- <Show22 when={req.priceCents != null}>
9766
- <span>{centsToUsd(req.priceCents)} · </span>
9767
- </Show22>
9768
- {fmtDate(req.createdAt)}
9769
- </div>
9770
- </div>}
9771
- </For16>
9772
- </div>
9773
- </Show22>
9774
- </div>
9775
-
9776
- {
9777
- /* Pending surveys */
9778
- }
9779
- <div>
9780
- <h3 style={panelSectionHeader}>Pending surveys</h3>
9781
- <Show22
9782
- when={(data.pendingSurveys() ?? []).length > 0}
9783
- fallback={<p
9784
- style={{
9785
- color: "var(--app-admin-fg-muted)",
9786
- "font-size": "0.875rem"
9787
- }}
9788
- >
9789
- No pending surveys.
9790
- </p>}
9791
- >
9792
- <div style={{ display: "flex", "flex-direction": "column", gap: "0.5rem" }}>
9793
- <For16 each={data.pendingSurveys()}>
9794
- {(survey) => <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
9795
- <span style={{ "font-size": "0.875rem", "font-weight": "500" }}>
9796
- {survey.drugName || survey.drugId || "Renewal survey"}
9797
- </span>
9798
- <span
9799
- style={{
9800
- "font-size": "0.75rem",
9801
- color: "var(--app-admin-fg-muted)",
9802
- "margin-left": "0.5rem"
9803
- }}
9804
- >
9805
- Cycle {survey.cycleNumber}
9806
- </span>
9807
- </div>}
9808
- </For16>
9809
- </div>
9810
- </Show22>
9811
- </div>
9812
- </>}
9813
- </Show22>
9814
- </Show22>
9815
- </div>
9816
- </div>
9817
- </div>;
9818
- }
9819
-
9820
- // src/pages/admin/customers/LifecycleBadge.tsx
9821
- function LifecycleBadge(props) {
9822
- const bucket = () => props.lifecycle?.bucket ?? props.bucket ?? null;
9823
- const label = () => props.lifecycle?.label || (bucket() ? LIFECYCLE_LABEL[bucket()] : "Unknown");
9824
- const tone = () => bucket() ? LIFECYCLE_TONE[bucket()] : "neutral";
9825
- return <span class={`app-admin-badge app-admin-badge--${tone()}`} style={{ "text-transform": "none" }}>
9826
- {label()}
9827
- </span>;
9828
- }
9829
-
9830
- // src/pages/admin/customers/modals/EditAmountModal.tsx
9831
- import { createSignal as createSignal12, Show as Show23 } from "solid-js";
9832
- function EditAmountModal(props) {
9833
- const current2 = () => props.subscription.amountCents ?? 0;
9834
- const [dollars, setDollars] = createSignal12((current2() / 100).toFixed(2));
9835
- const [saving, setSaving] = createSignal12(false);
9836
- const [error, setError] = createSignal12(null);
9716
+ // src/pages/admin/customers/modals/RefundModal.tsx
9717
+ import { createSignal as createSignal14, For as For16, Show as Show24 } from "solid-js";
9718
+ function RefundModal(props) {
9719
+ const remaining = () => Math.max(0, props.payment.amountCents - (props.payment.refundedAmountCents ?? 0));
9720
+ const [dollars, setDollars] = createSignal14((remaining() / 100).toFixed(2));
9721
+ const [reason, setReason] = createSignal14("");
9722
+ const [alsoCancel, setAlsoCancel] = createSignal14(false);
9723
+ const [busy, setBusy] = createSignal14(false);
9724
+ const [error, setError] = createSignal14(null);
9837
9725
  const cents = () => {
9838
9726
  const n = Number(dollars());
9839
- if (!Number.isFinite(n)) return null;
9840
- return Math.round(n * 100);
9727
+ return Number.isFinite(n) ? Math.round(n * 100) : null;
9841
9728
  };
9729
+ const isFull = () => cents() === remaining();
9842
9730
  const valid = () => {
9843
9731
  const c = cents();
9844
- return c !== null && c >= 0 && c !== current2();
9732
+ return c !== null && c > 0 && c <= remaining();
9845
9733
  };
9846
- const discountActive = () => props.subscription.discountRecurringIndefinite || (props.subscription.discountRecurringRemaining ?? 0) > 0;
9847
- const submit = async (e) => {
9848
- e.preventDefault();
9849
- const c = cents();
9850
- if (c === null || !valid()) return;
9851
- setSaving(true);
9734
+ const run = async (req) => {
9735
+ setBusy(true);
9852
9736
  setError(null);
9853
9737
  try {
9854
- await props.onSave(c);
9855
- props.onClose();
9738
+ const out = await props.onRefund(req);
9739
+ if (out.ok) {
9740
+ props.onClose();
9741
+ } else {
9742
+ setError({ message: out.message, code: out.code });
9743
+ }
9856
9744
  } catch (err) {
9857
- setError(err instanceof Error ? err.message : "Could not change the amount");
9745
+ setError({ message: err instanceof Error ? err.message : "Refund failed" });
9858
9746
  } finally {
9859
- setSaving(false);
9747
+ setBusy(false);
9860
9748
  }
9861
9749
  };
9750
+ const submit = (e) => {
9751
+ e.preventDefault();
9752
+ if (!valid()) return;
9753
+ void run({
9754
+ amountCents: isFull() ? void 0 : cents(),
9755
+ reason: reason().trim() || void 0,
9756
+ alsoCancel: alsoCancel() && props.liveSubscriptions.length > 0
9757
+ });
9758
+ };
9862
9759
  return <Modal
9863
- title="Change subscription amount"
9760
+ title={remaining() < props.payment.amountCents ? "Refund the rest of this payment" : "Refund this payment"}
9864
9761
  onClose={props.onClose}
9865
9762
  footer={<>
9866
- <button type="submit" form="edit-amount-form" class="app-admin-btn app-admin-btn-primary" disabled={saving() || !valid()}>
9867
- {saving() ? "Saving\u2026" : "Save new amount"}
9763
+ <button type="submit" form="refund-form" class="app-admin-btn app-admin-btn-primary" disabled={busy() || !valid()}>
9764
+ {busy() ? "Refunding\u2026" : isFull() ? `Refund ${centsToUsd(remaining())}` : `Refund ${centsToUsd(cents() ?? 0)} of ${centsToUsd(remaining())}`}
9868
9765
  </button>
9869
- <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={props.onClose} disabled={saving()}>
9766
+ <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={props.onClose} disabled={busy()}>
9870
9767
  Cancel
9871
9768
  </button>
9872
9769
  </>}
9873
9770
  >
9874
- <form id="edit-amount-form" onSubmit={submit} style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
9771
+ <form id="refund-form" onSubmit={submit} style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
9875
9772
  <p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>
9876
- {props.subscription.medication || "Subscription"} currently charges {centsToUsd(current2())} every{" "}
9877
- {props.subscription.intervalDays ?? 30} days. The new amount applies to the next charge and every charge after it.
9773
+ {centsToUsd(props.payment.amountCents)} paid{props.payment.createdAt ? ` on ${fmtDate(props.payment.createdAt)}` : ""}
9774
+ {props.payment.customerEmail ? ` by ${props.payment.customerEmail}` : ""}.
9775
+ <Show24 when={(props.payment.refundedAmountCents ?? 0) > 0}>
9776
+ {" "}
9777
+ {centsToUsd(props.payment.refundedAmountCents)} already refunded; {centsToUsd(remaining())} remains.
9778
+ </Show24>
9878
9779
  </p>
9879
- <FormRow label="New amount (USD)">
9780
+
9781
+ <FormRow label="Amount to refund (USD)" hint={`Up to ${centsToUsd(remaining())}.`}>
9880
9782
  <input
9881
9783
  class="app-admin-input"
9882
9784
  type="number"
9883
9785
  inputmode="decimal"
9884
- min="0"
9885
- step="0.01"
9886
- value={dollars()}
9887
- onInput={(e) => setDollars(e.currentTarget.value)}
9888
- autofocus
9889
- />
9890
- </FormRow>
9891
- <Show23 when={discountActive()}>
9892
- <p class="app-admin-notice" style={{ margin: 0 }}>
9893
- A recurring discount is still running on this subscription. Saving a new amount replaces it: the customer pays the new amount every period.
9894
- </p>
9895
- </Show23>
9896
- <Show23 when={props.subscription.billingMode === "gateway"}>
9897
- <p class="app-admin-notice" style={{ margin: 0 }}>
9898
- This subscription is billed by the payment gateway, which holds the price. The change will be refused until it is moved to platform billing.
9899
- </p>
9900
- </Show23>
9901
- <Show23 when={error()}>
9902
- <p style={{ margin: 0, "font-size": "0.875rem", color: "var(--app-admin-danger-fg)" }} role="alert">
9903
- {error()}
9904
- </p>
9905
- </Show23>
9906
- </form>
9907
- </Modal>;
9908
- }
9909
-
9910
- // src/pages/admin/customers/modals/EditScheduleModal.tsx
9911
- import { createSignal as createSignal13, Show as Show24 } from "solid-js";
9912
- function EditScheduleModal(props) {
9913
- const [nextCharge, setNextCharge] = createSignal13(isoToDatetimeLocal(props.subscription.nextChargeAt));
9914
- const [periodStart, setPeriodStart] = createSignal13(isoToDatetimeLocal(props.subscription.currentPeriodStart));
9915
- const [periodEnd, setPeriodEnd] = createSignal13(isoToDatetimeLocal(props.subscription.currentPeriodEnd));
9916
- const [saving, setSaving] = createSignal13(false);
9917
- const [error, setError] = createSignal13(null);
9918
- const patch = () => {
9919
- const p = {};
9920
- const nc = datetimeLocalToIso(nextCharge());
9921
- if (nc !== (props.subscription.nextChargeAt ?? null) && nextCharge() !== isoToDatetimeLocal(props.subscription.nextChargeAt)) {
9922
- if (nc) p.nextChargeAt = nc;
9923
- }
9924
- const ps = datetimeLocalToIso(periodStart());
9925
- if (ps && periodStart() !== isoToDatetimeLocal(props.subscription.currentPeriodStart)) p.currentPeriodStart = ps;
9926
- const pe = datetimeLocalToIso(periodEnd());
9927
- if (pe && periodEnd() !== isoToDatetimeLocal(props.subscription.currentPeriodEnd)) p.currentPeriodEnd = pe;
9928
- return p;
9929
- };
9930
- const dirty = () => Object.keys(patch()).length > 0;
9931
- const windowInverted = () => {
9932
- const s = datetimeLocalToIso(periodStart());
9933
- const e = datetimeLocalToIso(periodEnd());
9934
- return !!(s && e && Date.parse(s) >= Date.parse(e));
9935
- };
9936
- const submit = async (ev) => {
9937
- ev.preventDefault();
9938
- if (!dirty() || windowInverted()) return;
9939
- setSaving(true);
9940
- setError(null);
9941
- try {
9942
- await props.onSave(patch());
9943
- props.onClose();
9944
- } catch (err) {
9945
- setError(err instanceof Error ? err.message : "Could not change the schedule");
9946
- } finally {
9947
- setSaving(false);
9948
- }
9949
- };
9950
- return <Modal
9951
- title="Change billing schedule"
9952
- onClose={props.onClose}
9953
- footer={<>
9954
- <button type="submit" form="edit-schedule-form" class="app-admin-btn app-admin-btn-primary" disabled={saving() || !dirty() || windowInverted()}>
9955
- {saving() ? "Saving\u2026" : "Save schedule"}
9956
- </button>
9957
- <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={props.onClose} disabled={saving()}>
9958
- Cancel
9959
- </button>
9960
- </>}
9961
- >
9962
- <form id="edit-schedule-form" onSubmit={submit} style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
9963
- <Show24 when={props.subscription.billingMode === "gateway"}>
9964
- <p class="app-admin-notice" style={{ margin: 0 }}>
9965
- This subscription is billed by the payment gateway. The gateway decides when to charge; these dates only change what the admin displays.
9966
- </p>
9967
- </Show24>
9968
- <FormRow
9969
- label="Next charge"
9970
- hint={props.subscription.nextChargeAt ? `Currently ${fmtDate(props.subscription.nextChargeAt)}. Moving it later gives the customer more time; moving it earlier charges sooner.` : "No next charge is scheduled. Setting one restarts billing on that date."}
9971
- >
9972
- <input
9973
- class="app-admin-input"
9974
- type="datetime-local"
9975
- value={nextCharge()}
9976
- onInput={(e) => setNextCharge(e.currentTarget.value)}
9977
- autofocus
9978
- />
9979
- </FormRow>
9980
- <FormRow label="Current period start">
9981
- <input class="app-admin-input" type="datetime-local" value={periodStart()} onInput={(e) => setPeriodStart(e.currentTarget.value)} />
9982
- </FormRow>
9983
- <FormRow label="Current period end" hint="Shown to the customer as the end of their paid period.">
9984
- <input class="app-admin-input" type="datetime-local" value={periodEnd()} onInput={(e) => setPeriodEnd(e.currentTarget.value)} />
9985
- </FormRow>
9986
- <Show24 when={windowInverted()}>
9987
- <p style={{ margin: 0, "font-size": "0.875rem", color: "var(--app-admin-danger-fg)" }} role="alert">
9988
- The period end must be after its start.
9989
- </p>
9990
- </Show24>
9991
- <Show24 when={error()}>
9992
- <p style={{ margin: 0, "font-size": "0.875rem", color: "var(--app-admin-danger-fg)" }} role="alert">
9993
- {error()}
9994
- </p>
9995
- </Show24>
9996
- </form>
9997
- </Modal>;
9998
- }
9999
-
10000
- // src/pages/admin/customers/modals/RefundModal.tsx
10001
- import { createSignal as createSignal14, For as For17, Show as Show25 } from "solid-js";
10002
- function RefundModal(props) {
10003
- const remaining = () => Math.max(0, props.payment.amountCents - (props.payment.refundedAmountCents ?? 0));
10004
- const [dollars, setDollars] = createSignal14((remaining() / 100).toFixed(2));
10005
- const [reason, setReason] = createSignal14("");
10006
- const [alsoCancel, setAlsoCancel] = createSignal14(false);
10007
- const [busy, setBusy] = createSignal14(false);
10008
- const [error, setError] = createSignal14(null);
10009
- const cents = () => {
10010
- const n = Number(dollars());
10011
- return Number.isFinite(n) ? Math.round(n * 100) : null;
10012
- };
10013
- const isFull = () => cents() === remaining();
10014
- const valid = () => {
10015
- const c = cents();
10016
- return c !== null && c > 0 && c <= remaining();
10017
- };
10018
- const run = async (req) => {
10019
- setBusy(true);
10020
- setError(null);
10021
- try {
10022
- const out = await props.onRefund(req);
10023
- if (out.ok) {
10024
- props.onClose();
10025
- } else {
10026
- setError({ message: out.message, code: out.code });
10027
- }
10028
- } catch (err) {
10029
- setError({ message: err instanceof Error ? err.message : "Refund failed" });
10030
- } finally {
10031
- setBusy(false);
10032
- }
10033
- };
10034
- const submit = (e) => {
10035
- e.preventDefault();
10036
- if (!valid()) return;
10037
- void run({
10038
- amountCents: isFull() ? void 0 : cents(),
10039
- reason: reason().trim() || void 0,
10040
- alsoCancel: alsoCancel() && props.liveSubscriptions.length > 0
10041
- });
10042
- };
10043
- return <Modal
10044
- title={remaining() < props.payment.amountCents ? "Refund the rest of this payment" : "Refund this payment"}
10045
- onClose={props.onClose}
10046
- footer={<>
10047
- <button type="submit" form="refund-form" class="app-admin-btn app-admin-btn-primary" disabled={busy() || !valid()}>
10048
- {busy() ? "Refunding\u2026" : isFull() ? `Refund ${centsToUsd(remaining())}` : `Refund ${centsToUsd(cents() ?? 0)} of ${centsToUsd(remaining())}`}
10049
- </button>
10050
- <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={props.onClose} disabled={busy()}>
10051
- Cancel
10052
- </button>
10053
- </>}
10054
- >
10055
- <form id="refund-form" onSubmit={submit} style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
10056
- <p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>
10057
- {centsToUsd(props.payment.amountCents)} paid{props.payment.createdAt ? ` on ${fmtDate(props.payment.createdAt)}` : ""}
10058
- {props.payment.customerEmail ? ` by ${props.payment.customerEmail}` : ""}.
10059
- <Show25 when={(props.payment.refundedAmountCents ?? 0) > 0}>
10060
- {" "}
10061
- {centsToUsd(props.payment.refundedAmountCents)} already refunded; {centsToUsd(remaining())} remains.
10062
- </Show25>
10063
- </p>
10064
-
10065
- <FormRow label="Amount to refund (USD)" hint={`Up to ${centsToUsd(remaining())}.`}>
10066
- <input
10067
- class="app-admin-input"
10068
- type="number"
10069
- inputmode="decimal"
10070
- min="0.01"
10071
- max={(remaining() / 100).toFixed(2)}
9786
+ min="0.01"
9787
+ max={(remaining() / 100).toFixed(2)}
10072
9788
  step="0.01"
10073
9789
  value={dollars()}
10074
9790
  onInput={(e) => setDollars(e.currentTarget.value)}
@@ -10079,31 +9795,31 @@ function RefundModal(props) {
10079
9795
  <input class="app-admin-input" type="text" value={reason()} onInput={(e) => setReason(e.currentTarget.value)} placeholder="e.g. duplicate charge" />
10080
9796
  </FormRow>
10081
9797
 
10082
- <Show25 when={props.liveSubscriptions.length > 0}>
9798
+ <Show24 when={props.liveSubscriptions.length > 0}>
10083
9799
  <div class="app-admin-alert app-admin-alert--warning" style={{ "flex-direction": "column", gap: "0.5rem" }}>
10084
9800
  <p class="app-admin-alert__title">
10085
9801
  This customer still has {props.liveSubscriptions.length === 1 ? "a live subscription" : `${props.liveSubscriptions.length} live subscriptions`}. A refund does not stop billing.
10086
9802
  </p>
10087
9803
  <ul style={{ margin: 0, "padding-left": "1.25rem", "font-size": "0.8125rem", color: "var(--app-admin-fg-muted)" }}>
10088
- <For17 each={props.liveSubscriptions}>
9804
+ <For16 each={props.liveSubscriptions}>
10089
9805
  {(s) => <li>
10090
- {s.medication || "Subscription"} — {centsToUsd(s.amountCents)}
9806
+ {subscriptionLabel(s)} — {centsToUsd(s.amountCents)}
10091
9807
  {s.intervalDays ? ` every ${s.intervalDays} days` : ""}
10092
9808
  {s.nextChargeAt ? `, next charge ${fmtDate(s.nextChargeAt)}` : s.currentPeriodEnd ? `, period ends ${fmtDate(s.currentPeriodEnd)}` : ""}
10093
9809
  </li>}
10094
- </For17>
9810
+ </For16>
10095
9811
  </ul>
10096
9812
  <label style={{ display: "flex", "align-items": "center", gap: "0.5rem", "font-size": "0.875rem" }}>
10097
9813
  <input type="checkbox" checked={alsoCancel()} onChange={(e) => setAlsoCancel(e.currentTarget.checked)} />
10098
9814
  Also cancel {props.liveSubscriptions.length === 1 ? "the subscription" : "these subscriptions"} so they are not billed again
10099
9815
  </label>
10100
9816
  </div>
10101
- </Show25>
9817
+ </Show24>
10102
9818
 
10103
- <Show25 when={error()}>
9819
+ <Show24 when={error()}>
10104
9820
  {(err) => <div class="app-admin-alert app-admin-alert--danger" role="alert" style={{ "flex-direction": "column", gap: "0.5rem" }}>
10105
9821
  <p class="app-admin-alert__title">{err().message}</p>
10106
- <Show25 when={err().code === "unsettled_requires_void" && !isFull()}>
9822
+ <Show24 when={err().code === "unsettled_requires_void" && !isFull()}>
10107
9823
  <div>
10108
9824
  <p class="app-admin-alert__detail" style={{ "margin-bottom": "0.5rem" }}>
10109
9825
  The gateway has not settled this charge yet, so it can only be reversed in full right now. Partial refunds work once it settles, usually the next business day.
@@ -10121,72 +9837,72 @@ function RefundModal(props) {
10121
9837
  Refund the full {centsToUsd(remaining())} instead
10122
9838
  </button>
10123
9839
  </div>
10124
- </Show25>
9840
+ </Show24>
10125
9841
  </div>}
10126
- </Show25>
9842
+ </Show24>
10127
9843
  </form>
10128
9844
  </Modal>;
10129
9845
  }
10130
9846
 
10131
9847
  // src/pages/admin/customers/sections/FunnelActivity.tsx
10132
- import { For as For18, Show as Show26 } from "solid-js";
9848
+ import { For as For17, Show as Show25 } from "solid-js";
10133
9849
  function FunnelActivity(props) {
10134
9850
  const f = () => props.funnel;
10135
9851
  const nothing = () => f().captures.length === 0 && f().sessions.length === 0 && f().carts.length === 0;
10136
9852
  return <div class="app-admin-section-stack">
10137
9853
  <Block title="Intake survey">
10138
- <Show26 when={f().captures.length > 0} fallback={<Muted>No completed intake survey on record.</Muted>}>
9854
+ <Show25 when={f().captures.length > 0} fallback={<Muted>No completed intake survey on record.</Muted>}>
10139
9855
  <ul style={{ margin: 0, "padding-left": "1.1rem", "font-size": "0.8125rem" }}>
10140
- <For18 each={f().captures}>
9856
+ <For17 each={f().captures}>
10141
9857
  {(c) => <li>
10142
9858
  Completed {fmtDate(c.capturedAt)} · {c.qualified ? "qualified" : "did not qualify"}
10143
- <Show26 when={c.convertedAt}>{` \xB7 converted ${fmtDate(c.convertedAt)}`}</Show26>
10144
- <Show26 when={c.remindersSent > 0}>{` \xB7 ${c.remindersSent} reminder${c.remindersSent === 1 ? "" : "s"} sent`}</Show26>
9859
+ <Show25 when={c.convertedAt}>{` \xB7 converted ${fmtDate(c.convertedAt)}`}</Show25>
9860
+ <Show25 when={c.remindersSent > 0}>{` \xB7 ${c.remindersSent} reminder${c.remindersSent === 1 ? "" : "s"} sent`}</Show25>
10145
9861
  </li>}
10146
- </For18>
9862
+ </For17>
10147
9863
  </ul>
10148
- </Show26>
9864
+ </Show25>
10149
9865
  </Block>
10150
9866
 
10151
9867
  <Block title="Survey sessions">
10152
- <Show26 when={f().telemetryEnabled} fallback={<Muted>Step-by-step survey tracking is not collected on this site.</Muted>}>
10153
- <Show26 when={f().sessions.length > 0} fallback={<Muted>No survey sessions recorded.</Muted>}>
9868
+ <Show25 when={f().telemetryEnabled} fallback={<Muted>Step-by-step survey tracking is not collected on this site.</Muted>}>
9869
+ <Show25 when={f().sessions.length > 0} fallback={<Muted>No survey sessions recorded.</Muted>}>
10154
9870
  <ul style={{ margin: 0, "padding-left": "1.1rem", "font-size": "0.8125rem" }}>
10155
- <For18 each={f().sessions}>
9871
+ <For17 each={f().sessions}>
10156
9872
  {(s) => <li>
10157
9873
  Started {fmtDate(s.startedAt)}
10158
- <Show26 when={s.lastStep != null && s.stepCount}>{` \xB7 reached step ${s.lastStep} of ${s.stepCount}`}</Show26>
10159
- <Show26 when={s.phase}>{` \xB7 ${s.phase}`}</Show26>
10160
- <Show26 when={s.convertedAt}>{` \xB7 completed ${fmtDate(s.convertedAt)}`}</Show26>
10161
- <Show26 when={!s.convertedAt}>{` \xB7 last seen ${fmtDate(s.lastSeenAt)}`}</Show26>
9874
+ <Show25 when={s.lastStep != null && s.stepCount}>{` \xB7 reached step ${s.lastStep} of ${s.stepCount}`}</Show25>
9875
+ <Show25 when={s.phase}>{` \xB7 ${s.phase}`}</Show25>
9876
+ <Show25 when={s.convertedAt}>{` \xB7 completed ${fmtDate(s.convertedAt)}`}</Show25>
9877
+ <Show25 when={!s.convertedAt}>{` \xB7 last seen ${fmtDate(s.lastSeenAt)}`}</Show25>
10162
9878
  </li>}
10163
- </For18>
9879
+ </For17>
10164
9880
  </ul>
10165
- </Show26>
10166
- </Show26>
9881
+ </Show25>
9882
+ </Show25>
10167
9883
  </Block>
10168
9884
 
10169
9885
  <Block title="Carts">
10170
- <Show26 when={f().cartRecoveryEnabled} fallback={<Muted>Cart recovery is not collected on this site.</Muted>}>
10171
- <Show26 when={f().carts.length > 0} fallback={<Muted>No carts recorded in the last 30 days.</Muted>}>
9886
+ <Show25 when={f().cartRecoveryEnabled} fallback={<Muted>Cart recovery is not collected on this site.</Muted>}>
9887
+ <Show25 when={f().carts.length > 0} fallback={<Muted>No carts recorded in the last 30 days.</Muted>}>
10172
9888
  <ul style={{ margin: 0, "padding-left": "1.1rem", "font-size": "0.8125rem" }}>
10173
- <For18 each={f().carts}>
9889
+ <For17 each={f().carts}>
10174
9890
  {(c) => <li>
10175
9891
  {c.itemCount} item{c.itemCount === 1 ? "" : "s"} · {centsToUsd(c.subtotalCents)}
10176
9892
  {c.promoCode ? ` \xB7 code ${c.promoCode}` : ""}
10177
9893
  {c.convertedAt ? ` \xB7 checked out ${fmtDate(c.convertedAt)}` : ` \xB7 open, last touched ${fmtDate(c.updatedAt)}`}
10178
9894
  </li>}
10179
- </For18>
9895
+ </For17>
10180
9896
  </ul>
10181
- </Show26>
10182
- </Show26>
9897
+ </Show25>
9898
+ </Show25>
10183
9899
  </Block>
10184
9900
 
10185
- <Show26 when={nothing() && !f().telemetryEnabled && !f().cartRecoveryEnabled}>
9901
+ <Show25 when={nothing() && !f().telemetryEnabled && !f().cartRecoveryEnabled}>
10186
9902
  <Muted>
10187
9903
  Only completed surveys are recorded for this site. Turning on funnel telemetry would show which survey step people stop at.
10188
9904
  </Muted>
10189
- </Show26>
9905
+ </Show25>
10190
9906
  </div>;
10191
9907
  }
10192
9908
  function Block(props) {
@@ -10202,7 +9918,7 @@ function Muted(props) {
10202
9918
  }
10203
9919
 
10204
9920
  // src/pages/admin/customers/sections/PaymentsTable.tsx
10205
- import { For as For19, Show as Show27 } from "solid-js";
9921
+ import { For as For18, Show as Show26 } from "solid-js";
10206
9922
  function typeWord(p) {
10207
9923
  if (p.detached) return "checkout (declined)";
10208
9924
  if (!p.type) return p.orderId ? "order" : p.subscriptionId ? "subscription" : "\u2014";
@@ -10211,7 +9927,7 @@ function typeWord(p) {
10211
9927
  function PaymentsTable(props) {
10212
9928
  const sorted = () => [...props.payments].sort((a, b) => Date.parse(b.createdAt ?? "") - Date.parse(a.createdAt ?? ""));
10213
9929
  const refundable = (p) => p.status === "succeeded" && (p.amountCents ?? 0) - (p.refundedAmountCents ?? 0) > 0;
10214
- return <Show27 when={props.payments.length > 0} fallback={<EmptyState message="No payments yet." />}>
9930
+ return <Show26 when={props.payments.length > 0} fallback={<EmptyState message="No payments yet." />}>
10215
9931
  <div class="app-admin-table-wrap">
10216
9932
  <table class="app-admin-table">
10217
9933
  <thead>
@@ -10225,32 +9941,32 @@ function PaymentsTable(props) {
10225
9941
  </tr>
10226
9942
  </thead>
10227
9943
  <tbody>
10228
- <For19 each={sorted()}>
9944
+ <For18 each={sorted()}>
10229
9945
  {(p) => <tr id={`pay-${p.id}`}>
10230
9946
  <td data-label="Date" class="app-admin-text-muted">{fmtDate(p.createdAt)}</td>
10231
9947
  <td data-label="Amount">
10232
9948
  {centsToUsd(p.amountCents)}
10233
- <Show27 when={(p.refundedAmountCents ?? 0) > 0 && p.status !== "refunded"}>
9949
+ <Show26 when={(p.refundedAmountCents ?? 0) > 0 && p.status !== "refunded"}>
10234
9950
  <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{centsToUsd(p.refundedAmountCents)} refunded</div>
10235
- </Show27>
9951
+ </Show26>
10236
9952
  </td>
10237
9953
  <td data-label="Status">
10238
9954
  <StatusBadge status={p.status} />
10239
9955
  </td>
10240
9956
  <td data-label="Type" class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>{typeWord(p)}</td>
10241
9957
  <td data-label="Detail" class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>
10242
- <Show27 when={p.failureReason}>
9958
+ <Show26 when={p.failureReason}>
10243
9959
  <div>{p.failureReason}</div>
10244
- </Show27>
10245
- <Show27 when={p.transactionId}>
9960
+ </Show26>
9961
+ <Show26 when={p.transactionId}>
10246
9962
  <div class="app-admin-text-mono" style={{ "font-size": "0.75rem" }}>{p.transactionId}</div>
10247
- </Show27>
10248
- <Show27 when={p.refundedAt && p.status === "refunded"}>
9963
+ </Show26>
9964
+ <Show26 when={p.refundedAt && p.status === "refunded"}>
10249
9965
  <div>Refunded {fmtDate(p.refundedAt)}</div>
10250
- </Show27>
9966
+ </Show26>
10251
9967
  </td>
10252
9968
  <td data-label="Actions">
10253
- <Show27 when={refundable(p)}>
9969
+ <Show26 when={refundable(p)}>
10254
9970
  <button
10255
9971
  type="button"
10256
9972
  class="app-admin-btn app-admin-btn-warning"
@@ -10259,18 +9975,18 @@ function PaymentsTable(props) {
10259
9975
  >
10260
9976
  {props.busyId === p.id ? "\u2026" : (p.refundedAmountCents ?? 0) > 0 ? "Refund rest" : "Refund"}
10261
9977
  </button>
10262
- </Show27>
9978
+ </Show26>
10263
9979
  </td>
10264
9980
  </tr>}
10265
- </For19>
9981
+ </For18>
10266
9982
  </tbody>
10267
9983
  </table>
10268
9984
  </div>
10269
- </Show27>;
9985
+ </Show26>;
10270
9986
  }
10271
9987
 
10272
9988
  // src/pages/admin/customers/sections/ProfileCard.tsx
10273
- import { Show as Show28, createSignal as createSignal15 } from "solid-js";
9989
+ import { Show as Show27, createSignal as createSignal15 } from "solid-js";
10274
9990
  function ProfileCard(props) {
10275
9991
  const c = () => props.customer;
10276
9992
  const [editing, setEditing] = createSignal15(false);
@@ -10300,7 +10016,7 @@ function ProfileCard(props) {
10300
10016
  return lines.length ? lines.join(" \xB7 ") : null;
10301
10017
  };
10302
10018
  return <div class="app-admin-section-stack">
10303
- <Show28
10019
+ <Show27
10304
10020
  when={editing()}
10305
10021
  fallback={<div style={{ display: "flex", "align-items": "center", "justify-content": "space-between", gap: "0.5rem" }}>
10306
10022
  <span style={{ "font-size": "0.875rem" }}>
@@ -10327,7 +10043,7 @@ function ProfileCard(props) {
10327
10043
  </button>
10328
10044
  </div>
10329
10045
  </form>
10330
- </Show28>
10046
+ </Show27>
10331
10047
 
10332
10048
  <KeyValueList
10333
10049
  items={[
@@ -10345,7 +10061,7 @@ function ProfileCard(props) {
10345
10061
  }
10346
10062
 
10347
10063
  // src/pages/admin/customers/sections/RequestCard.tsx
10348
- import { Show as Show29 } from "solid-js";
10064
+ import { Show as Show28 } from "solid-js";
10349
10065
  var STAGE_TO_STEP = {
10350
10066
  done: "done",
10351
10067
  active: "active",
@@ -10385,15 +10101,15 @@ function RequestCard(props) {
10385
10101
  <div style={{ display: "flex", "flex-wrap": "wrap", "align-items": "center", "justify-content": "space-between", gap: "0.5rem 0.75rem" }}>
10386
10102
  <div style={{ display: "flex", "align-items": "center", gap: "0.5rem", "flex-wrap": "wrap", "min-width": 0 }}>
10387
10103
  <span style={{ "font-weight": "600" }}>{r().drugName || "Prescription request"}</span>
10388
- <Show29 when={r().dosage}>
10104
+ <Show28 when={r().dosage}>
10389
10105
  <span class="app-admin-text-muted" style={{ "font-size": "0.875rem" }}>{r().dosage}</span>
10390
- </Show29>
10106
+ </Show28>
10391
10107
  <StatusBadge status={r().status} />
10392
- <Show29 when={!r().live}>
10108
+ <Show28 when={!r().live}>
10393
10109
  <span class="app-admin-badge app-admin-badge--neutral" title="Apex could not be reached; showing the last status we stored.">
10394
10110
  cached
10395
10111
  </span>
10396
- </Show29>
10112
+ </Show28>
10397
10113
  </div>
10398
10114
  <span class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>
10399
10115
  {STATUS_WORD[r().status] ?? r().status.replace(/_/g, " ")} · submitted {fmtDate(r().createdAt)}
@@ -10411,14 +10127,14 @@ function RequestCard(props) {
10411
10127
  label: "Tracking",
10412
10128
  value: tracking() ? <span>
10413
10129
  {carrier() ? `${carrier()} ` : ""}
10414
- <Show29 when={trackingUrl()} fallback={<span class="app-admin-text-mono">{tracking()}</span>}>
10130
+ <Show28 when={trackingUrl()} fallback={<span class="app-admin-text-mono">{tracking()}</span>}>
10415
10131
  <a href={trackingUrl()} target="_blank" rel="noopener noreferrer" class="app-admin-text-mono" style={{ color: "var(--app-admin-primary-soft-fg)" }}>
10416
10132
  {tracking()}
10417
10133
  </a>
10418
- </Show29>
10419
- <Show29 when={deliveryStatus()}>
10134
+ </Show28>
10135
+ <Show28 when={deliveryStatus()}>
10420
10136
  <span class="app-admin-text-muted">{` \xB7 ${deliveryStatus().replace(/_/g, " ")}`}</span>
10421
- </Show29>
10137
+ </Show28>
10422
10138
  </span> : null
10423
10139
  },
10424
10140
  { label: "Shipped", value: r().tracking?.shippedAt ? fmtDate(r().tracking.shippedAt) : null },
@@ -10443,7 +10159,7 @@ function RequestCard(props) {
10443
10159
  }
10444
10160
 
10445
10161
  // src/pages/admin/customers/sections/SubscriptionCard.tsx
10446
- import { For as For20, Show as Show30, createSignal as createSignal16 } from "solid-js";
10162
+ import { For as For19, Show as Show29, createSignal as createSignal16 } from "solid-js";
10447
10163
  function attemptTone(status) {
10448
10164
  if (status === "succeeded") return "success";
10449
10165
  if (status === "failed") return "danger";
@@ -10468,23 +10184,23 @@ function SubscriptionCard(props) {
10468
10184
  <div style={{ display: "flex", "flex-wrap": "wrap", "align-items": "flex-start", "justify-content": "space-between", gap: "0.75rem" }}>
10469
10185
  <div style={{ "min-width": 0 }}>
10470
10186
  <div style={{ display: "flex", "align-items": "center", gap: "0.5rem", "flex-wrap": "wrap" }}>
10471
- <span style={{ "font-weight": "600" }}>{s().medication || "Subscription"}</span>
10472
- <Show30 when={s().dosage}>
10187
+ <span style={{ "font-weight": "600" }}>{subscriptionLabel(s())}</span>
10188
+ <Show29 when={s().dosage}>
10473
10189
  <span class="app-admin-text-muted" style={{ "font-size": "0.875rem" }}>{s().dosage}</span>
10474
- </Show30>
10190
+ </Show29>
10475
10191
  <StatusBadge status={s().status} />
10476
10192
  </div>
10477
10193
  <div class="app-admin-text-muted" style={{ "font-size": "0.875rem", "margin-top": "0.25rem" }}>
10478
10194
  {centsToUsd(s().amountCents)} every {s().intervalDays ?? 30} days
10479
- <Show30 when={s().baseAmountCents != null && s().baseAmountCents !== s().amountCents}>
10195
+ <Show29 when={s().baseAmountCents != null && s().baseAmountCents !== s().amountCents}>
10480
10196
  {` (then ${centsToUsd(s().baseAmountCents)})`}
10481
- </Show30>
10197
+ </Show29>
10482
10198
  {" \xB7 "}
10483
10199
  {gateway() ? "billed by the gateway" : "billed by the platform"}
10484
10200
  </div>
10485
10201
  </div>
10486
10202
  <div style={{ display: "flex", "flex-wrap": "wrap", gap: "0.375rem" }}>
10487
- <Show30 when={live()}>
10203
+ <Show29 when={live()}>
10488
10204
  <button
10489
10205
  type="button"
10490
10206
  class="app-admin-btn app-admin-btn-ghost app-admin-btn-sm"
@@ -10497,22 +10213,22 @@ function SubscriptionCard(props) {
10497
10213
  <button type="button" class="app-admin-btn app-admin-btn-ghost app-admin-btn-sm" onClick={() => props.onEditSchedule(s())}>
10498
10214
  Change schedule
10499
10215
  </button>
10500
- </Show30>
10501
- <Show30 when={s().status === "active"}>
10216
+ </Show29>
10217
+ <Show29 when={s().status === "active"}>
10502
10218
  <button type="button" class="app-admin-btn app-admin-btn-ghost app-admin-btn-sm" onClick={() => props.onPause(s())} disabled={busy("pause")}>
10503
10219
  {busy("pause") ? "Pausing\u2026" : "Pause"}
10504
10220
  </button>
10505
- </Show30>
10506
- <Show30 when={s().status === "paused"}>
10221
+ </Show29>
10222
+ <Show29 when={s().status === "paused"}>
10507
10223
  <button type="button" class="app-admin-btn app-admin-btn-primary app-admin-btn-sm" onClick={() => props.onResume(s())} disabled={busy("resume")}>
10508
10224
  {busy("resume") ? "Resuming\u2026" : "Resume"}
10509
10225
  </button>
10510
- </Show30>
10511
- <Show30 when={live()}>
10226
+ </Show29>
10227
+ <Show29 when={live()}>
10512
10228
  <button type="button" class="app-admin-btn app-admin-btn-danger" onClick={() => props.onCancel(s())} disabled={busy("cancel")}>
10513
10229
  {busy("cancel") ? "\u2026" : "Cancel"}
10514
10230
  </button>
10515
- </Show30>
10231
+ </Show29>
10516
10232
  </div>
10517
10233
  </div>
10518
10234
 
@@ -10537,12 +10253,12 @@ function SubscriptionCard(props) {
10537
10253
  />
10538
10254
  </div>
10539
10255
 
10540
- <Show30 when={attempts().length > 0}>
10256
+ <Show29 when={attempts().length > 0}>
10541
10257
  <div style={{ "margin-top": "0.875rem" }}>
10542
10258
  <button type="button" class="app-admin-link-btn" onClick={() => setShowAttempts((v) => !v)} aria-expanded={showAttempts()}>
10543
10259
  {showAttempts() ? "Hide" : "Show"} billing attempts ({attempts().length})
10544
10260
  </button>
10545
- <Show30 when={showAttempts()}>
10261
+ <Show29 when={showAttempts()}>
10546
10262
  <div class="app-admin-table-wrap" style={{ "margin-top": "0.5rem" }}>
10547
10263
  <table class="app-admin-table" style={{ "font-size": "0.8125rem" }}>
10548
10264
  <thead>
@@ -10556,12 +10272,12 @@ function SubscriptionCard(props) {
10556
10272
  </tr>
10557
10273
  </thead>
10558
10274
  <tbody>
10559
- <For20 each={attempts()}>
10275
+ <For19 each={attempts()}>
10560
10276
  {(a) => <tr>
10561
10277
  <td data-label="When" class="app-admin-text-muted">{fmtDate(a.createdAt)}</td>
10562
10278
  <td data-label="Period" class="app-admin-text-muted">
10563
10279
  {(a.billingPeriod ?? 0) + 1}
10564
- <Show30 when={(a.attemptNo ?? 1) > 1}>{` (try ${a.attemptNo})`}</Show30>
10280
+ <Show29 when={(a.attemptNo ?? 1) > 1}>{` (try ${a.attemptNo})`}</Show29>
10565
10281
  </td>
10566
10282
  <td data-label="Amount">{centsToUsd(a.amountCents)}</td>
10567
10283
  <td data-label="Outcome">
@@ -10571,7 +10287,7 @@ function SubscriptionCard(props) {
10571
10287
  {a.errorMessage ?? a.errorCode ?? "\u2014"}
10572
10288
  </td>
10573
10289
  <td data-label="" class="app-admin-table-cell--no-label">
10574
- <Show30 when={a.status === "pending" || a.status === "indeterminate"}>
10290
+ <Show29 when={a.status === "pending" || a.status === "indeterminate"}>
10575
10291
  <button
10576
10292
  type="button"
10577
10293
  class="app-admin-btn app-admin-btn-warning"
@@ -10580,21 +10296,21 @@ function SubscriptionCard(props) {
10580
10296
  >
10581
10297
  Resolve
10582
10298
  </button>
10583
- </Show30>
10299
+ </Show29>
10584
10300
  </td>
10585
10301
  </tr>}
10586
- </For20>
10302
+ </For19>
10587
10303
  </tbody>
10588
10304
  </table>
10589
10305
  </div>
10590
- </Show30>
10306
+ </Show29>
10591
10307
  </div>
10592
- </Show30>
10308
+ </Show29>
10593
10309
  </article>;
10594
10310
  }
10595
10311
 
10596
10312
  // src/pages/admin/customers/sections/SupportSummary.tsx
10597
- import { For as For21, Show as Show31 } from "solid-js";
10313
+ import { For as For20, Show as Show30 } from "solid-js";
10598
10314
  var STATUS_WORD2 = {
10599
10315
  open: "needs reply",
10600
10316
  pending: "awaiting customer",
@@ -10602,14 +10318,14 @@ var STATUS_WORD2 = {
10602
10318
  };
10603
10319
  function SupportSummary(props) {
10604
10320
  const s = () => props.support;
10605
- return <Show31 when={s().threadCount > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.8125rem" }}>No support conversations.</p>}>
10321
+ return <Show30 when={s().threadCount > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.8125rem" }}>No support conversations.</p>}>
10606
10322
  <div class="app-admin-section-stack" style={{ gap: "0.5rem" }}>
10607
10323
  <div class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>
10608
10324
  {s().threadCount} thread{s().threadCount === 1 ? "" : "s"}
10609
- <Show31 when={s().adminUnreadCount > 0}>{` \xB7 ${s().adminUnreadCount} awaiting a reply`}</Show31>
10325
+ <Show30 when={s().adminUnreadCount > 0}>{` \xB7 ${s().adminUnreadCount} awaiting a reply`}</Show30>
10610
10326
  </div>
10611
10327
  <ul style={{ "list-style": "none", margin: 0, padding: 0, display: "flex", "flex-direction": "column", gap: "0.5rem" }}>
10612
- <For21 each={s().threads}>
10328
+ <For20 each={s().threads}>
10613
10329
  {(t) => <li style={{ display: "flex", "align-items": "center", "justify-content": "space-between", gap: "0.5rem" }}>
10614
10330
  <div style={{ "min-width": 0 }}>
10615
10331
  <div style={{ "font-size": "0.875rem", "font-weight": t.adminUnread ? "600" : "400", overflow: "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }}>
@@ -10617,24 +10333,24 @@ function SupportSummary(props) {
10617
10333
  </div>
10618
10334
  <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>
10619
10335
  {STATUS_WORD2[t.status] ?? t.status}
10620
- <Show31 when={t.lastMessageAt}>{` \xB7 ${fmtDate(t.lastMessageAt)}`}</Show31>
10336
+ <Show30 when={t.lastMessageAt}>{` \xB7 ${fmtDate(t.lastMessageAt)}`}</Show30>
10621
10337
  </div>
10622
10338
  </div>
10623
- <Show31 when={props.onOpenThread} fallback={<StatusBadge status={t.status} />}>
10339
+ <Show30 when={props.onOpenThread} fallback={<StatusBadge status={t.status} />}>
10624
10340
  <button type="button" class="app-admin-btn app-admin-btn-ghost app-admin-btn-sm" onClick={() => props.onOpenThread(t.id)}>
10625
10341
  Open
10626
10342
  </button>
10627
- </Show31>
10343
+ </Show30>
10628
10344
  </li>}
10629
- </For21>
10345
+ </For20>
10630
10346
  </ul>
10631
- <Show31 when={s().threadCount > s().threads.length}>
10347
+ <Show30 when={s().threadCount > s().threads.length}>
10632
10348
  <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>
10633
10349
  Showing the latest {s().threads.length}.
10634
10350
  </div>
10635
- </Show31>
10351
+ </Show30>
10636
10352
  </div>
10637
- </Show31>;
10353
+ </Show30>;
10638
10354
  }
10639
10355
 
10640
10356
  // src/pages/admin/customers/CustomerDetail.tsx
@@ -10659,8 +10375,6 @@ function CustomerDetail(props) {
10659
10375
  }
10660
10376
  );
10661
10377
  const [busy, setBusy] = createSignal17(null);
10662
- const [previewToken, setPreviewToken] = createSignal17(null);
10663
- const [previewName, setPreviewName] = createSignal17("");
10664
10378
  const [editingEmail, setEditingEmail] = createSignal17(false);
10665
10379
  const [emailDraft, setEmailDraft] = createSignal17("");
10666
10380
  const [savingEmail, setSavingEmail] = createSignal17(false);
@@ -10684,15 +10398,6 @@ function CustomerDetail(props) {
10684
10398
  setBusy(null);
10685
10399
  }
10686
10400
  };
10687
- const handleViewAsCustomer = () => withBusy("impersonate", async () => {
10688
- try {
10689
- const res = await adminApi.impersonateCustomer(props.uid);
10690
- setPreviewName([res.customer.firstName, res.customer.lastName].filter(Boolean).join(" ") || res.customer.email);
10691
- setPreviewToken(res.token);
10692
- } catch (err) {
10693
- toastError(err instanceof Error ? err.message : "Could not open customer view");
10694
- }
10695
- });
10696
10401
  const canSendReset = () => !!props.passwordResetRedirectUrl || !!o()?.tenant.passwordResetAvailable;
10697
10402
  const handleSendReset = () => {
10698
10403
  if (!confirm("Send a password reset email to this customer?")) return;
@@ -10735,7 +10440,7 @@ function CustomerDetail(props) {
10735
10440
  }
10736
10441
  };
10737
10442
  const handleCancel = (sub) => {
10738
- if (!confirm(`Cancel the ${sub.medication || ""} subscription? Billing stops now and any unapproved prescription requests are withdrawn.`)) return;
10443
+ if (!confirm(`Cancel the ${subscriptionLabel(sub, "")} subscription? Billing stops now and any unapproved prescription requests are withdrawn.`)) return;
10739
10444
  void withBusy(`cancel-${sub.id}`, async () => {
10740
10445
  try {
10741
10446
  const res = await adminApi.cancelSubscription(sub.id);
@@ -10843,7 +10548,7 @@ function CustomerDetail(props) {
10843
10548
  try {
10844
10549
  await adminApi.cancelSubscription(sub.id);
10845
10550
  } catch (err) {
10846
- failed.push(`${sub.medication || sub.id}: ${err instanceof Error ? err.message : "cancel failed"}`);
10551
+ failed.push(`${subscriptionLabel(sub, sub.id)}: ${err instanceof Error ? err.message : "cancel failed"}`);
10847
10552
  }
10848
10553
  }
10849
10554
  if (failed.length > 0) {
@@ -10903,8 +10608,8 @@ function CustomerDetail(props) {
10903
10608
  };
10904
10609
  const pendingRequests = () => (o()?.requests.items ?? []).filter((r) => r.status === "pending");
10905
10610
  return <div class="app-admin-detail">
10906
- <Show32 when={!overview.loading} fallback={<LoadingSpinner />}>
10907
- <Show32
10611
+ <Show31 when={!overview.loading} fallback={<LoadingSpinner />}>
10612
+ <Show31
10908
10613
  when={o()}
10909
10614
  fallback={<>
10910
10615
  <button type="button" class="app-admin-back" onClick={props.onBack}>
@@ -10928,7 +10633,7 @@ function CustomerDetail(props) {
10928
10633
  onBack={props.onBack}
10929
10634
  title={customerName(ov())}
10930
10635
  subtitle={<>
10931
- <Show32
10636
+ <Show31
10932
10637
  when={editingEmail()}
10933
10638
  fallback={<span style={{ display: "inline-flex", "align-items": "center", gap: "0.5rem" }}>
10934
10639
  <span>{c().email}</span>
@@ -10959,57 +10664,54 @@ function CustomerDetail(props) {
10959
10664
  Cancel
10960
10665
  </button>
10961
10666
  </span>
10962
- </Show32>
10963
- <Show32 when={c().phone}>
10667
+ </Show31>
10668
+ <Show31 when={c().phone}>
10964
10669
  <span>{c().phone}</span>
10965
- </Show32>
10670
+ </Show31>
10966
10671
  <span>Joined {fmtDate(c().createdAt)}</span>
10967
10672
  </>}
10968
10673
  badges={<>
10969
10674
  <LifecycleBadge lifecycle={ov().lifecycle} />
10970
- <Show32 when={c().savingsMemberId}>
10675
+ <Show31 when={c().savingsMemberId}>
10971
10676
  <span class="app-admin-badge app-admin-badge--info" style={{ "text-transform": "none" }}>
10972
10677
  Savings member
10973
10678
  </span>
10974
- </Show32>
10975
- <Show32 when={c().status && c().status !== "active"}>
10679
+ </Show31>
10680
+ <Show31 when={c().status && c().status !== "active"}>
10976
10681
  <StatusBadge status={c().status ?? ""} />
10977
- </Show32>
10682
+ </Show31>
10978
10683
  <span style={{ "font-size": "0.9375rem" }}>{reason()}</span>
10979
10684
  </>}
10980
10685
  actions={<>
10981
- <button type="button" onClick={handleViewAsCustomer} disabled={busy() === "impersonate"} class="app-admin-btn app-admin-btn-ghost">
10982
- {busy() === "impersonate" ? "Opening\u2026" : "View as customer"}
10983
- </button>
10984
- <Show32 when={canSendReset()}>
10686
+ <Show31 when={canSendReset()}>
10985
10687
  <button type="button" onClick={handleSendReset} disabled={busy() === "send-reset"} class="app-admin-btn app-admin-btn-ghost">
10986
10688
  {busy() === "send-reset" ? "Sending\u2026" : "Send password reset"}
10987
10689
  </button>
10988
- </Show32>
10690
+ </Show31>
10989
10691
  </>}
10990
10692
  />
10991
10693
 
10992
- <Show32 when={ov().partial.length > 0}>
10694
+ <Show31 when={ov().partial.length > 0}>
10993
10695
  <p class="app-admin-notice" style={{ margin: 0 }}>
10994
10696
  Some sections did not load ({ov().partial.join(", ")}).{" "}
10995
10697
  <button type="button" class="app-admin-link-btn" onClick={() => refetch()}>
10996
10698
  Reload
10997
10699
  </button>
10998
10700
  </p>
10999
- </Show32>
10701
+ </Show31>
11000
10702
 
11001
- <Show32 when={attention().length > 0}>
10703
+ <Show31 when={attention().length > 0}>
11002
10704
  <div class="app-admin-alerts" data-testid="customer-attention">
11003
- <For22 each={attention()}>
10705
+ <For21 each={attention()}>
11004
10706
  {(item) => <AlertItem
11005
10707
  severity={item.severity}
11006
10708
  title={item.title}
11007
10709
  detail={item.detail}
11008
10710
  action={canAct(item) ? { label: item.action.label, onClick: () => act(item), disabled: busy() !== null } : void 0}
11009
10711
  />}
11010
- </For22>
10712
+ </For21>
11011
10713
  </div>
11012
- </Show32>
10714
+ </Show31>
11013
10715
 
11014
10716
  <Section title="Journey">
11015
10717
  <Stepper steps={journey()} label="Customer journey" />
@@ -11018,9 +10720,9 @@ function CustomerDetail(props) {
11018
10720
  <DetailGrid
11019
10721
  main={<>
11020
10722
  <Section title="Subscriptions" count={ov().subscriptions.length}>
11021
- <Show32 when={ov().subscriptions.length > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>No subscriptions.</p>}>
10723
+ <Show31 when={ov().subscriptions.length > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>No subscriptions.</p>}>
11022
10724
  <div class="app-admin-section-stack">
11023
- <For22 each={[...ov().subscriptions].sort((a, b) => Date.parse(b.createdAt ?? "") - Date.parse(a.createdAt ?? ""))}>
10725
+ <For21 each={[...ov().subscriptions].sort((a, b) => Date.parse(b.createdAt ?? "") - Date.parse(a.createdAt ?? ""))}>
11024
10726
  {(sub) => <SubscriptionCard
11025
10727
  subscription={sub}
11026
10728
  busy={busy()}
@@ -11031,9 +10733,9 @@ function CustomerDetail(props) {
11031
10733
  onCancel={handleCancel}
11032
10734
  onResolveAttempt={(s, a) => setResolveTarget({ sub: s, attempt: a })}
11033
10735
  />}
11034
- </For22>
10736
+ </For21>
11035
10737
  </div>
11036
- </Show32>
10738
+ </Show31>
11037
10739
  </Section>
11038
10740
 
11039
10741
  <Section
@@ -11049,25 +10751,25 @@ function CustomerDetail(props) {
11049
10751
  {busy() === "cancel-requests" ? "Cancelling\u2026" : pendingRequests().length > 0 ? `Cancel unapproved requests (${pendingRequests().length})` : "Cancel unapproved requests"}
11050
10752
  </button>}
11051
10753
  >
11052
- <Show32 when={ov().requests.items.length > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>No prescription requests.</p>}>
10754
+ <Show31 when={ov().requests.items.length > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>No prescription requests.</p>}>
11053
10755
  <div class="app-admin-section-stack">
11054
- <For22 each={[...ov().requests.items].sort((a, b) => Date.parse(b.createdAt ?? "") - Date.parse(a.createdAt ?? ""))}>
10756
+ <For21 each={[...ov().requests.items].sort((a, b) => Date.parse(b.createdAt ?? "") - Date.parse(a.createdAt ?? ""))}>
11055
10757
  {(r) => <RequestCard request={r} fulfillmentMode={ov().tenant.fulfillmentMode} />}
11056
- </For22>
11057
- <Show32 when={ov().requests.capped}>
10758
+ </For21>
10759
+ <Show31 when={ov().requests.capped}>
11058
10760
  <p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.8125rem" }}>
11059
10761
  Older requests are shown from stored status only.
11060
10762
  </p>
11061
- </Show32>
10763
+ </Show31>
11062
10764
  </div>
11063
- </Show32>
10765
+ </Show31>
11064
10766
  </Section>
11065
10767
 
11066
10768
  <Section title="Payments" count={ov().payments.length} flush>
11067
10769
  <PaymentsTable payments={ov().payments} busyId={busy()?.startsWith("refund-") ? busy().slice(7) : null} onRefund={setRefundFor} />
11068
10770
  </Section>
11069
10771
 
11070
- <Show32 when={ov().orders.length > 0}>
10772
+ <Show31 when={ov().orders.length > 0}>
11071
10773
  <Section title="Orders" count={ov().orders.length} flush>
11072
10774
  <div class="app-admin-table-wrap">
11073
10775
  <table class="app-admin-table">
@@ -11080,7 +10782,7 @@ function CustomerDetail(props) {
11080
10782
  </tr>
11081
10783
  </thead>
11082
10784
  <tbody>
11083
- <For22 each={ov().orders}>
10785
+ <For21 each={ov().orders}>
11084
10786
  {(order) => <tr>
11085
10787
  <td data-label="Date" class="app-admin-text-muted">{fmtDate(order.createdAt)}</td>
11086
10788
  <td data-label="Items">
@@ -11091,12 +10793,12 @@ function CustomerDetail(props) {
11091
10793
  <StatusBadge status={order.status} />
11092
10794
  </td>
11093
10795
  </tr>}
11094
- </For22>
10796
+ </For21>
11095
10797
  </tbody>
11096
10798
  </table>
11097
10799
  </div>
11098
10800
  </Section>
11099
- </Show32>
10801
+ </Show31>
11100
10802
  </>}
11101
10803
  aside={<>
11102
10804
  <Section title="Profile">
@@ -11115,32 +10817,32 @@ function CustomerDetail(props) {
11115
10817
  {allTimeline() ? "Show recent" : "Show all"}
11116
10818
  </button> : void 0}
11117
10819
  >
11118
- <Show32 when={timeline().length > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>Nothing recorded yet.</p>}>
10820
+ <Show31 when={timeline().length > 0} fallback={<p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.875rem" }}>Nothing recorded yet.</p>}>
11119
10821
  <Timeline events={allTimeline() ? timeline() : timeline().slice(0, TIMELINE_PREVIEW)} />
11120
- </Show32>
10822
+ </Show31>
11121
10823
  </Section>
11122
10824
  </>}
11123
10825
  />
11124
10826
  </>;
11125
10827
  }}
11126
- </Show32>
11127
- </Show32>
10828
+ </Show31>
10829
+ </Show31>
11128
10830
 
11129
- <Show32 when={amountFor()}>
10831
+ <Show31 when={amountFor()}>
11130
10832
  {(sub) => <EditAmountModal subscription={sub()} onClose={() => setAmountFor(null)} onSave={(cents) => saveAmount(sub(), cents)} />}
11131
- </Show32>
11132
- <Show32 when={scheduleFor()}>
10833
+ </Show31>
10834
+ <Show31 when={scheduleFor()}>
11133
10835
  {(sub) => <EditScheduleModal subscription={sub()} onClose={() => setScheduleFor(null)} onSave={(patch) => saveSchedule(sub(), patch)} />}
11134
- </Show32>
11135
- <Show32 when={refundFor()}>
10836
+ </Show31>
10837
+ <Show31 when={refundFor()}>
11136
10838
  {(p) => <RefundModal
11137
10839
  payment={{ id: p().id, amountCents: p().amountCents ?? 0, refundedAmountCents: p().refundedAmountCents, createdAt: p().createdAt ?? void 0, customerEmail: o()?.customer.email }}
11138
- liveSubscriptions={liveSubs().map((s) => ({ id: s.id, medication: s.medication, amountCents: s.amountCents ?? 0, intervalDays: s.intervalDays ?? void 0, nextChargeAt: s.nextChargeAt, currentPeriodEnd: s.currentPeriodEnd }))}
10840
+ liveSubscriptions={liveSubs().map((s) => ({ id: s.id, medication: s.medication, medicationName: s.medicationName, amountCents: s.amountCents ?? 0, intervalDays: s.intervalDays ?? void 0, nextChargeAt: s.nextChargeAt, currentPeriodEnd: s.currentPeriodEnd }))}
11139
10841
  onClose={() => setRefundFor(null)}
11140
10842
  onRefund={(req) => doRefund(p(), req)}
11141
10843
  />}
11142
- </Show32>
11143
- <Show32 when={resolveTarget()}>
10844
+ </Show31>
10845
+ <Show31 when={resolveTarget()}>
11144
10846
  {(t) => <Modal title="Resolve billing attempt" onClose={() => setResolveTarget(null)}>
11145
10847
  <p style={{ margin: 0, "font-size": "0.875rem" }}>
11146
10848
  The {centsToUsd(t().attempt.amountCents)} charge for period {(t().attempt.billingPeriod ?? 0) + 1} is <strong>{t().attempt.status}</strong>
@@ -11155,15 +10857,12 @@ function CustomerDetail(props) {
11155
10857
  </button>
11156
10858
  </div>
11157
10859
  </Modal>}
11158
- </Show32>
11159
- <Show32 when={previewToken()}>
11160
- {(token) => <PatientDashboardPreview token={token()} customerName={previewName()} onClose={() => setPreviewToken(null)} />}
11161
- </Show32>
10860
+ </Show31>
11162
10861
  </div>;
11163
10862
  }
11164
10863
 
11165
10864
  // src/pages/admin/customers/CustomerList.tsx
11166
- import { createMemo as createMemo10, createResource as createResource11, createSignal as createSignal18, For as For23, Show as Show33 } from "solid-js";
10865
+ import { createMemo as createMemo10, createResource as createResource11, createSignal as createSignal18, For as For22, Show as Show32 } from "solid-js";
11167
10866
  var PAGE = 50;
11168
10867
  function hint(row) {
11169
10868
  const f = row.facts;
@@ -11269,22 +10968,22 @@ function CustomerList(props) {
11269
10968
  </div>
11270
10969
  <div class="app-admin-chips" role="group" aria-label="Filter by status">
11271
10970
  <Chip label="All" active={lifecycle() === null} count={total()} onClick={() => setLifecycle(null)} />
11272
- <For23 each={LIFECYCLE_BUCKETS}>
10971
+ <For22 each={LIFECYCLE_BUCKETS}>
11273
10972
  {(b) => <Chip
11274
10973
  label={LIFECYCLE_LABEL[b]}
11275
10974
  active={lifecycle() === b}
11276
10975
  count={facets()?.[b]}
11277
10976
  onClick={() => setLifecycle(lifecycle() === b ? null : b)}
11278
10977
  />}
11279
- </For23>
10978
+ </For22>
11280
10979
  </div>
11281
10980
  <div style={{ display: "flex", "flex-wrap": "wrap", gap: "1rem", "font-size": "0.8125rem", color: "var(--app-admin-fg-muted)" }}>
11282
- <Show33 when={showSavingsToggle()}>
10981
+ <Show32 when={showSavingsToggle()}>
11283
10982
  <label style={{ display: "inline-flex", "align-items": "center", gap: "0.375rem" }}>
11284
10983
  <input type="checkbox" checked={savingsOnly()} onChange={(e) => setSavingsOnly(e.currentTarget.checked)} />
11285
10984
  Savings members only
11286
10985
  </label>
11287
- </Show33>
10986
+ </Show32>
11288
10987
  <label style={{ display: "inline-flex", "align-items": "center", gap: "0.375rem" }}>
11289
10988
  <input type="checkbox" checked={noIntakeOnly()} onChange={(e) => setNoIntakeOnly(e.currentTarget.checked)} />
11290
10989
  Never completed intake
@@ -11292,7 +10991,7 @@ function CustomerList(props) {
11292
10991
  </div>
11293
10992
  </div>
11294
10993
 
11295
- <Show33 when={!page.loading} fallback={<LoadingSpinner />}>
10994
+ <Show32 when={!page.loading} fallback={<LoadingSpinner />}>
11296
10995
  <div class="app-admin-card" style={{ overflow: "hidden" }}>
11297
10996
  <div class="app-admin-table-wrap">
11298
10997
  <table class="app-admin-table">
@@ -11307,7 +11006,7 @@ function CustomerList(props) {
11307
11006
  </tr>
11308
11007
  </thead>
11309
11008
  <tbody>
11310
- <For23 each={rows()}>
11009
+ <For22 each={rows()}>
11311
11010
  {(row) => {
11312
11011
  const name = () => [row.firstName, row.lastName].filter(Boolean).join(" ").trim();
11313
11012
  const lastActivity = () => row.facts?.lastPaymentAt ?? row.createdAt;
@@ -11324,25 +11023,25 @@ function CustomerList(props) {
11324
11023
  >
11325
11024
  <td data-label="Customer" class="app-admin-table-cell--title">
11326
11025
  <div style={{ "font-weight": "500" }}>{name() || row.email}</div>
11327
- <Show33 when={name()}>
11026
+ <Show32 when={name()}>
11328
11027
  <div class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>{row.email}</div>
11329
- </Show33>
11028
+ </Show32>
11330
11029
  </td>
11331
11030
  <td data-label="Status">
11332
11031
  <div style={{ display: "flex", "flex-direction": "column", gap: "0.25rem", "align-items": "flex-start" }}>
11333
11032
  <LifecycleBadge lifecycle={row.lifecycle} />
11334
- <Show33 when={hint(row)}>
11033
+ <Show32 when={hint(row)}>
11335
11034
  <span class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{hint(row)}</span>
11336
- </Show33>
11035
+ </Show32>
11337
11036
  </div>
11338
11037
  </td>
11339
11038
  <td data-label="Plan" class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>
11340
- <Show33 when={row.facts && row.facts.subscriptionCount > 0} fallback={<span>—</span>}>
11039
+ <Show32 when={row.facts && row.facts.subscriptionCount > 0} fallback={<span>—</span>}>
11341
11040
  <span style={{ "text-transform": "capitalize" }}>
11342
11041
  {(row.facts.latestSubscriptionStatus ?? row.subscriptionStatus).replace(/_/g, " ")}
11343
11042
  </span>
11344
- <Show33 when={row.facts.nextChargeAt}>{` \xB7 next ${fmtDate(row.facts.nextChargeAt)}`}</Show33>
11345
- </Show33>
11043
+ <Show32 when={row.facts.nextChargeAt}>{` \xB7 next ${fmtDate(row.facts.nextChargeAt)}`}</Show32>
11044
+ </Show32>
11346
11045
  </td>
11347
11046
  <td data-label="Prescription" class="app-admin-text-muted" style={{ "font-size": "0.8125rem", "text-transform": "capitalize" }}>
11348
11047
  {rxLabel(row.facts?.latestRequestApexStatus ?? null)}
@@ -11351,31 +11050,31 @@ function CustomerList(props) {
11351
11050
  <td data-label="Joined" class="app-admin-text-muted">{fmtDate(row.createdAt)}</td>
11352
11051
  </tr>;
11353
11052
  }}
11354
- </For23>
11053
+ </For22>
11355
11054
  </tbody>
11356
11055
  </table>
11357
11056
  </div>
11358
- <Show33 when={rows().length === 0}>
11057
+ <Show32 when={rows().length === 0}>
11359
11058
  <EmptyState
11360
11059
  message={searchParam() || lifecycle() || savingsOnly() || noIntakeOnly() ? "No customers match these filters." : "No customers yet."}
11361
11060
  />
11362
- </Show33>
11363
- <Show33 when={hasMore()}>
11061
+ </Show32>
11062
+ <Show32 when={hasMore()}>
11364
11063
  <div style={{ padding: "0.75rem 1rem", "border-top": "1px solid var(--app-admin-border-soft)", display: "flex", "justify-content": "center" }}>
11365
11064
  <button type="button" class="app-admin-btn app-admin-btn-ghost" onClick={loadMore} disabled={loadingMore()}>
11366
11065
  {loadingMore() ? "Loading\u2026" : "Load more"}
11367
11066
  </button>
11368
11067
  </div>
11369
- </Show33>
11068
+ </Show32>
11370
11069
  </div>
11371
- </Show33>
11372
- <Show33 when={page.error}>
11070
+ </Show32>
11071
+ <Show32 when={page.error}>
11373
11072
  <div style={{ "margin-top": "0.75rem" }}>
11374
11073
  <button type="button" class="app-admin-link-btn" onClick={() => refetch()}>
11375
11074
  Retry
11376
11075
  </button>
11377
11076
  </div>
11378
- </Show33>
11077
+ </Show32>
11379
11078
  </div>;
11380
11079
  }
11381
11080
 
@@ -11443,13 +11142,13 @@ function Customers(props = {}) {
11443
11142
  const off = onCustomerUrlChange((fromUrl) => setInternalUid(fromUrl));
11444
11143
  onCleanup(off);
11445
11144
  });
11446
- return <Show34 when={uid()} fallback={<CustomerList initialFilter={props.initialFilter} onOpen={(id) => select(id)} />}>
11145
+ return <Show33 when={uid()} fallback={<CustomerList initialFilter={props.initialFilter} onOpen={(id) => select(id)} />}>
11447
11146
  {(id) => <CustomerDetail uid={id()} onBack={() => select(null)} passwordResetRedirectUrl={props.passwordResetRedirectUrl} />}
11448
- </Show34>;
11147
+ </Show33>;
11449
11148
  }
11450
11149
 
11451
11150
  // src/pages/admin/Dashboard.tsx
11452
- import { createResource as createResource12, For as For24, Show as Show35 } from "solid-js";
11151
+ import { createResource as createResource12, For as For23, Show as Show34 } from "solid-js";
11453
11152
  import { Dynamic } from "solid-js/web";
11454
11153
  function Dashboard(props) {
11455
11154
  const [stats] = createResource12(async () => {
@@ -11474,8 +11173,8 @@ function Dashboard(props) {
11474
11173
  };
11475
11174
  return <div>
11476
11175
  <PageTitle>Dashboard</PageTitle>
11477
- <Show35 when={!stats.loading} fallback={<LoadingSpinner />}>
11478
- <Show35 when={stats()} fallback={<EmptyState message="Failed to load dashboard stats." />}>
11176
+ <Show34 when={!stats.loading} fallback={<LoadingSpinner />}>
11177
+ <Show34 when={stats()} fallback={<EmptyState message="Failed to load dashboard stats." />}>
11479
11178
  <div
11480
11179
  data-testid="admin-stats"
11481
11180
  style={{
@@ -11484,7 +11183,7 @@ function Dashboard(props) {
11484
11183
  "grid-template-columns": "repeat(auto-fit, minmax(220px, 1fr))"
11485
11184
  }}
11486
11185
  >
11487
- <For24 each={cards()}>
11186
+ <For23 each={cards()}>
11488
11187
  {(card) => {
11489
11188
  const clickable = !!props.onSelectTab && !!card.tab && (props.isTabEnabled?.(card.tab) ?? true);
11490
11189
  return <Dynamic
@@ -11529,18 +11228,18 @@ function Dashboard(props) {
11529
11228
  </span>
11530
11229
  </Dynamic>;
11531
11230
  }}
11532
- </For24>
11231
+ </For23>
11533
11232
  </div>
11534
- </Show35>
11535
- </Show35>
11233
+ </Show34>
11234
+ </Show34>
11536
11235
  </div>;
11537
11236
  }
11538
11237
 
11539
11238
  // src/pages/admin/Payments.tsx
11540
- import { createResource as createResource14, createSignal as createSignal21, For as For25, Show as Show37 } from "solid-js";
11239
+ import { createResource as createResource14, createSignal as createSignal21, For as For24, Show as Show36 } from "solid-js";
11541
11240
 
11542
11241
  // src/pages/admin/QuickBooksCard.tsx
11543
- import { createResource as createResource13, createSignal as createSignal20, Show as Show36, onMount as onMount2 } from "solid-js";
11242
+ import { createResource as createResource13, createSignal as createSignal20, Show as Show35, onMount as onMount2 } from "solid-js";
11544
11243
  function QuickBooksCard() {
11545
11244
  const [status, { refetch }] = createResource13(() => adminApi.quickbooksStatus().catch(() => null));
11546
11245
  const [connecting, setConnecting] = createSignal20(false);
@@ -11569,7 +11268,7 @@ function QuickBooksCard() {
11569
11268
  setConnecting(false);
11570
11269
  }
11571
11270
  };
11572
- return <Show36 when={status()?.provider === "quickbooks"}>
11271
+ return <Show35 when={status()?.provider === "quickbooks"}>
11573
11272
  <div
11574
11273
  style={{
11575
11274
  display: "flex",
@@ -11585,20 +11284,20 @@ function QuickBooksCard() {
11585
11284
  >
11586
11285
  <div>
11587
11286
  <div style={{ "font-weight": 600 }}>QuickBooks Payments</div>
11588
- <Show36
11287
+ <Show35
11589
11288
  when={status()?.connected}
11590
11289
  fallback={<div style={{ color: "var(--admin-text-muted, #64748b)", "font-size": "14px" }}>Not connected — connect your QuickBooks account to accept payments.</div>}
11591
11290
  >
11592
11291
  <div style={{ color: "var(--admin-text-muted, #64748b)", "font-size": "14px" }}>
11593
11292
  Connected{status()?.realmId ? ` \xB7 company ${status().realmId}` : ""} · {status()?.environment}
11594
11293
  </div>
11595
- </Show36>
11294
+ </Show35>
11596
11295
  </div>
11597
11296
  <button class="btn btn-primary" disabled={connecting()} onClick={connect}>
11598
11297
  {connecting() ? "Redirecting\u2026" : status()?.connected ? "Reconnect" : "Connect QuickBooks"}
11599
11298
  </button>
11600
11299
  </div>
11601
- </Show36>;
11300
+ </Show35>;
11602
11301
  }
11603
11302
 
11604
11303
  // src/pages/admin/Payments.tsx
@@ -11639,7 +11338,7 @@ function Payments() {
11639
11338
  try {
11640
11339
  await adminApi.cancelSubscription(sub.id);
11641
11340
  } catch (err) {
11642
- failed.push(`${sub.medication || sub.id}: ${err instanceof Error ? err.message : "cancel failed"}`);
11341
+ failed.push(`${subscriptionLabel(sub, sub.id)}: ${err instanceof Error ? err.message : "cancel failed"}`);
11643
11342
  }
11644
11343
  }
11645
11344
  if (failed.length > 0) {
@@ -11660,7 +11359,7 @@ function Payments() {
11660
11359
  return <div>
11661
11360
  <PageTitle>Payments</PageTitle>
11662
11361
  <QuickBooksCard />
11663
- <Show37 when={!payments.loading} fallback={<LoadingSpinner />}>
11362
+ <Show36 when={!payments.loading} fallback={<LoadingSpinner />}>
11664
11363
  <div class="app-admin-card" style={{ overflow: "hidden" }}>
11665
11364
  <div class="app-admin-table-wrap">
11666
11365
  <table class="app-admin-table">
@@ -11675,33 +11374,33 @@ function Payments() {
11675
11374
  </tr>
11676
11375
  </thead>
11677
11376
  <tbody>
11678
- <For25 each={payments() ?? []}>
11377
+ <For24 each={payments() ?? []}>
11679
11378
  {(payment) => <tr>
11680
11379
  <td data-label="Date" class="app-admin-text-muted">{fmtDate(payment.date)}</td>
11681
11380
  <td data-label="Customer" style={{ "font-weight": "500" }}>
11682
- <Show37 when={nav && payment.customerUid} fallback={payment.customerEmail}>
11381
+ <Show36 when={nav && payment.customerUid} fallback={payment.customerEmail}>
11683
11382
  <button type="button" class="app-admin-link-btn" style={{ "font-size": "inherit", "font-weight": "inherit" }} onClick={() => nav.openCustomer(payment.customerUid)}>
11684
11383
  {payment.customerEmail}
11685
11384
  </button>
11686
- </Show37>
11385
+ </Show36>
11687
11386
  </td>
11688
11387
  <td data-label="Amount">
11689
11388
  {centsToUsd(payment.amountCents)}
11690
- <Show37 when={(payment.refundedAmountCents ?? 0) > 0 && payment.status !== "refunded"}>
11389
+ <Show36 when={(payment.refundedAmountCents ?? 0) > 0 && payment.status !== "refunded"}>
11691
11390
  <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{centsToUsd(payment.refundedAmountCents)} refunded</div>
11692
- </Show37>
11391
+ </Show36>
11693
11392
  </td>
11694
11393
  <td data-label="Status">
11695
11394
  <StatusBadge status={payment.status} />
11696
- <Show37 when={payment.failureReason}>
11395
+ <Show36 when={payment.failureReason}>
11697
11396
  <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{payment.failureReason}</div>
11698
- </Show37>
11397
+ </Show36>
11699
11398
  </td>
11700
11399
  <td data-label="Transaction ID" class="app-admin-text-mono app-admin-text-muted" style={{ "font-size": "0.75rem" }}>
11701
11400
  {payment.transactionId}
11702
11401
  </td>
11703
11402
  <td data-label="Actions">
11704
- <Show37 when={refundable(payment)}>
11403
+ <Show36 when={refundable(payment)}>
11705
11404
  <button
11706
11405
  type="button"
11707
11406
  onClick={() => openRefund(payment)}
@@ -11710,20 +11409,20 @@ function Payments() {
11710
11409
  >
11711
11410
  {loadingRefund() === payment.id ? "..." : "Refund"}
11712
11411
  </button>
11713
- </Show37>
11412
+ </Show36>
11714
11413
  </td>
11715
11414
  </tr>}
11716
- </For25>
11415
+ </For24>
11717
11416
  </tbody>
11718
11417
  </table>
11719
11418
  </div>
11720
- <Show37 when={(payments() ?? []).length === 0}>
11419
+ <Show36 when={(payments() ?? []).length === 0}>
11721
11420
  <EmptyState message="No payments found." />
11722
- </Show37>
11421
+ </Show36>
11723
11422
  </div>
11724
- </Show37>
11423
+ </Show36>
11725
11424
 
11726
- <Show37 when={refundFor()}>
11425
+ <Show36 when={refundFor()}>
11727
11426
  {(target) => <RefundModal
11728
11427
  payment={{
11729
11428
  id: target().payment.id,
@@ -11736,6 +11435,7 @@ function Payments() {
11736
11435
  (s) => ({
11737
11436
  id: s.id,
11738
11437
  medication: s.medication,
11438
+ medicationName: s.medicationName,
11739
11439
  amountCents: s.amountCents,
11740
11440
  intervalDays: s.intervalDays,
11741
11441
  currentPeriodEnd: s.currentPeriodEnd
@@ -11744,12 +11444,12 @@ function Payments() {
11744
11444
  onClose={() => setRefundFor(null)}
11745
11445
  onRefund={(req) => doRefund(target().payment, target().liveSubs, req)}
11746
11446
  />}
11747
- </Show37>
11447
+ </Show36>
11748
11448
  </div>;
11749
11449
  }
11750
11450
 
11751
11451
  // src/pages/admin/Products.tsx
11752
- import { createEffect as createEffect8, createMemo as createMemo11, createResource as createResource15, createSignal as createSignal22, For as For26, Show as Show38 } from "solid-js";
11452
+ import { createEffect as createEffect8, createMemo as createMemo11, createResource as createResource15, createSignal as createSignal22, For as For25, Show as Show37 } from "solid-js";
11753
11453
 
11754
11454
  // src/pages/admin/_apexDrugs.ts
11755
11455
  var TTL_MS = 5 * 60 * 1e3;
@@ -11829,7 +11529,7 @@ function ThumbnailUpload(props) {
11829
11529
  e.currentTarget.value = "";
11830
11530
  }}
11831
11531
  />
11832
- <Show38 when={error()}>
11532
+ <Show37 when={error()}>
11833
11533
  <div
11834
11534
  style={{
11835
11535
  background: "var(--app-admin-danger-bg)",
@@ -11842,8 +11542,8 @@ function ThumbnailUpload(props) {
11842
11542
  >
11843
11543
  {error()}
11844
11544
  </div>
11845
- </Show38>
11846
- <Show38
11545
+ </Show37>
11546
+ <Show37
11847
11547
  when={displayUrl()}
11848
11548
  fallback={<button
11849
11549
  type="button"
@@ -11916,18 +11616,18 @@ function ThumbnailUpload(props) {
11916
11616
  </button>
11917
11617
  </div>
11918
11618
  </div>
11919
- </Show38>
11619
+ </Show37>
11920
11620
  </div>;
11921
11621
  }
11922
11622
  function SkuSelectOptions(props) {
11923
11623
  return <>
11924
11624
  <option value="">{props.placeholder}</option>
11925
- <For26 each={props.skus}>
11625
+ <For25 each={props.skus}>
11926
11626
  {(s) => <option value={s.id}>
11927
11627
  {s.label}
11928
11628
  {s.active === false ? " (inactive)" : ""}
11929
11629
  </option>}
11930
- </For26>
11630
+ </For25>
11931
11631
  </>;
11932
11632
  }
11933
11633
  function ProductEditPanel(props) {
@@ -12119,7 +11819,7 @@ function ProductEditPanel(props) {
12119
11819
  class="app-admin-input"
12120
11820
  style={{ resize: "vertical" }}
12121
11821
  />
12122
- <Show38 when={apexAdCopy() && apexAdCopy() !== description()}>
11822
+ <Show37 when={apexAdCopy() && apexAdCopy() !== description()}>
12123
11823
  <button
12124
11824
  type="button"
12125
11825
  onClick={() => setDescription(apexAdCopy())}
@@ -12128,7 +11828,7 @@ function ProductEditPanel(props) {
12128
11828
  >
12129
11829
  Use Default from Apex
12130
11830
  </button>
12131
- </Show38>
11831
+ </Show37>
12132
11832
  </div>
12133
11833
 
12134
11834
  <div>
@@ -12163,7 +11863,7 @@ function ProductEditPanel(props) {
12163
11863
 
12164
11864
  <div>
12165
11865
  <label class="app-admin-label">Categories</label>
12166
- <Show38
11866
+ <Show37
12167
11867
  when={props.availableCategories.length > 0}
12168
11868
  fallback={<p
12169
11869
  style={{
@@ -12182,7 +11882,7 @@ function ProductEditPanel(props) {
12182
11882
  gap: "0.375rem 0.75rem"
12183
11883
  }}
12184
11884
  >
12185
- <For26 each={props.availableCategories}>
11885
+ <For25 each={props.availableCategories}>
12186
11886
  {(c) => {
12187
11887
  const checked = () => selectedCategoryIds().includes(c.id);
12188
11888
  return <label
@@ -12204,9 +11904,9 @@ function ProductEditPanel(props) {
12204
11904
  <span>{c.name}</span>
12205
11905
  </label>;
12206
11906
  }}
12207
- </For26>
11907
+ </For25>
12208
11908
  </div>
12209
- </Show38>
11909
+ </Show37>
12210
11910
  {
12211
11911
  /* Surface any category strings on the product that aren't in the
12212
11912
  available list so the admin can clean them up. */
@@ -12214,7 +11914,7 @@ function ProductEditPanel(props) {
12214
11914
  {(() => {
12215
11915
  const knownIds = new Set(props.availableCategories.map((c) => c.id));
12216
11916
  const unknown = () => selectedCategoryIds().filter((id) => !knownIds.has(id));
12217
- return <Show38 when={unknown().length > 0}>
11917
+ return <Show37 when={unknown().length > 0}>
12218
11918
  <div
12219
11919
  style={{
12220
11920
  "margin-top": "0.5rem",
@@ -12226,7 +11926,7 @@ function ProductEditPanel(props) {
12226
11926
  Unknown categories on this product:
12227
11927
  </div>
12228
11928
  <div style={{ display: "flex", "flex-wrap": "wrap", gap: "0.375rem" }}>
12229
- <For26 each={unknown()}>
11929
+ <For25 each={unknown()}>
12230
11930
  {(id) => <span
12231
11931
  style={{
12232
11932
  display: "inline-flex",
@@ -12255,17 +11955,17 @@ function ProductEditPanel(props) {
12255
11955
  ×
12256
11956
  </button>
12257
11957
  </span>}
12258
- </For26>
11958
+ </For25>
12259
11959
  </div>
12260
11960
  </div>
12261
- </Show38>;
11961
+ </Show37>;
12262
11962
  })()}
12263
11963
  </div>
12264
11964
 
12265
11965
  <div>
12266
11966
  <label class="app-admin-label">Pricing Mode</label>
12267
11967
  <div style={{ display: "grid", "grid-template-columns": "1fr 1fr", gap: "0.5rem" }}>
12268
- <For26 each={["per_dose", "flat_fee"]}>
11968
+ <For25 each={["per_dose", "flat_fee"]}>
12269
11969
  {(mode) => <button
12270
11970
  type="button"
12271
11971
  onClick={() => setPricingMode(mode)}
@@ -12274,7 +11974,7 @@ function ProductEditPanel(props) {
12274
11974
  >
12275
11975
  {mode === "per_dose" ? "Per-dose pricing" : "Flat fee"}
12276
11976
  </button>}
12277
- </For26>
11977
+ </For25>
12278
11978
  </div>
12279
11979
  <p
12280
11980
  style={{
@@ -12290,7 +11990,7 @@ function ProductEditPanel(props) {
12290
11990
 
12291
11991
  <div>
12292
11992
  <label class="app-admin-label">Default Dosage</label>
12293
- <Show38
11993
+ <Show37
12294
11994
  when={apexDosages().length > 0}
12295
11995
  fallback={<input
12296
11996
  type="text"
@@ -12306,12 +12006,12 @@ function ProductEditPanel(props) {
12306
12006
  class="app-admin-input"
12307
12007
  >
12308
12008
  <option value="">None (use Apex default)</option>
12309
- <For26 each={apexDosages()}>{(d) => <option value={d}>{d}</option>}</For26>
12009
+ <For25 each={apexDosages()}>{(d) => <option value={d}>{d}</option>}</For25>
12310
12010
  </select>
12311
- </Show38>
12011
+ </Show37>
12312
12012
  </div>
12313
12013
 
12314
- <Show38 when={props.product.apexDrugId}>
12014
+ <Show37 when={props.product.apexDrugId}>
12315
12015
  <div>
12316
12016
  <label class="app-admin-label">Pharmacy SKU binding</label>
12317
12017
  <p
@@ -12326,7 +12026,7 @@ function ProductEditPanel(props) {
12326
12026
  pharmacy — no fuzzy label matching. Turn on “Prescriber picks” for a titration
12327
12027
  product with no fixed SKU at order time.
12328
12028
  </p>
12329
- <Show38
12029
+ <Show37
12330
12030
  when={apexSkus().length > 0}
12331
12031
  fallback={<p
12332
12032
  style={{ "font-size": "0.75rem", color: "var(--app-admin-fg-muted)", margin: 0 }}
@@ -12351,7 +12051,7 @@ function ProductEditPanel(props) {
12351
12051
  />
12352
12052
  <span>Prescriber picks the dose (no fixed SKU sent)</span>
12353
12053
  </label>
12354
- <Show38 when={!prescriberPicks() && pricingMode() === "flat_fee"}>
12054
+ <Show37 when={!prescriberPicks() && pricingMode() === "flat_fee"}>
12355
12055
  <div style={{ "margin-top": "0.5rem" }}>
12356
12056
  <label class="app-admin-label">Bound SKU</label>
12357
12057
  <select
@@ -12362,12 +12062,12 @@ function ProductEditPanel(props) {
12362
12062
  <SkuSelectOptions skus={apexSkus()} placeholder="— Select SKU —" />
12363
12063
  </select>
12364
12064
  </div>
12365
- </Show38>
12366
- </Show38>
12065
+ </Show37>
12066
+ </Show37>
12367
12067
  </div>
12368
- </Show38>
12068
+ </Show37>
12369
12069
 
12370
- <Show38 when={pricingMode() === "per_dose"}>
12070
+ <Show37 when={pricingMode() === "per_dose"}>
12371
12071
  <div>
12372
12072
  <label class="app-admin-label">Available doses &amp; pricing</label>
12373
12073
  <p
@@ -12381,20 +12081,20 @@ function ProductEditPanel(props) {
12381
12081
  Doses come from the linked Apex drug. Leave a price blank to charge the
12382
12082
  base price{price() ? ` ($${price()})` : ""}.
12383
12083
  </p>
12384
- <Show38
12084
+ <Show37
12385
12085
  when={apexDosages().length > 0}
12386
12086
  fallback={<p style={{ "font-size": "0.75rem", color: "var(--app-admin-fg-muted)", margin: 0 }}>
12387
12087
  {loadingDosages() ? "Loading doses\u2026" : "No Apex drug linked, or no doses available."}
12388
12088
  </p>}
12389
12089
  >
12390
12090
  <div style={{ display: "flex", "flex-direction": "column", gap: "0.625rem" }}>
12391
- <For26 each={apexDosages()}>
12091
+ <For25 each={apexDosages()}>
12392
12092
  {(dose) => <div style={{ display: "flex", "flex-direction": "column", gap: "0.25rem" }}>
12393
12093
  <span style={{ "font-size": "0.8125rem", color: "var(--app-admin-fg)" }}>
12394
12094
  {dose}
12395
12095
  </span>
12396
12096
  <div style={{ display: "flex", gap: "0.5rem", "align-items": "center" }}>
12397
- <Show38 when={!prescriberPicks() && apexSkus().length > 0}>
12097
+ <Show37 when={!prescriberPicks() && apexSkus().length > 0}>
12398
12098
  <select
12399
12099
  value={skuIdForDose(dose)}
12400
12100
  onChange={(e) => setSkuForDose(dose, e.currentTarget.value)}
@@ -12404,7 +12104,7 @@ function ProductEditPanel(props) {
12404
12104
  >
12405
12105
  <SkuSelectOptions skus={apexSkus()} placeholder="— SKU —" />
12406
12106
  </select>
12407
- </Show38>
12107
+ </Show37>
12408
12108
  <input
12409
12109
  type="number"
12410
12110
  step="0.01"
@@ -12416,11 +12116,11 @@ function ProductEditPanel(props) {
12416
12116
  />
12417
12117
  </div>
12418
12118
  </div>}
12419
- </For26>
12119
+ </For25>
12420
12120
  </div>
12421
- </Show38>
12121
+ </Show37>
12422
12122
  </div>
12423
- </Show38>
12123
+ </Show37>
12424
12124
 
12425
12125
  <div>
12426
12126
  <label class="app-admin-label">Benefits (one per line)</label>
@@ -12434,7 +12134,7 @@ function ProductEditPanel(props) {
12434
12134
  </div>
12435
12135
 
12436
12136
  <div style={{ display: "flex", gap: "0.75rem", "padding-top": "0.5rem" }}>
12437
- <Show38 when={resetCandidate()}>
12137
+ <Show37 when={resetCandidate()}>
12438
12138
  <button
12439
12139
  type="button"
12440
12140
  onClick={applyReset}
@@ -12444,7 +12144,7 @@ function ProductEditPanel(props) {
12444
12144
  >
12445
12145
  Reset to defaults
12446
12146
  </button>
12447
- </Show38>
12147
+ </Show37>
12448
12148
  <button
12449
12149
  type="button"
12450
12150
  onClick={props.onClose}
@@ -12594,7 +12294,7 @@ function Products(props) {
12594
12294
  Products
12595
12295
  </PageTitle>
12596
12296
 
12597
- <Show38 when={!loading()} fallback={<LoadingSpinner />}>
12297
+ <Show37 when={!loading()} fallback={<LoadingSpinner />}>
12598
12298
  <div class="app-admin-card" style={{ overflow: "hidden" }}>
12599
12299
  <table class="app-admin-table">
12600
12300
  <thead>
@@ -12608,7 +12308,7 @@ function Products(props) {
12608
12308
  </tr>
12609
12309
  </thead>
12610
12310
  <tbody>
12611
- <For26 each={catalog()}>
12311
+ <For25 each={catalog()}>
12612
12312
  {(entry) => <tr
12613
12313
  class={`is-clickable ${editingProduct()?.id === entry.product?.id && entry.product ? "is-active" : ""}`}
12614
12314
  style={opening() === entry.drugId ? { opacity: 0.5, "pointer-events": "none" } : void 0}
@@ -12642,16 +12342,16 @@ function Products(props) {
12642
12342
  {entry.product ? fmtPrice(entry.product.price) : <span class="app-admin-text-muted">-</span>}
12643
12343
  </td>
12644
12344
  <td data-label="Dosages" class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>
12645
- <Show38
12345
+ <Show37
12646
12346
  when={entry.product?.dosagePrices?.length}
12647
12347
  fallback={<span style={{ opacity: 0.5 }}>-</span>}
12648
12348
  >
12649
12349
  {entry.product.dosagePrices.map((dp) => dp.dosage).join(", ")}
12650
- </Show38>
12350
+ </Show37>
12651
12351
  </td>
12652
12352
  <td data-label="Categories" class="app-admin-text-muted">
12653
12353
  <div style={{ display: "flex", "flex-wrap": "wrap", gap: "0.25rem" }}>
12654
- <For26 each={entry.product?.categories ?? []}>
12354
+ <For25 each={entry.product?.categories ?? []}>
12655
12355
  {(cat) => <span
12656
12356
  style={{
12657
12357
  padding: "0.125rem 0.375rem",
@@ -12662,26 +12362,26 @@ function Products(props) {
12662
12362
  >
12663
12363
  {cat}
12664
12364
  </span>}
12665
- </For26>
12666
- <Show38 when={!entry.product}>
12365
+ </For25>
12366
+ <Show37 when={!entry.product}>
12667
12367
  <span style={{ opacity: 0.5, "font-size": "0.75rem" }}>
12668
12368
  Not configured
12669
12369
  </span>
12670
- </Show38>
12370
+ </Show37>
12671
12371
  </div>
12672
12372
  </td>
12673
12373
  </tr>}
12674
- </For26>
12374
+ </For25>
12675
12375
  </tbody>
12676
12376
  </table>
12677
- <Show38 when={catalog().length === 0}>
12377
+ <Show37 when={catalog().length === 0}>
12678
12378
  <EmptyState message="No drugs available. Check Apex configuration." />
12679
- </Show38>
12379
+ </Show37>
12680
12380
  </div>
12681
- </Show38>
12381
+ </Show37>
12682
12382
  </div>
12683
12383
 
12684
- <Show38 when={editingProduct()}>
12384
+ <Show37 when={editingProduct()}>
12685
12385
  {(product) => <ProductEditPanel
12686
12386
  product={product()}
12687
12387
  saving={saving()}
@@ -12704,12 +12404,12 @@ function Products(props) {
12704
12404
  onClose={() => setEditingProduct(null)}
12705
12405
  defaultsLookup={props.productDefaultsLookup}
12706
12406
  />}
12707
- </Show38>
12407
+ </Show37>
12708
12408
  </div>;
12709
12409
  }
12710
12410
 
12711
12411
  // src/pages/admin/Sales.tsx
12712
- import { createMemo as createMemo12, createResource as createResource16, createSignal as createSignal23, For as For27, Show as Show39 } from "solid-js";
12412
+ import { createMemo as createMemo12, createResource as createResource16, createSignal as createSignal23, For as For26, Show as Show38 } from "solid-js";
12713
12413
  function SaleEditPanel(props) {
12714
12414
  const editing = () => props.sale !== null;
12715
12415
  const initial = props.sale;
@@ -12795,7 +12495,7 @@ function SaleEditPanel(props) {
12795
12495
  </button>
12796
12496
  </div>
12797
12497
 
12798
- <Show39 when={error()}>
12498
+ <Show38 when={error()}>
12799
12499
  <div
12800
12500
  style={{
12801
12501
  background: "var(--app-admin-danger-bg)",
@@ -12809,7 +12509,7 @@ function SaleEditPanel(props) {
12809
12509
  >
12810
12510
  {error()}
12811
12511
  </div>
12812
- </Show39>
12512
+ </Show38>
12813
12513
 
12814
12514
  <div style={{ display: "flex", "flex-direction": "column", gap: "1rem" }}>
12815
12515
  <div>
@@ -12882,7 +12582,7 @@ function SaleEditPanel(props) {
12882
12582
  class="app-admin-card-soft"
12883
12583
  style={{ padding: "0.5rem", "max-height": "11rem", "overflow-y": "auto" }}
12884
12584
  >
12885
- <Show39
12585
+ <Show38
12886
12586
  when={props.products.length > 0}
12887
12587
  fallback={<div
12888
12588
  style={{
@@ -12894,7 +12594,7 @@ function SaleEditPanel(props) {
12894
12594
  No products available.
12895
12595
  </div>}
12896
12596
  >
12897
- <For27 each={props.products}>
12597
+ <For26 each={props.products}>
12898
12598
  {(p) => <label
12899
12599
  style={{
12900
12600
  display: "flex",
@@ -12912,8 +12612,8 @@ function SaleEditPanel(props) {
12912
12612
  />
12913
12613
  <span style={{ "font-size": "0.875rem" }}>{p.name}</span>
12914
12614
  </label>}
12915
- </For27>
12916
- </Show39>
12615
+ </For26>
12616
+ </Show38>
12917
12617
  </div>
12918
12618
  </div>
12919
12619
 
@@ -12928,7 +12628,7 @@ function SaleEditPanel(props) {
12928
12628
  <option value="finite">First N rebills</option>
12929
12629
  <option value="indefinite">All recurring charges (indefinite)</option>
12930
12630
  </select>
12931
- <Show39 when={recurringMode() === "finite"}>
12631
+ <Show38 when={recurringMode() === "finite"}>
12932
12632
  <input
12933
12633
  type="number"
12934
12634
  min="1"
@@ -12938,7 +12638,7 @@ function SaleEditPanel(props) {
12938
12638
  class="app-admin-input"
12939
12639
  style={{ "margin-top": "0.5rem" }}
12940
12640
  />
12941
- </Show39>
12641
+ </Show38>
12942
12642
  </div>
12943
12643
 
12944
12644
  <label
@@ -13045,7 +12745,7 @@ function Sales() {
13045
12745
  </button>
13046
12746
  </div>
13047
12747
 
13048
- <Show39 when={!sales.loading} fallback={<LoadingSpinner />}>
12748
+ <Show38 when={!sales.loading} fallback={<LoadingSpinner />}>
13049
12749
  <div class="app-admin-card" style={{ overflow: "hidden" }}>
13050
12750
  <table class="app-admin-table">
13051
12751
  <thead>
@@ -13059,11 +12759,11 @@ function Sales() {
13059
12759
  </tr>
13060
12760
  </thead>
13061
12761
  <tbody>
13062
- <For27 each={sales() ?? []}>
12762
+ <For26 each={sales() ?? []}>
13063
12763
  {(s) => <tr>
13064
12764
  <td data-label="Name" style={{ "font-weight": "500" }}>
13065
12765
  {s.name}
13066
- <Show39 when={s.isExclusive}>
12766
+ <Show38 when={s.isExclusive}>
13067
12767
  <span
13068
12768
  style={{
13069
12769
  "margin-left": "0.5rem",
@@ -13073,7 +12773,7 @@ function Sales() {
13073
12773
  >
13074
12774
  exclusive
13075
12775
  </span>
13076
- </Show39>
12776
+ </Show38>
13077
12777
  </td>
13078
12778
  <td data-label="Discount">{fmtDiscount(s.discountType, s.discountValueCents)}</td>
13079
12779
  <td data-label="Window" class="app-admin-text-muted">
@@ -13119,16 +12819,16 @@ function Sales() {
13119
12819
  </button>
13120
12820
  </td>
13121
12821
  </tr>}
13122
- </For27>
12822
+ </For26>
13123
12823
  </tbody>
13124
12824
  </table>
13125
- <Show39 when={(sales() ?? []).length === 0}>
12825
+ <Show38 when={(sales() ?? []).length === 0}>
13126
12826
  <EmptyState message="No sales yet." />
13127
- </Show39>
12827
+ </Show38>
13128
12828
  </div>
13129
- </Show39>
12829
+ </Show38>
13130
12830
 
13131
- <Show39 when={editing()}>
12831
+ <Show38 when={editing()}>
13132
12832
  <SaleEditPanel
13133
12833
  sale={editing() === "new" ? null : editing()}
13134
12834
  products={products() ?? []}
@@ -13138,12 +12838,12 @@ function Sales() {
13138
12838
  refresh();
13139
12839
  }}
13140
12840
  />
13141
- </Show39>
12841
+ </Show38>
13142
12842
  </div>;
13143
12843
  }
13144
12844
 
13145
12845
  // src/pages/admin/Support.tsx
13146
- import { createEffect as createEffect9, createResource as createResource17, createSignal as createSignal24, For as For28, Show as Show40 } from "solid-js";
12846
+ import { createEffect as createEffect9, createResource as createResource17, createSignal as createSignal24, For as For27, Show as Show39 } from "solid-js";
13147
12847
  var STATUS_FILTERS3 = [
13148
12848
  { value: "all", label: "All" },
13149
12849
  { value: "open", label: "Needs reply" },
@@ -13282,7 +12982,7 @@ function Support(props = {}) {
13282
12982
  if (!isImage() || url()) return;
13283
12983
  void resolveAttachmentUrl(p.attachment.id).then((u) => u ? setUrl(u) : setFailed(true));
13284
12984
  });
13285
- return <Show40
12985
+ return <Show39
13286
12986
  when={isImage() && url() && !failed()}
13287
12987
  fallback={<button
13288
12988
  type="button"
@@ -13315,7 +13015,7 @@ function Support(props = {}) {
13315
13015
  }}
13316
13016
  />
13317
13017
  </button>
13318
- </Show40>;
13018
+ </Show39>;
13319
13019
  };
13320
13020
  const Bubble = (p) => {
13321
13021
  const fromSupport = () => p.msg.sender === "support";
@@ -13347,19 +13047,19 @@ function Support(props = {}) {
13347
13047
  {formatWhen(p.msg.createdAt)}
13348
13048
  </span>
13349
13049
  </div>
13350
- <Show40 when={p.msg.body}>
13050
+ <Show39 when={p.msg.body}>
13351
13051
  <p style={{ margin: "0", "white-space": "pre-wrap", "line-height": "1.5" }}>
13352
13052
  {p.msg.body}
13353
13053
  </p>
13354
- </Show40>
13355
- <For28 each={p.msg.attachments}>{(a) => <Attachment attachment={a} />}</For28>
13054
+ </Show39>
13055
+ <For27 each={p.msg.attachments}>{(a) => <Attachment attachment={a} />}</For27>
13356
13056
  </div>;
13357
13057
  };
13358
13058
  return <div>
13359
13059
  <PageTitle subtitle="Customer messages from the member portal">Support</PageTitle>
13360
13060
 
13361
13061
  <div style={{ display: "flex", gap: "0.5rem", "margin-bottom": "1rem", "flex-wrap": "wrap" }}>
13362
- <For28 each={STATUS_FILTERS3}>
13062
+ <For27 each={STATUS_FILTERS3}>
13363
13063
  {(f) => <button
13364
13064
  type="button"
13365
13065
  class={`app-admin-btn ${statusFilter() === f.value ? "app-admin-btn-primary" : "app-admin-btn-ghost"}`}
@@ -13370,23 +13070,23 @@ function Support(props = {}) {
13370
13070
  >
13371
13071
  {f.label}
13372
13072
  </button>}
13373
- </For28>
13073
+ </For27>
13374
13074
  </div>
13375
13075
 
13376
- <Show40 when={error()}>
13076
+ <Show39 when={error()}>
13377
13077
  <p class="app-admin-text-muted" role="alert" style={{ color: "var(--app-admin-danger-fg)" }}>
13378
13078
  {error()}
13379
13079
  </p>
13380
- </Show40>
13080
+ </Show39>
13381
13081
 
13382
13082
  <div style={{ display: "grid", "grid-template-columns": "minmax(0, 1fr) minmax(0, 1.6fr)", gap: "1rem" }}>
13383
13083
  {
13384
13084
  /* Queue */
13385
13085
  }
13386
13086
  <div class="app-admin-card" style={{ overflow: "hidden", padding: "0" }}>
13387
- <Show40 when={!threads.loading} fallback={<LoadingSpinner />}>
13388
- <Show40 when={(threads() ?? []).length > 0} fallback={<EmptyState message="No support threads." />}>
13389
- <For28 each={threads() ?? []}>
13087
+ <Show39 when={!threads.loading} fallback={<LoadingSpinner />}>
13088
+ <Show39 when={(threads() ?? []).length > 0} fallback={<EmptyState message="No support threads." />}>
13089
+ <For27 each={threads() ?? []}>
13390
13090
  {(t) => <button
13391
13091
  type="button"
13392
13092
  style={{
@@ -13413,37 +13113,37 @@ function Support(props = {}) {
13413
13113
  <StatusBadge status={t.status} />
13414
13114
  </div>
13415
13115
  </button>}
13416
- </For28>
13417
- </Show40>
13418
- </Show40>
13116
+ </For27>
13117
+ </Show39>
13118
+ </Show39>
13419
13119
  </div>
13420
13120
 
13421
13121
  {
13422
13122
  /* Transcript + reply */
13423
13123
  }
13424
13124
  <div class="app-admin-card" style={{ padding: "1.25rem" }}>
13425
- <Show40
13125
+ <Show39
13426
13126
  when={selectedId()}
13427
13127
  fallback={<EmptyState message="Select a thread to read and reply." />}
13428
13128
  >
13429
- <Show40 when={!detail.loading} fallback={<LoadingSpinner />}>
13430
- <Show40 when={detail()} fallback={<EmptyState message="Thread not found." />}>
13129
+ <Show39 when={!detail.loading} fallback={<LoadingSpinner />}>
13130
+ <Show39 when={detail()} fallback={<EmptyState message="Thread not found." />}>
13431
13131
  {(d) => <>
13432
13132
  <div style={{ display: "flex", "justify-content": "space-between", gap: "1rem", "align-items": "flex-start" }}>
13433
13133
  <div>
13434
13134
  <h3 style={{ margin: "0 0 0.25rem" }}>{d().thread.subject}</h3>
13435
13135
  <p class="app-admin-text-muted" style={{ margin: 0, "font-size": "0.8125rem" }}>
13436
13136
  {d().customer?.email ?? "Unknown customer"}
13437
- <Show40 when={nav && d().thread.userId}>
13137
+ <Show39 when={nav && d().thread.userId}>
13438
13138
  {" \xB7 "}
13439
13139
  <button type="button" class="app-admin-link-btn" onClick={() => nav.openCustomer(d().thread.userId)}>
13440
13140
  View customer
13441
13141
  </button>
13442
- </Show40>
13142
+ </Show39>
13443
13143
  </p>
13444
13144
  </div>
13445
13145
  <div style={{ display: "flex", gap: "0.375rem" }}>
13446
- <For28 each={STATUS_FILTERS3.filter((f) => f.value !== "all")}>
13146
+ <For27 each={STATUS_FILTERS3.filter((f) => f.value !== "all")}>
13447
13147
  {(f) => <button
13448
13148
  type="button"
13449
13149
  class={`app-admin-btn app-admin-btn-ghost${d().thread.status === f.value ? " is-active" : ""}`}
@@ -13453,7 +13153,7 @@ function Support(props = {}) {
13453
13153
  >
13454
13154
  {f.label}
13455
13155
  </button>}
13456
- </For28>
13156
+ </For27>
13457
13157
  </div>
13458
13158
  </div>
13459
13159
 
@@ -13468,7 +13168,7 @@ function Support(props = {}) {
13468
13168
  data-scrollable
13469
13169
  style={{ margin: "1rem 0", "max-height": "26rem", "overflow-y": "auto" }}
13470
13170
  >
13471
- <For28 each={d().messages}>{(m) => <Bubble msg={m} />}</For28>
13171
+ <For27 each={d().messages}>{(m) => <Bubble msg={m} />}</For27>
13472
13172
  <div ref={transcriptEnd.setEnd} />
13473
13173
  </div>
13474
13174
 
@@ -13515,7 +13215,7 @@ function Support(props = {}) {
13515
13215
  }}
13516
13216
  />
13517
13217
  </label>
13518
- <Show40 when={pendingFile()}>
13218
+ <Show39 when={pendingFile()}>
13519
13219
  {(f) => <span class="app-admin-text-muted" style={{ "font-size": "0.8125rem" }}>
13520
13220
  {f().name}
13521
13221
  <button
@@ -13527,20 +13227,20 @@ function Support(props = {}) {
13527
13227
  remove
13528
13228
  </button>
13529
13229
  </span>}
13530
- </Show40>
13230
+ </Show39>
13531
13231
  </div>
13532
13232
  </form>
13533
13233
  </>}
13534
- </Show40>
13535
- </Show40>
13536
- </Show40>
13234
+ </Show39>
13235
+ </Show39>
13236
+ </Show39>
13537
13237
  </div>
13538
13238
  </div>
13539
13239
  </div>;
13540
13240
  }
13541
13241
 
13542
13242
  // src/pages/admin/Webhooks.tsx
13543
- import { createResource as createResource18, createSignal as createSignal25, For as For29, Show as Show41 } from "solid-js";
13243
+ import { createResource as createResource18, createSignal as createSignal25, For as For28, Show as Show40 } from "solid-js";
13544
13244
  function Webhooks() {
13545
13245
  const [expanded, setExpanded] = createSignal25(null);
13546
13246
  const [webhooks] = createResource18(async () => {
@@ -13556,7 +13256,7 @@ function Webhooks() {
13556
13256
  };
13557
13257
  return <div>
13558
13258
  <PageTitle>Webhook Events</PageTitle>
13559
- <Show41 when={!webhooks.loading} fallback={<LoadingSpinner />}>
13259
+ <Show40 when={!webhooks.loading} fallback={<LoadingSpinner />}>
13560
13260
  <div class="app-admin-card" style={{ overflow: "hidden" }}>
13561
13261
  <table class="app-admin-table">
13562
13262
  <thead>
@@ -13569,7 +13269,7 @@ function Webhooks() {
13569
13269
  </tr>
13570
13270
  </thead>
13571
13271
  <tbody>
13572
- <For29 each={webhooks() ?? []}>
13272
+ <For28 each={webhooks() ?? []}>
13573
13273
  {(event) => <>
13574
13274
  <tr
13575
13275
  class="is-clickable"
@@ -13595,7 +13295,7 @@ function Webhooks() {
13595
13295
  </span>
13596
13296
  </td>
13597
13297
  </tr>
13598
- <Show41 when={expanded() === String(event.id)}>
13298
+ <Show40 when={expanded() === String(event.id)}>
13599
13299
  <tr>
13600
13300
  <td colspan="5">
13601
13301
  <pre
@@ -13621,21 +13321,21 @@ function Webhooks() {
13621
13321
  </pre>
13622
13322
  </td>
13623
13323
  </tr>
13624
- </Show41>
13324
+ </Show40>
13625
13325
  </>}
13626
- </For29>
13326
+ </For28>
13627
13327
  </tbody>
13628
13328
  </table>
13629
- <Show41 when={(webhooks() ?? []).length === 0}>
13329
+ <Show40 when={(webhooks() ?? []).length === 0}>
13630
13330
  <EmptyState message="No webhook events found." />
13631
- </Show41>
13331
+ </Show40>
13632
13332
  </div>
13633
- </Show41>
13333
+ </Show40>
13634
13334
  </div>;
13635
13335
  }
13636
13336
 
13637
13337
  // src/pages/admin/EmailTemplates.tsx
13638
- import { createSignal as createSignal26, createResource as createResource19, For as For30, Index, Show as Show42 } from "solid-js";
13338
+ import { createSignal as createSignal26, createResource as createResource19, For as For29, Index, Show as Show41 } from "solid-js";
13639
13339
  var CATEGORY_DEFS = [
13640
13340
  {
13641
13341
  label: "Subscription & Billing",
@@ -13836,8 +13536,8 @@ function EmailTemplates() {
13836
13536
  Email Templates
13837
13537
  </PageTitle>
13838
13538
 
13839
- <Show42 when={!templates.loading} fallback={<LoadingSpinner />}>
13840
- <Show42 when={templateKeys().length > 0} fallback={<div class="app-admin-empty">No email templates configured.</div>}>
13539
+ <Show41 when={!templates.loading} fallback={<LoadingSpinner />}>
13540
+ <Show41 when={templateKeys().length > 0} fallback={<div class="app-admin-empty">No email templates configured.</div>}>
13841
13541
  <div style={{ display: "flex", gap: "1.5rem", "align-items": "flex-start" }}>
13842
13542
  {
13843
13543
  /* Vertical template nav, grouped by category */
@@ -13855,7 +13555,7 @@ function EmailTemplates() {
13855
13555
  top: "1rem"
13856
13556
  }}
13857
13557
  >
13858
- <For30 each={categorizedKeys()}>
13558
+ <For29 each={categorizedKeys()}>
13859
13559
  {(group) => <div style={{ "margin-bottom": "0.25rem" }}>
13860
13560
  <button
13861
13561
  type="button"
@@ -13882,8 +13582,8 @@ function EmailTemplates() {
13882
13582
  {collapsed()[group.label] ? "\u25B8" : "\u25BE"}
13883
13583
  </span>
13884
13584
  </button>
13885
- <Show42 when={!collapsed()[group.label]}>
13886
- <For30 each={group.keys}>
13585
+ <Show41 when={!collapsed()[group.label]}>
13586
+ <For29 each={group.keys}>
13887
13587
  {(key) => <button
13888
13588
  type="button"
13889
13589
  onClick={() => handleTabSwitch(key)}
@@ -13904,22 +13604,22 @@ function EmailTemplates() {
13904
13604
  >
13905
13605
  {humanize(key)}
13906
13606
  </button>}
13907
- </For30>
13908
- </Show42>
13607
+ </For29>
13608
+ </Show41>
13909
13609
  </div>}
13910
- </For30>
13610
+ </For29>
13911
13611
  </div>
13912
13612
 
13913
13613
  {
13914
13614
  /* Edit form */
13915
13615
  }
13916
- <Show42 when={currentDraft()}>
13616
+ <Show41 when={currentDraft()}>
13917
13617
  {(cur) => <div class="app-admin-card" style={{ padding: "1.25rem", flex: 1, "min-width": 0 }}>
13918
13618
  <div style={{ display: "flex", "flex-direction": "column", gap: "1.25rem" }}>
13919
13619
  {
13920
13620
  /* Placeholder insert bar (per-template) */
13921
13621
  }
13922
- <Show42 when={activePlaceholders().length > 0}>
13622
+ <Show41 when={activePlaceholders().length > 0}>
13923
13623
  <div
13924
13624
  style={{
13925
13625
  padding: "0.75rem 0.875rem",
@@ -13935,7 +13635,7 @@ function EmailTemplates() {
13935
13635
  </span>
13936
13636
  </p>
13937
13637
  <div style={{ display: "flex", "flex-wrap": "wrap", gap: "0.375rem" }}>
13938
- <For30 each={activePlaceholders()}>
13638
+ <For29 each={activePlaceholders()}>
13939
13639
  {(p) => <button
13940
13640
  type="button"
13941
13641
  title={p.description}
@@ -13954,10 +13654,10 @@ function EmailTemplates() {
13954
13654
  >
13955
13655
  {p.token}
13956
13656
  </button>}
13957
- </For30>
13657
+ </For29>
13958
13658
  </div>
13959
13659
  </div>
13960
- </Show42>
13660
+ </Show41>
13961
13661
 
13962
13662
  {
13963
13663
  /* Subject */
@@ -14009,7 +13709,7 @@ function EmailTemplates() {
14009
13709
  class="app-admin-input"
14010
13710
  style={{ flex: 1, resize: "vertical" }}
14011
13711
  />
14012
- <Show42 when={cur().bodyParagraphs.length > 1}>
13712
+ <Show41 when={cur().bodyParagraphs.length > 1}>
14013
13713
  <button
14014
13714
  type="button"
14015
13715
  onClick={() => removeParagraph(i)}
@@ -14026,11 +13726,11 @@ function EmailTemplates() {
14026
13726
  >
14027
13727
  &times;
14028
13728
  </button>
14029
- </Show42>
13729
+ </Show41>
14030
13730
  </div>}
14031
13731
  </Index>
14032
13732
  </div>
14033
- <Show42 when={cur().bodyParagraphs.length < 10}>
13733
+ <Show41 when={cur().bodyParagraphs.length < 10}>
14034
13734
  <button
14035
13735
  type="button"
14036
13736
  onClick={addParagraph}
@@ -14046,7 +13746,7 @@ function EmailTemplates() {
14046
13746
  >
14047
13747
  + Add Paragraph
14048
13748
  </button>
14049
- </Show42>
13749
+ </Show41>
14050
13750
  </div>
14051
13751
 
14052
13752
  {
@@ -14107,15 +13807,20 @@ function EmailTemplates() {
14107
13807
  </div>
14108
13808
  </div>
14109
13809
  </div>}
14110
- </Show42>
13810
+ </Show41>
14111
13811
  </div>
14112
- </Show42>
14113
- </Show42>
13812
+ </Show41>
13813
+ </Show41>
14114
13814
  </div>;
14115
13815
  }
14116
13816
 
14117
13817
  // src/pages/admin/Funnel.tsx
14118
- import { createResource as createResource20, createSignal as createSignal27, For as For31, Show as Show43 } from "solid-js";
13818
+ import { createResource as createResource20, createSignal as createSignal27, For as For30, Show as Show42 } from "solid-js";
13819
+ var MODE_HELP = {
13820
+ off: "Nothing is sent and nothing is queued.",
13821
+ review: 'The schedule decides who is due; nothing leaves until you send it. Due reminders appear under "Waiting for approval" below.',
13822
+ auto: "Reminders send by themselves, hourly, with no further review."
13823
+ };
14119
13824
  function pct(n, d) {
14120
13825
  if (!d) return "\u2014";
14121
13826
  return `${Math.round(n / d * 100)}%`;
@@ -14145,11 +13850,11 @@ function StatCard(props) {
14145
13850
  function CardHeader(props) {
14146
13851
  return <div style={{ padding: "1rem 1.25rem", "border-bottom": "1px solid var(--app-admin-border-soft)" }}>
14147
13852
  <h2 class="app-admin-heading" style={{ "font-size": "0.9375rem", "font-weight": "600", margin: 0 }}>{props.title}</h2>
14148
- <Show43 when={props.note}>
13853
+ <Show42 when={props.note}>
14149
13854
  <p style={{ "font-size": "0.75rem", color: "var(--app-admin-fg-muted)", margin: "0.25rem 0 0" }}>
14150
13855
  {props.note}
14151
13856
  </p>
14152
- </Show43>
13857
+ </Show42>
14153
13858
  </div>;
14154
13859
  }
14155
13860
  function RecoverySettingsCard() {
@@ -14186,7 +13891,7 @@ function RecoverySettingsCard() {
14186
13891
  try {
14187
13892
  await apiFetch("/admin/settings/funnel-recovery", {
14188
13893
  method: "PUT",
14189
- body: JSON.stringify({ enabled: s.enabled, stagesHours, incompleteStagesHours })
13894
+ body: JSON.stringify({ mode: s.mode, stagesHours, incompleteStagesHours })
14190
13895
  });
14191
13896
  const sorted = {
14192
13897
  ...s,
@@ -14205,19 +13910,28 @@ function RecoverySettingsCard() {
14205
13910
  };
14206
13911
  return <div class="app-admin-card" style={{ "margin-top": "1.25rem" }}>
14207
13912
  <CardHeader title="Recovery email settings" />
14208
- <Show43
13913
+ <Show42
14209
13914
  when={!unavailable()}
14210
13915
  fallback={<EmptyState message="Settings endpoint unavailable — backend update not deployed yet." />}
14211
13916
  >
14212
- <Show43 when={settings()} fallback={<LoadingSpinner />}>
13917
+ <Show42 when={settings()} fallback={<LoadingSpinner />}>
14213
13918
  {(s) => <div style={{ padding: "1rem 1.25rem", display: "grid", gap: "0.875rem", "max-width": "34rem" }}>
14214
- <label style={{ display: "flex", "align-items": "center", gap: "0.625rem", cursor: "pointer" }}>
14215
- <input
14216
- type="checkbox"
14217
- checked={s().enabled}
14218
- onChange={(e) => setSettings({ ...s(), enabled: e.currentTarget.checked })}
14219
- />
14220
- <span>Send recovery emails</span>
13919
+ <label style={{ display: "grid", gap: "0.25rem" }}>
13920
+ <span style={{ "font-size": "0.8125rem", color: "var(--app-admin-fg-muted)" }}>
13921
+ How reminders go out
13922
+ </span>
13923
+ <select
13924
+ class="app-admin-input"
13925
+ value={s().mode}
13926
+ onChange={(e) => setSettings({ ...s(), mode: e.currentTarget.value })}
13927
+ >
13928
+ <option value="off">Off — send nothing</option>
13929
+ <option value="review">Review — hold for approval, I send them</option>
13930
+ <option value="auto">Automatic — send on the schedule below</option>
13931
+ </select>
13932
+ <span style={{ "font-size": "0.75rem", color: "var(--app-admin-fg-muted)" }}>
13933
+ {MODE_HELP[s().mode]}
13934
+ </span>
14221
13935
  </label>
14222
13936
  <label style={{ display: "grid", gap: "0.25rem" }}>
14223
13937
  <span style={{ "font-size": "0.8125rem", color: "var(--app-admin-fg-muted)" }}>
@@ -14243,12 +13957,12 @@ function RecoverySettingsCard() {
14243
13957
  placeholder="4, 48"
14244
13958
  />
14245
13959
  </label>
14246
- <Show43 when={error()}>
13960
+ <Show42 when={error()}>
14247
13961
  <p style={{ color: "var(--app-admin-danger-fg)", "font-size": "0.8125rem", margin: 0 }}>{error()}</p>
14248
- </Show43>
14249
- <Show43 when={status()}>
13962
+ </Show42>
13963
+ <Show42 when={status()}>
14250
13964
  <p style={{ color: "var(--app-admin-success-fg)", "font-size": "0.8125rem", margin: 0 }}>{status()}</p>
14251
- </Show43>
13965
+ </Show42>
14252
13966
  <div>
14253
13967
  <button
14254
13968
  type="button"
@@ -14260,10 +13974,123 @@ function RecoverySettingsCard() {
14260
13974
  </button>
14261
13975
  </div>
14262
13976
  </div>}
14263
- </Show43>
14264
- </Show43>
13977
+ </Show42>
13978
+ </Show42>
14265
13979
  </div>;
14266
13980
  }
13981
+ function RecoveryQueue() {
13982
+ const [reload, setReload] = createSignal27(0);
13983
+ const [busy, setBusy] = createSignal27(null);
13984
+ const [error, setError] = createSignal27(null);
13985
+ const [done, setDone] = createSignal27({});
13986
+ const [queue, { refetch }] = createResource20(
13987
+ reload,
13988
+ () => apiFetch(
13989
+ "/admin/funnel/recovery-queue"
13990
+ ).catch(() => null)
13991
+ );
13992
+ const key = (c) => `${c.kind}:${c.id}`;
13993
+ const act = async (c, action) => {
13994
+ setBusy(key(c));
13995
+ setError(null);
13996
+ try {
13997
+ await apiFetch(`/admin/funnel/recovery-queue/${action}`, {
13998
+ method: "POST",
13999
+ body: JSON.stringify({ kind: c.kind, id: c.id })
14000
+ });
14001
+ setDone({ ...done(), [key(c)]: action });
14002
+ void refetch();
14003
+ } catch (e) {
14004
+ setError(e.message);
14005
+ } finally {
14006
+ setBusy(null);
14007
+ }
14008
+ };
14009
+ const label = (c) => c.kind === "capture" ? "Finished the questionnaire, never signed up" : c.lastStep != null && c.stepCount ? `Stopped at step ${c.lastStep + 1} of ${c.stepCount}` : "Started the questionnaire, never finished";
14010
+ return <Show42 when={queue()?.mode === "review"}>
14011
+ <div class="app-admin-card" style={{ "margin-top": "1.25rem" }}>
14012
+ <CardHeader
14013
+ title="Waiting for approval"
14014
+ note="Due by the schedule below. Nothing here has been emailed, and nothing will be until you send it."
14015
+ />
14016
+ <Show42 when={error()}>
14017
+ <p style={{ color: "var(--app-admin-danger-fg)", "font-size": "0.8125rem", padding: "0 1.25rem" }}>
14018
+ {error()}
14019
+ </p>
14020
+ </Show42>
14021
+ <Show42
14022
+ when={(queue()?.candidates.length ?? 0) > 0}
14023
+ fallback={<EmptyState message="Nobody is due a reminder right now." />}
14024
+ >
14025
+ <table class="app-admin-table">
14026
+ <thead>
14027
+ <tr><th>Person</th><th>Where they stopped</th><th>Waiting</th><th>Reminder</th><th /></tr>
14028
+ </thead>
14029
+ <tbody>
14030
+ <For30 each={queue().candidates}>
14031
+ {(c) => <tr>
14032
+ <td data-label="Person">
14033
+ <div>{c.name || c.email}</div>
14034
+ <Show42 when={c.name}>
14035
+ <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{c.email}</div>
14036
+ </Show42>
14037
+ </td>
14038
+ <td data-label="Where they stopped">{label(c)}</td>
14039
+ <td data-label="Waiting">{daysAgo(c.lastActivityAt)}</td>
14040
+ <td data-label="Reminder">{c.stage + 1} of {c.totalStages}</td>
14041
+ <td>
14042
+ <Show42
14043
+ when={!done()[key(c)]}
14044
+ fallback={<span class="app-admin-text-muted">{DONE_LABEL[done()[key(c)]]}</span>}
14045
+ >
14046
+ <div style={{ display: "flex", gap: "0.375rem", "flex-wrap": "wrap" }}>
14047
+ <button
14048
+ type="button"
14049
+ class="app-admin-btn app-admin-btn--primary"
14050
+ disabled={busy() === key(c)}
14051
+ onClick={() => void act(c, "send")}
14052
+ >
14053
+ {busy() === key(c) ? "Sending\u2026" : "Send"}
14054
+ </button>
14055
+ <button
14056
+ type="button"
14057
+ class="app-admin-btn"
14058
+ disabled={busy() === key(c)}
14059
+ onClick={() => void act(c, "skip")}
14060
+ title="Move past this reminder without emailing. They stay in the funnel for the next one."
14061
+ >
14062
+ Skip
14063
+ </button>
14064
+ <button
14065
+ type="button"
14066
+ class="app-admin-btn"
14067
+ disabled={busy() === key(c)}
14068
+ onClick={() => void act(c, "suppress")}
14069
+ title="Never contact this person about their visit again."
14070
+ >
14071
+ Don't contact
14072
+ </button>
14073
+ </div>
14074
+ </Show42>
14075
+ </td>
14076
+ </tr>}
14077
+ </For30>
14078
+ </tbody>
14079
+ </table>
14080
+ </Show42>
14081
+ </div>
14082
+ </Show42>;
14083
+ }
14084
+ var DONE_LABEL = {
14085
+ send: "Sent",
14086
+ skip: "Skipped",
14087
+ suppress: "Suppressed"
14088
+ };
14089
+ function daysAgo(iso) {
14090
+ const days = Math.floor((Date.now() - new Date(iso).getTime()) / 864e5);
14091
+ if (days < 1) return "today";
14092
+ return days === 1 ? "1 day" : `${days} days`;
14093
+ }
14267
14094
  function Funnel() {
14268
14095
  const [days, setDays] = createSignal27(30);
14269
14096
  const [summary] = createResource20(
@@ -14307,7 +14134,7 @@ function Funnel() {
14307
14134
  </select>
14308
14135
  </div>
14309
14136
 
14310
- <Show43 when={summary()} fallback={<LoadingSpinner />}>
14137
+ <Show42 when={summary()} fallback={<LoadingSpinner />}>
14311
14138
  {(s) => <>
14312
14139
  <div
14313
14140
  style={{
@@ -14326,7 +14153,7 @@ function Funnel() {
14326
14153
  <div class="app-admin-card" style={{ "margin-top": "1.25rem" }}>
14327
14154
  <CardHeader title="Funnel stages" />
14328
14155
  <div style={{ padding: "1rem 1.25rem", display: "grid", gap: "0.625rem" }}>
14329
- <For31 each={stages()}>
14156
+ <For30 each={stages()}>
14330
14157
  {(stage, i) => <div
14331
14158
  style={{
14332
14159
  display: "grid",
@@ -14357,7 +14184,7 @@ function Funnel() {
14357
14184
  </span>
14358
14185
  </span>
14359
14186
  </div>}
14360
- </For31>
14187
+ </For30>
14361
14188
  </div>
14362
14189
  </div>
14363
14190
 
@@ -14367,7 +14194,7 @@ function Funnel() {
14367
14194
  note={"Survey progress at last activity \u2014 the final bucket is the contact-info step. Leaving the page counts immediately; a silently-dropped session counts after 4 quiet hours." + (s().sessions.active > 0 ? ` ${s().sessions.active} session${s().sessions.active === 1 ? "" : "s"} still in progress \u2014 not counted yet.` : "")}
14368
14195
  />
14369
14196
  <div style={{ padding: "1.25rem", display: "flex", "align-items": "flex-end", gap: "0.375rem", height: "9rem" }}>
14370
- <For31 each={s().stepDropoff}>
14197
+ <For30 each={s().stepDropoff}>
14371
14198
  {(b) => <div
14372
14199
  style={{
14373
14200
  flex: 1,
@@ -14380,9 +14207,9 @@ function Funnel() {
14380
14207
  }}
14381
14208
  title={`${b.bucket * 10}% through: ${b.count} abandon${b.count === 1 ? "" : "s"}`}
14382
14209
  >
14383
- <Show43 when={b.count > 0}>
14210
+ <Show42 when={b.count > 0}>
14384
14211
  <span style={{ "font-size": "0.6875rem", color: "var(--app-admin-fg-muted)" }}>{b.count}</span>
14385
- </Show43>
14212
+ </Show42>
14386
14213
  <div
14387
14214
  style={{
14388
14215
  width: "100%",
@@ -14396,7 +14223,7 @@ function Funnel() {
14396
14223
  {b.bucket === 0 ? "Start" : b.bucket === 10 ? "Info" : b.bucket === 5 ? "50%" : ""}
14397
14224
  </span>
14398
14225
  </div>}
14399
- </For31>
14226
+ </For30>
14400
14227
  </div>
14401
14228
  </div>
14402
14229
 
@@ -14425,8 +14252,9 @@ function Funnel() {
14425
14252
  </table>
14426
14253
  </div>
14427
14254
  </>}
14428
- </Show43>
14255
+ </Show42>
14429
14256
 
14257
+ <RecoveryQueue />
14430
14258
  <RecoverySettingsCard />
14431
14259
 
14432
14260
  <div class="app-admin-card" style={{ "margin-top": "1.25rem", overflow: "hidden" }}>
@@ -14436,11 +14264,11 @@ function Funnel() {
14436
14264
  <tr><th>Last seen</th><th>Progress</th><th>Email</th><th>Reminders</th></tr>
14437
14265
  </thead>
14438
14266
  <tbody>
14439
- <Show43
14267
+ <Show42
14440
14268
  when={(abandons()?.sessions ?? []).length > 0}
14441
14269
  fallback={<tr><td colSpan={4}><EmptyState message="No abandoned sessions" /></td></tr>}
14442
14270
  >
14443
- <For31 each={abandons()?.sessions}>
14271
+ <For30 each={abandons()?.sessions}>
14444
14272
  {(sess) => <tr>
14445
14273
  <td data-label="Last seen" class="app-admin-text-muted">{formatDate(sess.last_seen_at)}</td>
14446
14274
  <td data-label="Progress">
@@ -14451,8 +14279,8 @@ function Funnel() {
14451
14279
  </td>
14452
14280
  <td data-label="Reminders">{sess.reminders_sent}</td>
14453
14281
  </tr>}
14454
- </For31>
14455
- </Show43>
14282
+ </For30>
14283
+ </Show42>
14456
14284
  </tbody>
14457
14285
  </table>
14458
14286
  </div>
@@ -14464,11 +14292,11 @@ function Funnel() {
14464
14292
  <tr><th>Captured</th><th>Name</th><th>Email</th><th>Qualified</th><th>Reminders</th></tr>
14465
14293
  </thead>
14466
14294
  <tbody>
14467
- <Show43
14295
+ <Show42
14468
14296
  when={(leads()?.captures ?? []).length > 0}
14469
14297
  fallback={<tr><td colSpan={5}><EmptyState message="No unconverted captures" /></td></tr>}
14470
14298
  >
14471
- <For31 each={leads()?.captures}>
14299
+ <For30 each={leads()?.captures}>
14472
14300
  {(c) => <tr>
14473
14301
  <td data-label="Captured" class="app-admin-text-muted">{formatDate(c.captured_at)}</td>
14474
14302
  <td data-label="Name">{c.patient_name ?? "\u2014"}</td>
@@ -14476,8 +14304,8 @@ function Funnel() {
14476
14304
  <td data-label="Qualified">{c.qualified ? "Yes" : "No"}</td>
14477
14305
  <td data-label="Reminders">{c.reminders_sent}</td>
14478
14306
  </tr>}
14479
- </For31>
14480
- </Show43>
14307
+ </For30>
14308
+ </Show42>
14481
14309
  </tbody>
14482
14310
  </table>
14483
14311
  </div>
@@ -14587,15 +14415,15 @@ function AdminDashboard(props) {
14587
14415
  color: currentTab() === btnProps.tab ? "var(--app-admin-primary-soft-fg)" : "var(--app-admin-fg-muted)"
14588
14416
  }}
14589
14417
  >
14590
- <Show44 when={props.tabIcons?.[btnProps.tab]}>
14418
+ <Show43 when={props.tabIcons?.[btnProps.tab]}>
14591
14419
  <span
14592
14420
  class={props.tabIcons[btnProps.tab]}
14593
14421
  style={{ "font-size": "1rem", opacity: 0.7, "flex-shrink": 0 }}
14594
14422
  />
14595
- </Show44>
14423
+ </Show43>
14596
14424
  {TAB_LABELS[btnProps.tab]}
14597
14425
  </button>;
14598
- return <Show44 when={adminAllowed()} fallback={<AdminGateSpinner topOffset={props.topOffset ?? "0px"} />}>
14426
+ return <Show43 when={adminAllowed()} fallback={<AdminGateSpinner topOffset={props.topOffset ?? "0px"} />}>
14599
14427
  <AdminNavContext.Provider value={adminNav}>
14600
14428
  <div
14601
14429
  class="app-admin-root app-admin-shell"
@@ -14635,178 +14463,465 @@ function AdminDashboard(props) {
14635
14463
  "font-size": "0.7rem",
14636
14464
  "font-weight": "500",
14637
14465
  color: "var(--app-admin-fg-muted)",
14638
- "text-transform": "uppercase",
14639
- "letter-spacing": "0.08em",
14640
- margin: "0 0 1rem"
14466
+ "text-transform": "uppercase",
14467
+ "letter-spacing": "0.08em",
14468
+ margin: "0 0 1rem"
14469
+ }}
14470
+ >
14471
+ Admin Panel
14472
+ </h2>
14473
+ <nav style={{ display: "flex", "flex-direction": "column", gap: "0.25rem" }}>
14474
+ <For31 each={visibleTopTabs()}>{(tab) => <TabButton tab={tab} />}</For31>
14475
+ <For31 each={visibleGroups()}>
14476
+ {(group) => <>
14477
+ <h3
14478
+ style={{
14479
+ "font-size": "0.625rem",
14480
+ "font-weight": "600",
14481
+ color: "var(--app-admin-fg-muted)",
14482
+ "text-transform": "uppercase",
14483
+ "letter-spacing": "0.08em",
14484
+ margin: "1rem 0 0.375rem",
14485
+ padding: "0 0.75rem"
14486
+ }}
14487
+ >
14488
+ {group.label}
14489
+ </h3>
14490
+ <For31 each={group.tabs}>{(tab) => <TabButton tab={tab} />}</For31>
14491
+ </>}
14492
+ </For31>
14493
+ </nav>
14494
+ </div>
14495
+ </aside>
14496
+
14497
+ <div class="app-admin-content">
14498
+ {
14499
+ /* Key the boundary to the active tab so a render error in one tab shows
14500
+ a recoverable fallback instead of tearing down the whole dashboard
14501
+ (which would wedge the sidebar nav), and switching tabs mounts a fresh
14502
+ boundary that clears a prior tab's error. */
14503
+ }
14504
+ <Show43 when={currentTab()} keyed>
14505
+ <ErrorBoundary fallback={(err, reset) => <AdminTabError error={err} reset={reset} />}>
14506
+ <Switch2 fallback={<Dashboard onSelectTab={handleTabClick} isTabEnabled={isTabEnabled} />}>
14507
+ <Match2 when={currentTab() === "dashboard"}>
14508
+ <Dashboard onSelectTab={handleTabClick} isTabEnabled={isTabEnabled} />
14509
+ </Match2>
14510
+ <Match2 when={currentTab() === "customers"}>
14511
+ <Customers
14512
+ passwordResetRedirectUrl={props.passwordResetRedirectUrl}
14513
+ activeUid={props.customers?.activeUid}
14514
+ onSelectCustomer={props.customers?.onSelectCustomer}
14515
+ initialUid={pendingCustomerUid()}
14516
+ />
14517
+ </Match2>
14518
+ <Match2 when={currentTab() === "payments"}>
14519
+ <Payments />
14520
+ </Match2>
14521
+ <Match2 when={currentTab() === "subscriptions"}>
14522
+ {
14523
+ /* Retired tab alias: the customer list, filtered to active subscribers. */
14524
+ }
14525
+ <Customers
14526
+ passwordResetRedirectUrl={props.passwordResetRedirectUrl}
14527
+ initialFilter="active"
14528
+ activeUid={props.customers?.activeUid}
14529
+ onSelectCustomer={props.customers?.onSelectCustomer}
14530
+ />
14531
+ </Match2>
14532
+ <Match2 when={currentTab() === "products"}>
14533
+ <Products productDefaultsLookup={props.productDefaultsLookup} />
14534
+ </Match2>
14535
+ <Match2 when={currentTab() === "categories"}>
14536
+ <Categories />
14537
+ </Match2>
14538
+ <Match2 when={currentTab() === "sales"}>
14539
+ <Sales />
14540
+ </Match2>
14541
+ <Match2 when={currentTab() === "promo-codes"}>
14542
+ <PromoCodes affiliatesEnabled={affiliatesEnabled()} />
14543
+ </Match2>
14544
+ <Match2 when={currentTab() === "affiliates"}>
14545
+ <Affiliates {...props.affiliates ?? {}} />
14546
+ </Match2>
14547
+ <Match2 when={currentTab() === "support"}>
14548
+ <Support initialThreadId={pendingThreadId()} />
14549
+ </Match2>
14550
+ <Match2 when={currentTab() === "webhooks"}>
14551
+ <Webhooks />
14552
+ </Match2>
14553
+ <Match2 when={currentTab() === "email-templates"}>
14554
+ <EmailTemplates />
14555
+ </Match2>
14556
+ <Match2 when={currentTab() === "funnel"}>
14557
+ <Funnel />
14558
+ </Match2>
14559
+ </Switch2>
14560
+ </ErrorBoundary>
14561
+ </Show43>
14562
+ </div>
14563
+ </div>
14564
+ </AdminNavContext.Provider>
14565
+ </Show43>;
14566
+ }
14567
+ function AdminTabError(props) {
14568
+ console.error("[AdminDashboard] tab failed to render:", props.error);
14569
+ const message = () => props.error instanceof Error ? props.error.message : String(props.error);
14570
+ return <div
14571
+ role="alert"
14572
+ style={{
14573
+ margin: "1rem 0",
14574
+ padding: "1.25rem 1.5rem",
14575
+ border: "1px solid var(--app-admin-border)",
14576
+ "border-radius": "var(--app-admin-radius-sm)",
14577
+ background: "var(--app-admin-surface)",
14578
+ color: "var(--app-admin-fg)"
14579
+ }}
14580
+ >
14581
+ <div style={{ "font-weight": "600", "margin-bottom": "0.375rem" }}>
14582
+ This section failed to load
14583
+ </div>
14584
+ <div
14585
+ style={{
14586
+ "font-size": "0.875rem",
14587
+ color: "var(--app-admin-fg-muted)",
14588
+ "margin-bottom": "1rem",
14589
+ "word-break": "break-word"
14590
+ }}
14591
+ >
14592
+ {message()}
14593
+ </div>
14594
+ <button
14595
+ type="button"
14596
+ onClick={() => props.reset()}
14597
+ style={{
14598
+ padding: "0.5rem 0.875rem",
14599
+ "border-radius": "var(--app-admin-radius-sm)",
14600
+ border: "1px solid var(--app-admin-border)",
14601
+ background: "var(--app-admin-primary-soft)",
14602
+ color: "var(--app-admin-primary-soft-fg)",
14603
+ "font-size": "0.875rem",
14604
+ "font-weight": "500",
14605
+ cursor: "pointer"
14606
+ }}
14607
+ >
14608
+ Try again
14609
+ </button>
14610
+ </div>;
14611
+ }
14612
+ function AdminGateSpinner(props) {
14613
+ return <div
14614
+ class="app-admin-root"
14615
+ style={{
14616
+ display: "flex",
14617
+ "align-items": "center",
14618
+ "justify-content": "center",
14619
+ position: "sticky",
14620
+ top: props.topOffset,
14621
+ height: `calc(100vh - ${props.topOffset})`,
14622
+ background: "var(--app-admin-bg)"
14623
+ }}
14624
+ >
14625
+ <div
14626
+ role="status"
14627
+ aria-label="Loading admin"
14628
+ style={{
14629
+ width: "1.75rem",
14630
+ height: "1.75rem",
14631
+ "border-radius": "9999px",
14632
+ border: "2px solid var(--app-admin-border)",
14633
+ "border-top-color": "var(--app-admin-primary)",
14634
+ animation: "app-admin-gate-spin 0.8s linear infinite"
14635
+ }}
14636
+ />
14637
+ <style>{`@keyframes app-admin-gate-spin { to { transform: rotate(360deg); } }`}</style>
14638
+ </div>;
14639
+ }
14640
+
14641
+ // src/pages/admin/PatientDashboardPreview.tsx
14642
+ import { Show as Show44, For as For32 } from "solid-js";
14643
+ function PatientDashboardPreview(props) {
14644
+ const data = useDashboardData({ authToken: () => props.token });
14645
+ return <div
14646
+ class="app-admin-modal-backdrop"
14647
+ onClick={(e) => {
14648
+ if (e.target === e.currentTarget) props.onClose();
14649
+ }}
14650
+ >
14651
+ <div class="app-admin-card app-admin-modal" style={{ "max-width": "32rem" }}>
14652
+ <div class="app-admin-modal-header">
14653
+ <h3 class="app-admin-heading" style={{ "font-size": "1rem", margin: 0 }}>
14654
+ Customer dashboard preview
14655
+ </h3>
14656
+ <button
14657
+ type="button"
14658
+ onClick={props.onClose}
14659
+ class="app-admin-btn app-admin-btn-ghost"
14660
+ style={{ border: "none", padding: "0.25rem 0.5rem", "font-size": "1.25rem" }}
14661
+ >
14662
+ ×
14663
+ </button>
14664
+ </div>
14665
+
14666
+ <div class="app-admin-modal-body">
14667
+ <div
14668
+ style={{
14669
+ padding: "0.5rem 0.75rem",
14670
+ "border-radius": "var(--app-admin-radius-sm)",
14671
+ background: "var(--app-admin-warning-bg)",
14672
+ color: "var(--app-admin-warning-fg)",
14673
+ "font-size": "0.75rem",
14674
+ "font-weight": "500"
14675
+ }}
14676
+ >
14677
+ Viewing as {props.customerName || "customer"} — read-only
14678
+ </div>
14679
+
14680
+ {
14681
+ /* A failed read is an error with a retry — never presented as an
14682
+ empty dashboard (the customer may have plenty of data). */
14683
+ }
14684
+ <Show44 when={data.error()} keyed>
14685
+ {(msg) => <div
14686
+ style={{
14687
+ display: "flex",
14688
+ "align-items": "center",
14689
+ "justify-content": "space-between",
14690
+ gap: "0.75rem",
14691
+ padding: "0.5rem 0.75rem",
14692
+ "border-radius": "var(--app-admin-radius-sm)",
14693
+ background: "var(--app-admin-danger-bg)",
14694
+ color: "var(--app-admin-danger-fg)",
14695
+ "font-size": "0.75rem",
14696
+ "font-weight": "500"
14697
+ }}
14698
+ >
14699
+ <span>{msg}</span>
14700
+ <button
14701
+ type="button"
14702
+ class="app-admin-btn app-admin-btn-ghost"
14703
+ style={{ padding: "0.25rem 0.75rem" }}
14704
+ onClick={() => data.retry()}
14705
+ >
14706
+ Retry
14707
+ </button>
14708
+ </div>}
14709
+ </Show44>
14710
+
14711
+ <Show44 when={!data.profile.loading} fallback={<LoadingSpinner />}>
14712
+ <Show44
14713
+ when={data.profile()}
14714
+ fallback={<p style={{ color: "var(--app-admin-fg-muted)", "font-size": "0.875rem" }}>
14715
+ Could not load this customer's dashboard.
14716
+ </p>}
14717
+ >
14718
+ {(profile) => <>
14719
+ {
14720
+ /* Profile */
14721
+ }
14722
+ <div>
14723
+ <h3 style={panelSectionHeader}>Profile</h3>
14724
+ <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
14725
+ <p style={{ "font-weight": "600", "font-size": "0.9375rem", margin: 0 }}>
14726
+ {[profile().firstName, profile().lastName].filter(Boolean).join(" ") || "Member"}
14727
+ </p>
14728
+ <p
14729
+ style={{
14730
+ "font-size": "0.8125rem",
14731
+ color: "var(--app-admin-fg-muted)",
14732
+ margin: "0.25rem 0 0"
14733
+ }}
14734
+ >
14735
+ {profile().email}
14736
+ </p>
14737
+ </div>
14738
+ </div>
14739
+
14740
+ {
14741
+ /* Subscription */
14742
+ }
14743
+ <div>
14744
+ <h3 style={panelSectionHeader}>Subscription</h3>
14745
+ <Show44
14746
+ when={data.subscription()}
14747
+ fallback={<p
14748
+ style={{
14749
+ color: "var(--app-admin-fg-muted)",
14750
+ "font-size": "0.875rem"
14751
+ }}
14752
+ >
14753
+ No active subscription.
14754
+ </p>}
14755
+ >
14756
+ {(sub) => <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
14757
+ <div
14758
+ style={{
14759
+ display: "flex",
14760
+ "align-items": "center",
14761
+ "justify-content": "space-between"
14762
+ }}
14763
+ >
14764
+ <span style={{ "font-size": "0.875rem", "font-weight": "500" }}>
14765
+ <Show44 when={sub().amount != null} fallback="Subscription">
14766
+ {centsToUsd(sub().amount)}/mo
14767
+ </Show44>
14768
+ </span>
14769
+ <StatusBadge status={sub().status} />
14770
+ </div>
14771
+ <Show44 when={sub().nextBillingDate}>
14772
+ <p
14773
+ style={{
14774
+ "font-size": "0.75rem",
14775
+ color: "var(--app-admin-fg-muted)",
14776
+ margin: "0.25rem 0 0"
14641
14777
  }}
14642
14778
  >
14643
- Admin Panel
14644
- </h2>
14645
- <nav style={{ display: "flex", "flex-direction": "column", gap: "0.25rem" }}>
14646
- <For32 each={visibleTopTabs()}>{(tab) => <TabButton tab={tab} />}</For32>
14647
- <For32 each={visibleGroups()}>
14648
- {(group) => <>
14649
- <h3
14779
+ Next charge {fmtDate(sub().nextBillingDate)}
14780
+ </p>
14781
+ </Show44>
14782
+ </div>}
14783
+ </Show44>
14784
+ </div>
14785
+
14786
+ {
14787
+ /* Prescription status */
14788
+ }
14789
+ <Show44 when={data.rxStatus()}>
14790
+ {(rx) => <div>
14791
+ <h3 style={panelSectionHeader}>Prescription status</h3>
14792
+ <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
14793
+ <div
14650
14794
  style={{
14651
- "font-size": "0.625rem",
14652
- "font-weight": "600",
14795
+ display: "flex",
14796
+ "align-items": "center",
14797
+ "justify-content": "space-between"
14798
+ }}
14799
+ >
14800
+ <span style={{ "font-size": "0.875rem", "font-weight": "500" }}>
14801
+ Current request
14802
+ </span>
14803
+ <StatusBadge status={rx().status} />
14804
+ </div>
14805
+ <Show44 when={rx().reason}>
14806
+ <p
14807
+ style={{
14808
+ "font-size": "0.75rem",
14653
14809
  color: "var(--app-admin-fg-muted)",
14654
- "text-transform": "uppercase",
14655
- "letter-spacing": "0.08em",
14656
- margin: "1rem 0 0.375rem",
14657
- padding: "0 0.75rem"
14810
+ margin: "0.25rem 0 0"
14658
14811
  }}
14659
14812
  >
14660
- {group.label}
14661
- </h3>
14662
- <For32 each={group.tabs}>{(tab) => <TabButton tab={tab} />}</For32>
14663
- </>}
14664
- </For32>
14665
- </nav>
14666
- </div>
14667
- </aside>
14813
+ {rx().reason}
14814
+ </p>
14815
+ </Show44>
14816
+ </div>
14817
+ </div>}
14818
+ </Show44>
14668
14819
 
14669
- <div class="app-admin-content">
14670
- {
14671
- /* Key the boundary to the active tab so a render error in one tab shows
14672
- a recoverable fallback instead of tearing down the whole dashboard
14673
- (which would wedge the sidebar nav), and switching tabs mounts a fresh
14674
- boundary that clears a prior tab's error. */
14675
- }
14676
- <Show44 when={currentTab()} keyed>
14677
- <ErrorBoundary fallback={(err, reset) => <AdminTabError error={err} reset={reset} />}>
14678
- <Switch2 fallback={<Dashboard onSelectTab={handleTabClick} isTabEnabled={isTabEnabled} />}>
14679
- <Match2 when={currentTab() === "dashboard"}>
14680
- <Dashboard onSelectTab={handleTabClick} isTabEnabled={isTabEnabled} />
14681
- </Match2>
14682
- <Match2 when={currentTab() === "customers"}>
14683
- <Customers
14684
- passwordResetRedirectUrl={props.passwordResetRedirectUrl}
14685
- activeUid={props.customers?.activeUid}
14686
- onSelectCustomer={props.customers?.onSelectCustomer}
14687
- initialUid={pendingCustomerUid()}
14688
- />
14689
- </Match2>
14690
- <Match2 when={currentTab() === "payments"}>
14691
- <Payments />
14692
- </Match2>
14693
- <Match2 when={currentTab() === "subscriptions"}>
14694
- {
14695
- /* Retired tab alias: the customer list, filtered to active subscribers. */
14820
+ {
14821
+ /* Prescription requests */
14696
14822
  }
14697
- <Customers
14698
- passwordResetRedirectUrl={props.passwordResetRedirectUrl}
14699
- initialFilter="active"
14700
- activeUid={props.customers?.activeUid}
14701
- onSelectCustomer={props.customers?.onSelectCustomer}
14702
- />
14703
- </Match2>
14704
- <Match2 when={currentTab() === "products"}>
14705
- <Products productDefaultsLookup={props.productDefaultsLookup} />
14706
- </Match2>
14707
- <Match2 when={currentTab() === "categories"}>
14708
- <Categories />
14709
- </Match2>
14710
- <Match2 when={currentTab() === "sales"}>
14711
- <Sales />
14712
- </Match2>
14713
- <Match2 when={currentTab() === "promo-codes"}>
14714
- <PromoCodes affiliatesEnabled={affiliatesEnabled()} />
14715
- </Match2>
14716
- <Match2 when={currentTab() === "affiliates"}>
14717
- <Affiliates {...props.affiliates ?? {}} />
14718
- </Match2>
14719
- <Match2 when={currentTab() === "support"}>
14720
- <Support initialThreadId={pendingThreadId()} />
14721
- </Match2>
14722
- <Match2 when={currentTab() === "webhooks"}>
14723
- <Webhooks />
14724
- </Match2>
14725
- <Match2 when={currentTab() === "email-templates"}>
14726
- <EmailTemplates />
14727
- </Match2>
14728
- <Match2 when={currentTab() === "funnel"}>
14729
- <Funnel />
14730
- </Match2>
14731
- </Switch2>
14732
- </ErrorBoundary>
14733
- </Show44>
14734
- </div>
14735
- </div>
14736
- </AdminNavContext.Provider>
14737
- </Show44>;
14738
- }
14739
- function AdminTabError(props) {
14740
- console.error("[AdminDashboard] tab failed to render:", props.error);
14741
- const message = () => props.error instanceof Error ? props.error.message : String(props.error);
14742
- return <div
14743
- role="alert"
14823
+ <div>
14824
+ <h3 style={panelSectionHeader}>Prescription requests</h3>
14825
+ <Show44
14826
+ when={(data.rxList() ?? []).length > 0}
14827
+ fallback={<p
14828
+ style={{
14829
+ color: "var(--app-admin-fg-muted)",
14830
+ "font-size": "0.875rem"
14831
+ }}
14832
+ >
14833
+ No prescription requests.
14834
+ </p>}
14835
+ >
14836
+ <div style={{ display: "flex", "flex-direction": "column", gap: "0.5rem" }}>
14837
+ <For32 each={data.rxList()}>
14838
+ {(req) => <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
14839
+ <div
14744
14840
  style={{
14745
- margin: "1rem 0",
14746
- padding: "1.25rem 1.5rem",
14747
- border: "1px solid var(--app-admin-border)",
14748
- "border-radius": "var(--app-admin-radius-sm)",
14749
- background: "var(--app-admin-surface)",
14750
- color: "var(--app-admin-fg)"
14841
+ display: "flex",
14842
+ "align-items": "center",
14843
+ "justify-content": "space-between"
14751
14844
  }}
14752
14845
  >
14753
- <div style={{ "font-weight": "600", "margin-bottom": "0.375rem" }}>
14754
- This section failed to load
14755
- </div>
14756
- <div
14846
+ <div>
14847
+ <span
14848
+ style={{ "font-size": "0.875rem", "font-weight": "500" }}
14849
+ >
14850
+ {req.drugName || req.drugId || "Prescription"}
14851
+ </span>
14852
+ <Show44 when={req.dosage}>
14853
+ <span
14757
14854
  style={{
14758
- "font-size": "0.875rem",
14855
+ "font-size": "0.75rem",
14759
14856
  color: "var(--app-admin-fg-muted)",
14760
- "margin-bottom": "1rem",
14761
- "word-break": "break-word"
14857
+ "margin-left": "0.5rem"
14762
14858
  }}
14763
14859
  >
14764
- {message()}
14765
- </div>
14766
- <button
14767
- type="button"
14768
- onClick={() => props.reset()}
14860
+ {req.dosage}
14861
+ </span>
14862
+ </Show44>
14863
+ </div>
14864
+ <StatusBadge status={req.status} />
14865
+ </div>
14866
+ <div
14769
14867
  style={{
14770
- padding: "0.5rem 0.875rem",
14771
- "border-radius": "var(--app-admin-radius-sm)",
14772
- border: "1px solid var(--app-admin-border)",
14773
- background: "var(--app-admin-primary-soft)",
14774
- color: "var(--app-admin-primary-soft-fg)",
14775
- "font-size": "0.875rem",
14776
- "font-weight": "500",
14777
- cursor: "pointer"
14868
+ "font-size": "0.75rem",
14869
+ color: "var(--app-admin-fg-muted)",
14870
+ "margin-top": "0.25rem"
14778
14871
  }}
14779
14872
  >
14780
- Try again
14781
- </button>
14782
- </div>;
14783
- }
14784
- function AdminGateSpinner(props) {
14785
- return <div
14786
- class="app-admin-root"
14787
- style={{
14788
- display: "flex",
14789
- "align-items": "center",
14790
- "justify-content": "center",
14791
- position: "sticky",
14792
- top: props.topOffset,
14793
- height: `calc(100vh - ${props.topOffset})`,
14794
- background: "var(--app-admin-bg)"
14795
- }}
14873
+ <Show44 when={req.priceCents != null}>
14874
+ <span>{centsToUsd(req.priceCents)} · </span>
14875
+ </Show44>
14876
+ {fmtDate(req.createdAt)}
14877
+ </div>
14878
+ </div>}
14879
+ </For32>
14880
+ </div>
14881
+ </Show44>
14882
+ </div>
14883
+
14884
+ {
14885
+ /* Pending surveys */
14886
+ }
14887
+ <div>
14888
+ <h3 style={panelSectionHeader}>Pending surveys</h3>
14889
+ <Show44
14890
+ when={(data.pendingSurveys() ?? []).length > 0}
14891
+ fallback={<p
14892
+ style={{
14893
+ color: "var(--app-admin-fg-muted)",
14894
+ "font-size": "0.875rem"
14895
+ }}
14896
+ >
14897
+ No pending surveys.
14898
+ </p>}
14796
14899
  >
14797
- <div
14798
- role="status"
14799
- aria-label="Loading admin"
14900
+ <div style={{ display: "flex", "flex-direction": "column", gap: "0.5rem" }}>
14901
+ <For32 each={data.pendingSurveys()}>
14902
+ {(survey) => <div class="app-admin-card-soft" style={{ padding: "0.75rem" }}>
14903
+ <span style={{ "font-size": "0.875rem", "font-weight": "500" }}>
14904
+ {survey.drugName || survey.drugId || "Renewal survey"}
14905
+ </span>
14906
+ <span
14800
14907
  style={{
14801
- width: "1.75rem",
14802
- height: "1.75rem",
14803
- "border-radius": "9999px",
14804
- border: "2px solid var(--app-admin-border)",
14805
- "border-top-color": "var(--app-admin-primary)",
14806
- animation: "app-admin-gate-spin 0.8s linear infinite"
14908
+ "font-size": "0.75rem",
14909
+ color: "var(--app-admin-fg-muted)",
14910
+ "margin-left": "0.5rem"
14807
14911
  }}
14808
- />
14809
- <style>{`@keyframes app-admin-gate-spin { to { transform: rotate(360deg); } }`}</style>
14912
+ >
14913
+ Cycle {survey.cycleNumber}
14914
+ </span>
14915
+ </div>}
14916
+ </For32>
14917
+ </div>
14918
+ </Show44>
14919
+ </div>
14920
+ </>}
14921
+ </Show44>
14922
+ </Show44>
14923
+ </div>
14924
+ </div>
14810
14925
  </div>;
14811
14926
  }
14812
14927
 
@@ -18242,9 +18357,9 @@ export {
18242
18357
  SignupPage,
18243
18358
  RegisterPage,
18244
18359
  SubscribePage,
18245
- PatientDashboardPreview,
18246
18360
  EmailTemplates,
18247
18361
  AdminDashboard,
18362
+ PatientDashboardPreview,
18248
18363
  UpdatePaymentMethod,
18249
18364
  MemberPortal,
18250
18365
  AffiliatePortal,
@@ -18255,4 +18370,4 @@ export {
18255
18370
  AffiliateForgotPassword,
18256
18371
  AffiliateResetPassword
18257
18372
  };
18258
- //# sourceMappingURL=HM27UGZM.jsx.map
18373
+ //# sourceMappingURL=YPZVHEBG.jsx.map