@apextelemed/partner-core 0.20.0-dev.65 → 0.20.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.
@@ -83,7 +83,7 @@ import {
83
83
  useSurveyV2Flow,
84
84
  useUpdatePaymentMethodFlow,
85
85
  visibleWarnings
86
- } from "./HEXXZYK4.jsx";
86
+ } from "./KSEIBHCD.jsx";
87
87
  import {
88
88
  fetchFunnelConfig
89
89
  } from "./UAZK2UTR.jsx";
@@ -7737,7 +7737,7 @@ function EarningsBar(props) {
7737
7737
  1,
7738
7738
  props.earnings.pending + props.earnings.approved + props.earnings.paid + props.earnings.cancelled
7739
7739
  );
7740
- const pct = (n) => `${n / total() * 100}%`;
7740
+ const pct2 = (n) => `${n / total() * 100}%`;
7741
7741
  return <div style={{ "margin-top": "0.5rem" }}>
7742
7742
  <div
7743
7743
  style={{
@@ -7750,21 +7750,21 @@ function EarningsBar(props) {
7750
7750
  }}
7751
7751
  >
7752
7752
  <div
7753
- style={{ background: "var(--app-admin-warning-fg)", width: pct(props.earnings.pending) }}
7753
+ style={{ background: "var(--app-admin-warning-fg)", width: pct2(props.earnings.pending) }}
7754
7754
  title={`Pending ${fmtCents4(props.earnings.pending)}`}
7755
7755
  />
7756
7756
  <div
7757
- style={{ background: "var(--app-admin-info-fg)", width: pct(props.earnings.approved) }}
7757
+ style={{ background: "var(--app-admin-info-fg)", width: pct2(props.earnings.approved) }}
7758
7758
  title={`Approved ${fmtCents4(props.earnings.approved)}`}
7759
7759
  />
7760
7760
  <div
7761
- style={{ background: "var(--app-admin-success-fg)", width: pct(props.earnings.paid) }}
7761
+ style={{ background: "var(--app-admin-success-fg)", width: pct2(props.earnings.paid) }}
7762
7762
  title={`Paid ${fmtCents4(props.earnings.paid)}`}
7763
7763
  />
7764
7764
  <div
7765
7765
  style={{
7766
7766
  background: "var(--app-admin-danger-fg)",
7767
- width: pct(props.earnings.cancelled)
7767
+ width: pct2(props.earnings.cancelled)
7768
7768
  }}
7769
7769
  title={`Canceled ${fmtCents4(props.earnings.cancelled)}`}
7770
7770
  />
@@ -7894,10 +7894,10 @@ function OverrideEditor(props) {
7894
7894
  setSaving(true);
7895
7895
  try {
7896
7896
  const fixed = fixedDollars().trim();
7897
- const pct = pctRate().trim();
7898
- const customCommission = fixed === "" && pct === "" ? void 0 : {
7897
+ const pct2 = pctRate().trim();
7898
+ const customCommission = fixed === "" && pct2 === "" ? void 0 : {
7899
7899
  fixedAmountCents: fixed === "" ? void 0 : Math.round(parseFloat(fixed) * 100),
7900
- percentageRate: pct === "" ? void 0 : parseFloat(pct)
7900
+ percentageRate: pct2 === "" ? void 0 : parseFloat(pct2)
7901
7901
  };
7902
7902
  const discountStr = discountPct().trim();
7903
7903
  const cyclesStr = minCycles().trim();
@@ -8107,10 +8107,10 @@ function SecondTierEditor(props) {
8107
8107
  setSaving(true);
8108
8108
  try {
8109
8109
  const fixed = fixedDollars().trim();
8110
- const pct = pctRate().trim();
8111
- const customSecondTierCommission = fixed === "" && pct === "" ? null : {
8110
+ const pct2 = pctRate().trim();
8111
+ const customSecondTierCommission = fixed === "" && pct2 === "" ? null : {
8112
8112
  fixedAmountCents: fixed === "" ? void 0 : Math.round(parseFloat(fixed) * 100),
8113
- percentageRate: pct === "" ? void 0 : parseFloat(pct)
8113
+ percentageRate: pct2 === "" ? void 0 : parseFloat(pct2)
8114
8114
  };
8115
8115
  await adminAffiliatesApi.update(props.affiliate.id, { customSecondTierCommission });
8116
8116
  props.onSaved();
@@ -8831,15 +8831,15 @@ function ProgramEditPanel(props) {
8831
8831
  const save = async () => {
8832
8832
  if (!name().trim()) return setErr("Name is required.");
8833
8833
  const fixed = fixedDollars().trim();
8834
- const pct = pctRate().trim();
8835
- if (fixed === "" && pct === "") {
8834
+ const pct2 = pctRate().trim();
8835
+ if (fixed === "" && pct2 === "") {
8836
8836
  return setErr("Set at least one of fixed amount or percentage rate.");
8837
8837
  }
8838
8838
  setErr("");
8839
8839
  setSaving(true);
8840
8840
  const defaultCommission = {
8841
8841
  fixedAmountCents: fixed === "" ? void 0 : Math.round(parseFloat(fixed) * 100),
8842
- percentageRate: pct === "" ? void 0 : parseFloat(pct)
8842
+ percentageRate: pct2 === "" ? void 0 : parseFloat(pct2)
8843
8843
  };
8844
8844
  const t2Fixed = tier2FixedDollars().trim();
8845
8845
  const t2Pct = tier2PctRate().trim();
@@ -8906,13 +8906,13 @@ function ProgramEditPanel(props) {
8906
8906
  );
8907
8907
  const examplePerCycleCents = createMemo8(() => {
8908
8908
  const fixed = (parseFloat(fixedDollars()) || 0) * 100;
8909
- const pct = parseFloat(pctRate()) || 0;
8910
- return Math.round(fixed + exampleBilledCents() * (pct / 100));
8909
+ const pct2 = parseFloat(pctRate()) || 0;
8910
+ return Math.round(fixed + exampleBilledCents() * (pct2 / 100));
8911
8911
  });
8912
8912
  const exampleTier2Cents = createMemo8(() => {
8913
8913
  const fixed = (parseFloat(tier2FixedDollars()) || 0) * 100;
8914
- const pct = parseFloat(tier2PctRate()) || 0;
8915
- return Math.round(fixed + exampleBilledCents() * (pct / 100));
8914
+ const pct2 = parseFloat(tier2PctRate()) || 0;
8915
+ return Math.round(fixed + exampleBilledCents() * (pct2 / 100));
8916
8916
  });
8917
8917
  const exampleCyclesNum = createMemo8(() => Math.max(1, parseInt(minCycles(), 10) || 1));
8918
8918
  const exampleHoldDaysNum = createMemo8(() => Math.max(0, parseInt(holdDays(), 10) || 0));
@@ -16947,8 +16947,8 @@ import { createMemo as createMemo17, createResource as createResource17, createS
16947
16947
 
16948
16948
  // src/pages/admin/funnelShared.ts
16949
16949
  var SEGMENT_KEYS = {
16950
- a: ["a.cart", "a.survey_finished", "a.survey_started"],
16951
- b: ["b.card_declined", "b.cart", "b.survey_finished", "b.survey_started", "b.no_activity"]
16950
+ a: ["a.cart", "a.survey_finished", "a.rejected", "a.survey_started"],
16951
+ b: ["b.card_declined", "b.cart", "b.survey_finished", "b.rejected", "b.survey_started", "b.no_activity"]
16952
16952
  };
16953
16953
  var GROUP_LABEL = {
16954
16954
  a: "No account",
@@ -16957,10 +16957,12 @@ var GROUP_LABEL = {
16957
16957
  var SEGMENT_LABEL = {
16958
16958
  "a.cart": "Abandoned a cart",
16959
16959
  "a.survey_finished": "Finished the questionnaire",
16960
+ "a.rejected": "Rejected by the questionnaire",
16960
16961
  "a.survey_started": "Started the questionnaire",
16961
16962
  "b.card_declined": "Card declined",
16962
16963
  "b.cart": "Abandoned a cart",
16963
16964
  "b.survey_finished": "Finished the questionnaire",
16965
+ "b.rejected": "Rejected by the questionnaire",
16964
16966
  "b.survey_started": "Started the questionnaire",
16965
16967
  "b.no_activity": "No tracked activity"
16966
16968
  };
@@ -20576,7 +20578,7 @@ function EmailTemplates(props = {}) {
20576
20578
  }
20577
20579
 
20578
20580
  // src/pages/admin/Funnel.tsx
20579
- import { createResource as createResource25, createSignal as createSignal40, For as For45, Show as Show59 } from "solid-js";
20581
+ import { createMemo as createMemo19, createResource as createResource25, createSignal as createSignal40, For as For45, Show as Show59 } from "solid-js";
20580
20582
 
20581
20583
  // src/pages/admin/Sequences.tsx
20582
20584
  import { createResource as createResource24, createSignal as createSignal39, For as For44, Index as Index2, Match as Match4, Show as Show58, Switch as Switch4 } from "solid-js";
@@ -21247,6 +21249,17 @@ function Sequences() {
21247
21249
  }
21248
21250
 
21249
21251
  // src/pages/admin/Funnel.tsx
21252
+ var STAGES = [
21253
+ { id: "survey_started", label: "Left the survey" },
21254
+ { id: "rejected", label: "Rejected" },
21255
+ { id: "survey_finished", label: "Finished, never bought" },
21256
+ { id: "cart", label: "Left a cart" },
21257
+ { id: "card_declined", label: "Card declined" },
21258
+ { id: "no_activity", label: "Account, no activity" }
21259
+ ];
21260
+ var STAGE_LABEL = Object.fromEntries(STAGES.map((s) => [s.id, s.label]));
21261
+ var stageOf = (key) => key.slice(2);
21262
+ var PAGE_SIZE = 50;
21250
21263
  function CardHeader(props) {
21251
21264
  return <div style={{ padding: "1rem 1.25rem", "border-bottom": "1px solid var(--app-admin-border-soft)" }}>
21252
21265
  <h2 class="app-admin-heading" style={{ "font-size": "0.9375rem", "font-weight": "600", margin: 0 }}>{props.title}</h2>
@@ -21257,90 +21270,325 @@ function CardHeader(props) {
21257
21270
  </Show59>
21258
21271
  </div>;
21259
21272
  }
21260
- function stoppedAt(p) {
21261
- const base = SEGMENT_LABEL[p.key];
21262
- if (p.key.endsWith("survey_started") && p.lastStep != null && p.stepCount) {
21263
- return `${base} \u2014 step ${Math.min(p.lastStep + 1, p.stepCount)} of ${p.stepCount}`;
21264
- }
21265
- if (p.key.endsWith("survey_finished") && p.qualified === false) return `${base} \u2014 not qualified`;
21266
- return base;
21273
+ function Tile(props) {
21274
+ const danger = () => props.tone === "danger";
21275
+ return <div
21276
+ style={{
21277
+ padding: "0.75rem 0.875rem",
21278
+ "border-radius": "var(--app-admin-radius-sm, 0.5rem)",
21279
+ background: danger() ? "var(--app-admin-danger-bg)" : "var(--app-admin-surface-light, var(--app-admin-border-soft))",
21280
+ "min-width": 0
21281
+ }}
21282
+ >
21283
+ <div style={{ "font-size": "0.75rem", color: danger() ? "var(--app-admin-danger-fg)" : "var(--app-admin-fg-muted)" }}>
21284
+ {props.label}
21285
+ </div>
21286
+ <div
21287
+ style={{ "font-size": "1.375rem", "font-weight": "600", color: danger() ? "var(--app-admin-danger-fg)" : void 0 }}
21288
+ >
21289
+ {props.value}
21290
+ </div>
21291
+ <Show59 when={props.note}>
21292
+ <div style={{ "font-size": "0.6875rem", color: "var(--app-admin-fg-subtle)" }}>{props.note}</div>
21293
+ </Show59>
21294
+ </div>;
21267
21295
  }
21268
- function SegmentSection(props) {
21269
- const nav = useAdminNav();
21270
- const [filter, setFilter] = createSignal40("all");
21271
- const [savingsOnly, setSavingsOnly] = createSignal40(false);
21272
- const [selected, setSelected] = createSignal40({});
21273
- const [people, { refetch }] = createResource25(
21274
- () => ({ days: props.days, filter: filter(), savings: savingsOnly() }),
21275
- (q) => apiFetch(
21276
- `/admin/funnel/segments/${q.filter === "all" ? props.group : q.filter}/people?days=${q.days}&limit=50` + (q.savings ? "&savings=true" : "")
21277
- )
21278
- );
21279
- const max = () => Math.max(1, ...props.summary.segments.map((s) => s.count));
21280
- const hasSavings = () => props.group === "b" && props.summary.savingsMembers > 0;
21281
- const selectable = () => (people()?.people ?? []).filter((p) => !p.optedOut);
21282
- const picked = () => selectable().filter((p) => selected()[p.email]);
21283
- const allPicked = () => selectable().length > 0 && picked().length === selectable().length;
21284
- const toggleAll = () => setSelected(allPicked() ? {} : Object.fromEntries(selectable().map((p) => [p.email, true])));
21285
- return <div class="app-admin-card" style={{ "margin-top": "1.25rem", overflow: "hidden" }}>
21286
- <CardHeader title={`${props.title} \u2014 ${props.summary.total}`} note={props.note} />
21287
-
21288
- <div style={{ padding: "1rem 1.25rem", display: "grid", gap: "0.5rem" }}>
21289
- <For45 each={props.summary.segments}>
21290
- {(seg) => <button
21291
- type="button"
21292
- onClick={() => setFilter(filter() === seg.key ? "all" : seg.key)}
21293
- aria-pressed={filter() === seg.key}
21294
- title={`${SEGMENT_LABEL[seg.key]}: ${seg.count}`}
21296
+ function pageName(p) {
21297
+ return p.title || p.sectionTitle || (p.stepId === "patient_info" ? "Contact information" : "Untitled page");
21298
+ }
21299
+ var pct = (n, d) => d > 0 ? Math.round(n / d * 100) : 0;
21300
+ function Totals(props) {
21301
+ const s = () => props.summary;
21302
+ const carts = () => s().carts;
21303
+ return <div class="app-admin-card" style={{ overflow: "hidden" }}>
21304
+ <CardHeader
21305
+ title="Everyone who started, and where they ended up"
21306
+ note="Counts survey attempts, so someone who tried twice counts twice. The people list below counts each person once."
21307
+ />
21308
+ <div
21295
21309
  style={{
21310
+ padding: "1rem 1.25rem",
21296
21311
  display: "grid",
21297
- "grid-template-columns": "12rem 1fr 7rem",
21298
- "align-items": "center",
21299
- gap: "0.75rem",
21300
- background: "none",
21301
- border: "none",
21302
- padding: "0.125rem 0",
21303
- cursor: "pointer",
21304
- "text-align": "left",
21305
- color: "inherit",
21306
- font: "inherit",
21307
- opacity: filter() === "all" || filter() === seg.key ? 1 : 0.45
21312
+ "grid-template-columns": "repeat(auto-fit, minmax(8.5rem, 1fr))",
21313
+ gap: "0.5rem"
21308
21314
  }}
21309
21315
  >
21310
- <span style={{ "font-size": "0.8125rem", color: "var(--app-admin-fg-muted)" }}>
21311
- {SEGMENT_LABEL[seg.key]}
21312
- </span>
21313
- <span style={{ display: "block", background: "var(--app-admin-border-soft)", "border-radius": "4px", height: "1.125rem" }}>
21314
- <span
21316
+ <Tile
21317
+ label="Started the survey"
21318
+ value={s().sessions.started}
21319
+ note={s().sessions.active > 0 ? `${s().sessions.active} still in progress` : void 0}
21320
+ />
21321
+ <Tile label="Left partway" value={s().sessions.abandoned} />
21322
+ <Show59 when={s().sessions.rejected !== void 0}>
21323
+ <Tile label="Rejected" value={s().sessions.rejected ?? 0} note="Told they don't qualify" tone="danger" />
21324
+ </Show59>
21325
+ <Tile label="Finished the survey" value={s().sessions.completed} />
21326
+ <Show59 when={(carts()?.total ?? 0) > 0}>
21327
+ <Tile label="Left a cart" value={carts().abandoned} note={`of ${carts().total} carts`} />
21328
+ </Show59>
21329
+ <Show59 when={s().captures}>
21330
+ <Tile label="Finished and bought" value={s().captures.converted} />
21331
+ </Show59>
21332
+ </div>
21333
+ </div>;
21334
+ }
21335
+ function PagesCard(props) {
21336
+ const pages = () => props.summary.pages ?? [];
21337
+ const anyRejected = () => pages().some((p) => p.rejected > 0);
21338
+ const untracked = () => props.summary.untrackedAbandons ?? 0;
21339
+ const reasons = () => props.summary.rejections ?? [];
21340
+ const maxRate = () => Math.max(1, ...pages().map((p) => pct(p.stopped, p.reached)));
21341
+ const dropoffMax = () => Math.max(1, ...props.summary.stepDropoff.map((b) => b.count));
21342
+ return <div class="app-admin-card" style={{ "margin-top": "1.25rem", overflow: "hidden" }}>
21343
+ <CardHeader
21344
+ title="Survey pages people stop on"
21345
+ note="The last page someone saw before they left, most stops first. Leaving the page counts at once; a session that just goes quiet counts after 4 hours."
21346
+ />
21347
+ <Show59
21348
+ when={pages().length > 0}
21349
+ fallback={<div style={{ padding: "1rem 1.25rem" }}>
21350
+ <EmptyState
21351
+ message={props.summary.pages === void 0 ? "Page details need a newer backend." : "No page details yet. They start with surveys taken after this update."}
21352
+ />
21353
+ </div>}
21354
+ >
21355
+ <table class="app-admin-table">
21356
+ <thead>
21357
+ <tr>
21358
+ <th>Page and its questions</th>
21359
+ <th style={{ width: "6rem", "text-align": "right" }}>Left here</th>
21360
+ <Show59 when={anyRejected()}>
21361
+ <th style={{ width: "6rem", "text-align": "right" }}>Rejected here</th>
21362
+ </Show59>
21363
+ <th style={{ width: "11rem" }}>Of those who reached it</th>
21364
+ </tr>
21365
+ </thead>
21366
+ <tbody>
21367
+ <For45 each={pages()}>
21368
+ {(p) => <tr>
21369
+ <td data-label="Page">
21370
+ <div style={{ "font-weight": "500" }}>{pageName(p)}</div>
21371
+ <Show59 when={p.title && p.sectionTitle && p.sectionTitle !== p.title}>
21372
+ <div class="app-admin-text-muted" style={{ "font-size": "0.6875rem" }}>{p.sectionTitle}</div>
21373
+ </Show59>
21374
+ <Show59 when={p.questions.length > 0}>
21375
+ <ul class="app-admin-text-muted" style={{ "font-size": "0.75rem", margin: "0.25rem 0 0", "padding-left": "1rem" }}>
21376
+ <For45 each={p.questions}>{(q) => <li>{q}</li>}</For45>
21377
+ </ul>
21378
+ </Show59>
21379
+ </td>
21380
+ <td data-label="Left here" style={{ "text-align": "right" }}>{p.stopped}</td>
21381
+ <Show59 when={anyRejected()}>
21382
+ <td data-label="Rejected here" style={{ "text-align": "right" }}>{p.rejected || "\u2014"}</td>
21383
+ </Show59>
21384
+ <td data-label="Of those who reached it">
21385
+ <div style={{ display: "flex", "align-items": "center", gap: "0.5rem" }}>
21386
+ <span
21387
+ style={{ flex: 1, display: "block", background: "var(--app-admin-border-soft)", "border-radius": "4px", height: "0.5rem" }}
21388
+ >
21389
+ <span
21315
21390
  style={{
21316
21391
  display: "block",
21317
- width: `${seg.count / max() * 100}%`,
21318
- "min-width": seg.count > 0 ? "4px" : "0",
21392
+ width: `${pct(p.stopped, p.reached) / maxRate() * 100}%`,
21319
21393
  height: "100%",
21320
21394
  background: "var(--app-admin-primary)",
21321
21395
  "border-radius": "4px"
21322
21396
  }}
21323
21397
  />
21324
- </span>
21325
- <span style={{ "font-size": "0.8125rem", "text-align": "right" }}>
21326
- {seg.count}
21327
- <Show59 when={hasSavings()}>
21328
- <span style={{ color: "var(--app-admin-fg-subtle)", "margin-left": "0.375rem" }}>
21329
- {seg.savingsMembers} savings
21398
+ </span>
21399
+ <span
21400
+ style={{ "font-size": "0.75rem", "min-width": "5.5rem", "text-align": "right" }}
21401
+ title={`${p.stopped} of ${p.reached} who reached this page left on it`}
21402
+ >
21403
+ {pct(p.stopped, p.reached)}% of {p.reached}
21404
+ </span>
21405
+ </div>
21406
+ </td>
21407
+ </tr>}
21408
+ </For45>
21409
+ </tbody>
21410
+ </table>
21411
+ </Show59>
21412
+
21413
+ <Show59 when={(props.summary.sessions.rejected ?? 0) > 0}>
21414
+ <div style={{ padding: "1rem 1.25rem", "border-top": "1px solid var(--app-admin-border-soft)" }}>
21415
+ <h3 class="app-admin-heading" style={{ "font-size": "0.8125rem", "font-weight": "600", margin: "0 0 0.5rem" }}>
21416
+ Why people were rejected
21417
+ </h3>
21418
+ <Show59
21419
+ when={reasons().length > 0}
21420
+ fallback={<p class="app-admin-text-muted" style={{ "font-size": "0.75rem", margin: 0 }}>Apex gave no reason text for these rejections.</p>}
21421
+ >
21422
+ <div style={{ display: "grid", gap: "0.25rem" }}>
21423
+ <For45 each={reasons()}>
21424
+ {(r) => <div style={{ display: "flex", "justify-content": "space-between", gap: "1rem", "font-size": "0.8125rem" }}>
21425
+ <span>{r.reason}</span>
21426
+ <span class="app-admin-text-muted">{r.count}</span>
21427
+ </div>}
21428
+ </For45>
21429
+ </div>
21430
+ <p class="app-admin-text-muted" style={{ "font-size": "0.6875rem", margin: "0.5rem 0 0" }}>
21431
+ People, not medications: someone ruled out of two medications for the same reason counts once.
21432
+ </p>
21433
+ </Show59>
21434
+ </div>
21435
+ </Show59>
21436
+
21437
+ <Show59 when={untracked() > 0}>
21438
+ <details style={{ padding: "0.75rem 1.25rem", "border-top": "1px solid var(--app-admin-border-soft)" }}>
21439
+ <summary style={{ "font-size": "0.75rem", color: "var(--app-admin-fg-muted)", cursor: "pointer" }}>
21440
+ Older drop-offs by position ({untracked()}) — from before page tracking, so only how far through they were is known
21441
+ </summary>
21442
+ <div style={{ "padding-top": "0.75rem", display: "flex", "align-items": "flex-end", gap: "0.375rem", height: "7rem" }}>
21443
+ <For45 each={props.summary.stepDropoff}>
21444
+ {(b) => <div
21445
+ style={{ flex: 1, display: "flex", "flex-direction": "column", "align-items": "center", gap: "0.25rem", height: "100%", "justify-content": "flex-end" }}
21446
+ title={`${b.bucket * 10}% through: ${b.count}`}
21447
+ >
21448
+ <Show59 when={b.count > 0}>
21449
+ <span style={{ "font-size": "0.6875rem", color: "var(--app-admin-fg-muted)" }}>{b.count}</span>
21450
+ </Show59>
21451
+ <div
21452
+ style={{
21453
+ width: "100%",
21454
+ "max-width": "1.75rem",
21455
+ height: `${Math.max(b.count > 0 ? 6 : 2, b.count / dropoffMax() * 70)}px`,
21456
+ background: b.count > 0 ? "var(--app-admin-primary)" : "var(--app-admin-border-soft)",
21457
+ "border-radius": "4px 4px 0 0"
21458
+ }}
21459
+ />
21460
+ <span style={{ "font-size": "0.625rem", color: "var(--app-admin-fg-subtle)" }}>
21461
+ {b.bucket === 0 ? "Start" : b.bucket === 10 ? "Info" : b.bucket === 5 ? "50%" : ""}
21330
21462
  </span>
21331
- </Show59>
21332
- </span>
21333
- </button>}
21334
- </For45>
21335
- <Show59 when={hasSavings()}>
21336
- <label style={{ "font-size": "0.8125rem", display: "flex", gap: "0.375rem", "align-items": "center", "margin-top": "0.25rem" }}>
21337
- <input type="checkbox" checked={savingsOnly()} onChange={(e) => setSavingsOnly(e.currentTarget.checked)} />
21338
- Savings program only ({props.summary.savingsMembers})
21463
+ </div>}
21464
+ </For45>
21465
+ </div>
21466
+ </details>
21467
+ </Show59>
21468
+ </div>;
21469
+ }
21470
+ function whereStopped(p) {
21471
+ const stage = stageOf(p.key);
21472
+ const detail = () => {
21473
+ if (stage === "survey_started" || stage === "rejected") {
21474
+ if (p.stepTitle) return p.stepTitle;
21475
+ if (p.lastStep != null && p.stepCount) return `Step ${Math.min(p.lastStep + 1, p.stepCount)} of ${p.stepCount}`;
21476
+ }
21477
+ if (stage === "survey_finished" && p.qualified === false) return "Not qualified";
21478
+ return null;
21479
+ };
21480
+ return <>
21481
+ <Show59 when={stage === "rejected"} fallback={<span>{STAGE_LABEL[stage]}</span>}>
21482
+ <span class="app-admin-badge app-admin-badge--danger">Rejected</span>
21483
+ </Show59>
21484
+ <Show59 when={detail()}>
21485
+ <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{detail()}</div>
21486
+ </Show59>
21487
+ <Show59 when={stage === "rejected" && p.rejectionReasons && p.rejectionReasons.length > 0}>
21488
+ <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{p.rejectionReasons.join("; ")}</div>
21489
+ </Show59>
21490
+ </>;
21491
+ }
21492
+ function keysFor(stage, account, known) {
21493
+ const groups = account === "all" ? ["a", "b"] : [account];
21494
+ if (stage === "all") return groups;
21495
+ return groups.map((g) => `${g}.${stage}`).filter((k) => SEGMENT_KEYS[k.charAt(0)].includes(k) && known.has(k));
21496
+ }
21497
+ function PeopleCard(props) {
21498
+ const nav = useAdminNav();
21499
+ const [stage, setStage] = createSignal40("all");
21500
+ const [account, setAccount] = createSignal40("all");
21501
+ const [savingsOnly, setSavingsOnly] = createSignal40(false);
21502
+ const [selected, setSelected] = createSignal40({});
21503
+ const known = createMemo19(
21504
+ () => new Set([...props.segments.noAccount.segments, ...props.segments.account.segments].map((s) => s.key))
21505
+ );
21506
+ const groupSummary = (g) => g === "a" ? props.segments.noAccount : props.segments.account;
21507
+ const stageCount = (st) => {
21508
+ const groups = account() === "all" ? ["a", "b"] : [account()];
21509
+ return groups.reduce((n, g) => {
21510
+ const seg = groupSummary(g).segments.find((s) => s.key === `${g}.${st}`);
21511
+ return n + (savingsOnly() ? seg?.savingsMembers ?? 0 : seg?.count ?? 0);
21512
+ }, 0);
21513
+ };
21514
+ const visibleStages = () => STAGES.filter((st) => keysFor(st.id, account(), known()).length > 0);
21515
+ const savingsTotal = () => props.segments.account.savingsMembers;
21516
+ const [people, { refetch }] = createResource25(
21517
+ () => ({ days: props.days, stage: stage(), account: savingsOnly() ? "b" : account(), savings: savingsOnly() }),
21518
+ async (q) => {
21519
+ const keys = keysFor(q.stage, q.account, known());
21520
+ const pages = await Promise.all(
21521
+ keys.map(
21522
+ (k) => apiFetch(
21523
+ `/admin/funnel/segments/${k}/people?days=${q.days}&limit=${PAGE_SIZE}` + (q.savings ? "&savings=true" : "")
21524
+ )
21525
+ )
21526
+ );
21527
+ const merged = pages.flatMap((p) => p.people).sort((x, y) => y.enteredAt.localeCompare(x.enteredAt)).slice(0, PAGE_SIZE);
21528
+ return {
21529
+ people: merged,
21530
+ total: pages.reduce((n, p) => n + p.total, 0),
21531
+ hasMore: pages.some((p) => p.hasMore) || pages.reduce((n, p) => n + p.people.length, 0) > PAGE_SIZE,
21532
+ rejectedHidden: pages.reduce((n, p) => n + (p.rejectedHidden ?? 0), 0)
21533
+ };
21534
+ }
21535
+ );
21536
+ const selectable = () => (people()?.people ?? []).filter((p) => !p.optedOut);
21537
+ const picked = () => selectable().filter((p) => selected()[p.email]);
21538
+ const allPicked = () => selectable().length > 0 && picked().length === selectable().length;
21539
+ const toggleAll = () => setSelected(allPicked() ? {} : Object.fromEntries(selectable().map((p) => [p.email, true])));
21540
+ const totalPeople = createMemo19(
21541
+ () => (account() === "all" ? ["a", "b"] : [account()]).reduce(
21542
+ (n, g) => n + (savingsOnly() ? g === "b" ? savingsTotal() : 0 : groupSummary(g).total),
21543
+ 0
21544
+ )
21545
+ );
21546
+ return <div class="app-admin-card" style={{ "margin-top": "1.25rem", overflow: "hidden" }}>
21547
+ <CardHeader
21548
+ title="People who didn't buy"
21549
+ note="Each person once, at the furthest point they reached. Anyone who has bought is left out."
21550
+ />
21551
+
21552
+ <div style={{ padding: "0.875rem 1.25rem 0", display: "grid", gap: "0.5rem" }}>
21553
+ <div class="app-admin-chips" role="group" aria-label="Where they stopped">
21554
+ <Chip label="Everyone" count={totalPeople()} active={stage() === "all"} onClick={() => setStage("all")} />
21555
+ <For45 each={visibleStages()}>
21556
+ {(st) => <Chip
21557
+ label={st.label}
21558
+ count={stageCount(st.id)}
21559
+ active={stage() === st.id}
21560
+ onClick={() => setStage(stage() === st.id ? "all" : st.id)}
21561
+ />}
21562
+ </For45>
21563
+ </div>
21564
+ <div style={{ display: "flex", gap: "1rem", "align-items": "center", "flex-wrap": "wrap", "font-size": "0.8125rem" }}>
21565
+ <label style={{ display: "flex", gap: "0.375rem", "align-items": "center" }}>
21566
+ Account
21567
+ <select
21568
+ class="app-admin-input"
21569
+ style={{ width: "auto" }}
21570
+ value={account()}
21571
+ disabled={savingsOnly()}
21572
+ onChange={(e) => {
21573
+ setAccount(e.currentTarget.value);
21574
+ if (stage() !== "all" && keysFor(stage(), e.currentTarget.value, known()).length === 0) setStage("all");
21575
+ }}
21576
+ >
21577
+ <option value="all">Everyone ({props.segments.noAccount.total + props.segments.account.total})</option>
21578
+ <option value="a">No account — email only ({props.segments.noAccount.total})</option>
21579
+ <option value="b">Has an account ({props.segments.account.total})</option>
21580
+ </select>
21339
21581
  </label>
21340
- </Show59>
21582
+ <Show59 when={savingsTotal() > 0}>
21583
+ <label style={{ display: "flex", gap: "0.375rem", "align-items": "center" }}>
21584
+ <input type="checkbox" checked={savingsOnly()} onChange={(e) => setSavingsOnly(e.currentTarget.checked)} />
21585
+ Savings program only ({savingsTotal()})
21586
+ </label>
21587
+ </Show59>
21588
+ </div>
21341
21589
  </div>
21342
21590
 
21343
- <div style={{ padding: "0.5rem 1.25rem 0.75rem", "border-top": "1px solid var(--app-admin-border-soft)" }}>
21591
+ <div style={{ padding: "0.75rem 1.25rem" }}>
21344
21592
  <AddToSequence
21345
21593
  people={picked().map((p) => ({ email: p.email, userId: p.userId, segment: p.key }))}
21346
21594
  onDone={() => {
@@ -21358,15 +21606,14 @@ function SegmentSection(props) {
21358
21606
  </th>
21359
21607
  <th>Person</th>
21360
21608
  <th>Where they stopped</th>
21361
- <th>Since</th>
21362
- <Show59 when={props.group === "b"}><th>Account</th></Show59>
21609
+ <th style={{ width: "7rem" }}>When</th>
21363
21610
  </tr>
21364
21611
  </thead>
21365
21612
  <tbody>
21366
- <Show59 when={people()} fallback={<tr><td colSpan={5}><LoadingSpinner /></td></tr>}>
21613
+ <Show59 when={people()} fallback={<tr><td colSpan={4}><LoadingSpinner /></td></tr>}>
21367
21614
  {(page) => <Show59
21368
21615
  when={page().people.length > 0}
21369
- fallback={<tr><td colSpan={5}><EmptyState message="Nobody here in this window" /></td></tr>}
21616
+ fallback={<tr><td colSpan={4}><EmptyState message="Nobody here in this window" /></td></tr>}
21370
21617
  >
21371
21618
  <For45 each={page().people}>
21372
21619
  {(p) => <tr>
@@ -21380,11 +21627,8 @@ function SegmentSection(props) {
21380
21627
  />
21381
21628
  </td>
21382
21629
  <td data-label="Person">
21383
- <div>
21384
- <Show59
21385
- when={p.userId && nav}
21386
- fallback={p.name || p.email}
21387
- >
21630
+ <div style={{ display: "flex", gap: "0.375rem", "align-items": "center", "flex-wrap": "wrap" }}>
21631
+ <Show59 when={p.userId && nav} fallback={<span>{p.name || p.email}</span>}>
21388
21632
  <button
21389
21633
  type="button"
21390
21634
  class="app-admin-link-btn"
@@ -21394,28 +21638,22 @@ function SegmentSection(props) {
21394
21638
  {p.name || p.email}
21395
21639
  </button>
21396
21640
  </Show59>
21641
+ <Show59 when={p.userId}>
21642
+ <span class="app-admin-badge app-admin-badge--neutral">Account</span>
21643
+ </Show59>
21644
+ <Show59 when={p.savingsMember}>
21645
+ <span class="app-admin-badge app-admin-badge--info">Savings</span>
21646
+ </Show59>
21397
21647
  <Show59 when={p.optedOut}>
21398
- <span class="app-admin-badge app-admin-badge--neutral" style={{ "margin-left": "0.5rem" }}>
21399
- Opted out
21400
- </span>
21648
+ <span class="app-admin-badge app-admin-badge--neutral">Opted out</span>
21401
21649
  </Show59>
21402
21650
  </div>
21403
21651
  <Show59 when={p.name}>
21404
21652
  <div class="app-admin-text-muted" style={{ "font-size": "0.75rem" }}>{p.email}</div>
21405
21653
  </Show59>
21406
21654
  </td>
21407
- <td data-label="Where they stopped">{stoppedAt(p)}</td>
21408
- <td data-label="Since" class="app-admin-text-muted">{formatDate(p.enteredAt)}</td>
21409
- <Show59 when={props.group === "b"}>
21410
- <td data-label="Account">
21411
- <span class="app-admin-text-muted">{p.accountCreatedAt ? formatDate(p.accountCreatedAt) : "\u2014"}</span>
21412
- <Show59 when={p.savingsMember}>
21413
- <span class="app-admin-badge app-admin-badge--info" style={{ "margin-left": "0.5rem" }}>
21414
- Savings
21415
- </span>
21416
- </Show59>
21417
- </td>
21418
- </Show59>
21655
+ <td data-label="Where they stopped">{whereStopped(p)}</td>
21656
+ <td data-label="When" class="app-admin-text-muted">{formatDate(p.enteredAt)}</td>
21419
21657
  </tr>}
21420
21658
  </For45>
21421
21659
  </Show59>}
@@ -21424,29 +21662,29 @@ function SegmentSection(props) {
21424
21662
  </table>
21425
21663
  <Show59 when={people()?.hasMore}>
21426
21664
  <p class="app-admin-text-muted" style={{ "font-size": "0.75rem", padding: "0.625rem 1.25rem", margin: 0 }}>
21427
- Showing the 50 most recent of {people().total}.
21665
+ Showing the {PAGE_SIZE} most recent of {people().total}.
21666
+ </p>
21667
+ </Show59>
21668
+ <Show59 when={(people()?.rejectedHidden ?? 0) > 0}>
21669
+ <p class="app-admin-text-muted" style={{ "font-size": "0.75rem", padding: "0.625rem 1.25rem", margin: 0 }}>
21670
+ {people().rejectedHidden} rejected {people().rejectedHidden === 1 ? "person is" : "people are"} not listed: whether a
21671
+ named patient qualified is health information your role can't see. They're still in the totals above.
21428
21672
  </p>
21429
21673
  </Show59>
21430
21674
  </div>;
21431
21675
  }
21432
21676
  function Funnel() {
21433
21677
  const [days, setDays] = createSignal40(30);
21434
- const [summary] = createResource25(
21435
- days,
21436
- (d) => apiFetch(`/admin/funnel/summary?days=${d}`)
21437
- );
21438
- const [segments] = createResource25(
21439
- days,
21440
- (d) => apiFetch(`/admin/funnel/segments?days=${d}`)
21441
- );
21442
- const dropoffMax = () => Math.max(1, ...(summary()?.stepDropoff ?? []).map((b) => b.count));
21678
+ const [summary] = createResource25(days, (d) => apiFetch(`/admin/funnel/summary?days=${d}`));
21679
+ const [segments] = createResource25(days, (d) => apiFetch(`/admin/funnel/segments?days=${d}`));
21443
21680
  return <div>
21444
- <PageTitle subtitle="Who stopped short of a subscription, and where">Funnel</PageTitle>
21681
+ <PageTitle subtitle="Who stopped short of buying, and where">Funnel</PageTitle>
21445
21682
 
21446
21683
  <div style={{ "margin-bottom": "1rem" }}>
21447
21684
  <select
21448
21685
  class="app-admin-input"
21449
21686
  style={{ width: "auto" }}
21687
+ aria-label="Time window"
21450
21688
  value={days()}
21451
21689
  onChange={(e) => setDays(parseInt(e.currentTarget.value))}
21452
21690
  >
@@ -21456,65 +21694,14 @@ function Funnel() {
21456
21694
  </select>
21457
21695
  </div>
21458
21696
 
21459
- <Show59 when={segments()} fallback={<LoadingSpinner />}>
21460
- {(seg) => <>
21461
- <SegmentSection
21462
- group="a"
21463
- title="No account"
21464
- note="We hold an email and nothing else. The only thing to offer them is to come back and finish the questionnaire. Buyers are excluded; the hottest stage wins when someone has done several."
21465
- summary={seg().noAccount}
21466
- days={days()}
21467
- />
21468
- <SegmentSection
21469
- group="b"
21470
- title="Account, not subscribed"
21471
- note="They registered and never bought. They can log in and pick up their visit. “No tracked activity” means we saw nothing after the account — for accounts older than step tracking, that is all we know."
21472
- summary={seg().account}
21473
- days={days()}
21474
- />
21697
+ <Show59 when={summary()} fallback={<LoadingSpinner />}>
21698
+ {(s) => <>
21699
+ <Totals summary={s()} />
21700
+ <PagesCard summary={s()} />
21475
21701
  </>}
21476
21702
  </Show59>
21477
21703
 
21478
- <Show59 when={summary()}>
21479
- {(s) => <div class="app-admin-card" style={{ "margin-top": "1.25rem" }}>
21480
- <CardHeader
21481
- title="Where abandons quit"
21482
- 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.` : "")}
21483
- />
21484
- <div style={{ padding: "1.25rem", display: "flex", "align-items": "flex-end", gap: "0.375rem", height: "9rem" }}>
21485
- <For45 each={s().stepDropoff}>
21486
- {(b) => <div
21487
- style={{
21488
- flex: 1,
21489
- display: "flex",
21490
- "flex-direction": "column",
21491
- "align-items": "center",
21492
- gap: "0.25rem",
21493
- height: "100%",
21494
- "justify-content": "flex-end"
21495
- }}
21496
- title={`${b.bucket * 10}% through: ${b.count} abandon${b.count === 1 ? "" : "s"}`}
21497
- >
21498
- <Show59 when={b.count > 0}>
21499
- <span style={{ "font-size": "0.6875rem", color: "var(--app-admin-fg-muted)" }}>{b.count}</span>
21500
- </Show59>
21501
- <div
21502
- style={{
21503
- width: "100%",
21504
- "max-width": "1.75rem",
21505
- height: `${Math.max(b.count > 0 ? 6 : 2, b.count / dropoffMax() * 100)}px`,
21506
- background: b.count > 0 ? "var(--app-admin-primary)" : "var(--app-admin-border-soft)",
21507
- "border-radius": "4px 4px 0 0"
21508
- }}
21509
- />
21510
- <span style={{ "font-size": "0.625rem", color: "var(--app-admin-fg-subtle)" }}>
21511
- {b.bucket === 0 ? "Start" : b.bucket === 10 ? "Info" : b.bucket === 5 ? "50%" : ""}
21512
- </span>
21513
- </div>}
21514
- </For45>
21515
- </div>
21516
- </div>}
21517
- </Show59>
21704
+ <Show59 when={segments()}>{(seg) => <PeopleCard segments={seg()} days={days()} />}</Show59>
21518
21705
  </div>;
21519
21706
  }
21520
21707
 
@@ -22250,7 +22437,7 @@ function SmsCard(props) {
22250
22437
 
22251
22438
  // src/pages/admin/sms/SmsLogCard.tsx
22252
22439
  import { createSignal as createSignal44, For as For49, onMount as onMount7, Show as Show64 } from "solid-js";
22253
- var PAGE_SIZE = 25;
22440
+ var PAGE_SIZE2 = 25;
22254
22441
  var BASE_STATUSES = ["delivered", "sent", "failed", "blocked"];
22255
22442
  var humanize4 = (key) => key.replace(/([A-Z])/g, " $1").replace(/[_-]/g, " ").replace(/^\w/, (c) => c.toUpperCase()).trim();
22256
22443
  var statusVariant = (status) => {
@@ -22290,7 +22477,7 @@ function SmsLogCard(props) {
22290
22477
  const res = await adminApi.listSmsMessages({
22291
22478
  status: status() || void 0,
22292
22479
  before: more ? next() ?? void 0 : void 0,
22293
- limit: PAGE_SIZE
22480
+ limit: PAGE_SIZE2
22294
22481
  });
22295
22482
  if (mine !== generation) return;
22296
22483
  setRows(more ? [...rows(), ...res.messages] : res.messages);
@@ -26264,11 +26451,11 @@ function td2() {
26264
26451
  }
26265
26452
 
26266
26453
  // src/pages/affiliate/ReferralLink.tsx
26267
- import { Show as Show83, createSignal as createSignal57, createMemo as createMemo19 } from "solid-js";
26454
+ import { Show as Show83, createSignal as createSignal57, createMemo as createMemo20 } from "solid-js";
26268
26455
  function AffiliateReferralLink() {
26269
26456
  const { links } = useAffiliateLinks();
26270
26457
  const [copied, setCopied] = createSignal57(false);
26271
- const homepageLink = createMemo19(() => {
26458
+ const homepageLink = createMemo20(() => {
26272
26459
  const l = links();
26273
26460
  const affiliate = affiliateAuth_default.affiliate();
26274
26461
  const code = l?.affiliateCode ?? affiliate?.affiliateCode ?? "";
@@ -27994,4 +28181,4 @@ export {
27994
28181
  AffiliateForgotPassword,
27995
28182
  AffiliateResetPassword
27996
28183
  };
27997
- //# sourceMappingURL=FKEDRIA7.jsx.map
28184
+ //# sourceMappingURL=MFXFQISO.jsx.map