@apextelemed/partner-core 0.6.4 → 0.7.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.
- package/README.md +2 -2
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/index.jsx +3 -3
- package/dist/{cart-D4mVX_zx.d.ts → cart-o6DpAu5y.d.ts} +1 -0
- package/dist/chunk/{WLEIDQ5M.jsx → 4S4MTN2K.jsx} +6 -2
- package/dist/chunk/{NBB2VTQK.jsx → 4SFB2SS2.jsx} +2 -2
- package/dist/chunk/{BVLA7ATM.js → 64RJJFEH.js} +3 -3
- package/dist/chunk/{BVLA7ATM.js.map → 64RJJFEH.js.map} +1 -1
- package/dist/chunk/{EVCGDF5D.jsx → 7AFUT5S3.jsx} +9 -1
- package/dist/chunk/{ZDBW3JDO.jsx → 7AMVRNYX.jsx} +3286 -1423
- package/dist/chunk/{4ZSZHZQV.jsx → CBOGAYTL.jsx} +2 -2
- package/dist/chunk/{YJEHCCLY.js → EXXI5Y7I.js} +4 -3
- package/dist/chunk/EXXI5Y7I.js.map +1 -0
- package/dist/chunk/{MTCQREMZ.js → F34QLV7Z.js} +4063 -2058
- package/dist/chunk/F34QLV7Z.js.map +1 -0
- package/dist/chunk/{MLXPHJLR.js → GODF2NJN.js} +7 -3
- package/dist/chunk/GODF2NJN.js.map +1 -0
- package/dist/chunk/{WUE4VQBA.js → J3IRPONP.js} +392 -21
- package/dist/chunk/J3IRPONP.js.map +1 -0
- package/dist/chunk/{QTGJY3YQ.js → J3OK2PQA.js} +3 -3
- package/dist/chunk/{QTGJY3YQ.js.map → J3OK2PQA.js.map} +1 -1
- package/dist/chunk/{NSRQXBHK.js → KXO4U2C6.js} +8 -189
- package/dist/chunk/KXO4U2C6.js.map +1 -0
- package/dist/chunk/{HXMLRDIJ.jsx → PA66KUAU.jsx} +418 -26
- package/dist/chunk/{2OXI5TKO.jsx → RSMUKR4J.jsx} +3 -2
- package/dist/chunk/{5HNZ7SEM.jsx → SHXH72AC.jsx} +26 -219
- package/dist/chunk/{BEDW4XUM.js → UPZPR5TU.js} +10 -2
- package/dist/chunk/UPZPR5TU.js.map +1 -0
- package/dist/{client-B6Kt7LWo.d.ts → client-CiHb-dIf.d.ts} +64 -8
- package/dist/flows/index.d.ts +157 -13
- package/dist/flows/index.js +6 -6
- package/dist/flows/index.jsx +25 -13
- package/dist/index/index.d.ts +4 -4
- package/dist/index/index.js +8 -8
- package/dist/index/index.jsx +40 -16
- package/dist/pages/index.d.ts +41 -6
- package/dist/pages/index.js +5 -5
- package/dist/pages/index.jsx +19 -7
- package/dist/primitives/default/index.js +1 -1
- package/dist/primitives/default/index.jsx +1 -1
- package/dist/stores/index.d.ts +2 -2
- package/dist/stores/index.js +2 -2
- package/dist/stores/index.jsx +2 -2
- package/dist/testing/seam-suite.js +1 -1
- package/dist/theme/admin.css +406 -1
- package/dist/theme/member-portal.css +5 -5
- package/package.json +1 -1
- package/dist/chunk/BEDW4XUM.js.map +0 -1
- package/dist/chunk/MLXPHJLR.js.map +0 -1
- package/dist/chunk/MTCQREMZ.js.map +0 -1
- package/dist/chunk/NSRQXBHK.js.map +0 -1
- package/dist/chunk/WUE4VQBA.js.map +0 -1
- package/dist/chunk/YJEHCCLY.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onTokensCleared, authStorageKey, getTokens, usersApi, ApiError, affiliateAuthStorageKey, getAffiliateTokens, affiliatePortalApi, clearTokens, authApi, clearAffiliateTokens, setTokens, setAffiliateTokens } from './
|
|
1
|
+
import { onTokensCleared, authStorageKey, getTokens, usersApi, ApiError, affiliateAuthStorageKey, getAffiliateTokens, affiliatePortalApi, clearTokens, authApi, clearAffiliateTokens, setTokens, setAffiliateTokens } from './UPZPR5TU.js';
|
|
2
2
|
import { onConfigured, getConfig } from './5XGPFYIJ.js';
|
|
3
3
|
import { createRoot, createSignal, createMemo, batch } from 'solid-js';
|
|
4
4
|
|
|
@@ -73,6 +73,9 @@ function createCartStore() {
|
|
|
73
73
|
if (!current.some((i) => itemKey(i.productId, i.dosage) === key)) return;
|
|
74
74
|
write(current.map((i) => itemKey(i.productId, i.dosage) === key ? { ...i, quantity: clamped } : i));
|
|
75
75
|
}
|
|
76
|
+
function replace(next) {
|
|
77
|
+
write(next);
|
|
78
|
+
}
|
|
76
79
|
function clear() {
|
|
77
80
|
write([]);
|
|
78
81
|
}
|
|
@@ -95,6 +98,7 @@ function createCartStore() {
|
|
|
95
98
|
add,
|
|
96
99
|
remove,
|
|
97
100
|
setQuantity,
|
|
101
|
+
replace,
|
|
98
102
|
clear,
|
|
99
103
|
hasGlp1,
|
|
100
104
|
isMultiItem,
|
|
@@ -378,5 +382,5 @@ var medicationStore = createRoot(createMedicationStore);
|
|
|
378
382
|
var medication_default = medicationStore;
|
|
379
383
|
|
|
380
384
|
export { affiliateAuth_default, auth_default, cart_default, medication_default };
|
|
381
|
-
//# sourceMappingURL=
|
|
382
|
-
//# sourceMappingURL=
|
|
385
|
+
//# sourceMappingURL=GODF2NJN.js.map
|
|
386
|
+
//# sourceMappingURL=GODF2NJN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stores/cart.ts","../../src/stores/auth.ts","../../src/stores/affiliateAuth.ts","../../src/stores/medication.ts"],"names":["createSignal","createRoot","batch"],"mappings":";;;;AAGA,IAAM,cAAA,GAAiB,MAAM,CAAA,EAAG,SAAA,GAAY,aAAa,CAAA,KAAA,CAAA;AACzD,IAAM,eAAA,GAAkB,MAAM,CAAA,EAAG,SAAA,GAAY,aAAa,CAAA,WAAA,CAAA;AA4C1D,SAAS,OAAA,CAAQ,WAAmB,MAAA,EAAwB;AAC1D,EAAA,OAAO,CAAA,EAAG,SAAS,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA;AAChC;AAEA,SAAS,WAAA,GAA0B;AACjC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,YAAA,CAAa,OAA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AAwB;AAC/B,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAID,aAAyC,IAAI,CAAA;AAE7E,EAAA,SAAS,OAAO,UAAA,EAAiC;AAC/C,IAAA,WAAA,CAAY,UAAU,CAAA;AAAA,EACxB;AAEA,EAAA,SAAS,KAAA,GAAQ;AACf,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EAClB;AAEA,EAAA,OAAO,EAAE,QAAA,EAAU,MAAA,EAAQ,KAAA,EAAM;AACnC;AAEA,IAAM,eAAA,GAAkBC,WAAW,qBAAqB,CAAA;AACxD,IAAO,kBAAA,GAAQ","file":"GODF2NJN.js","sourcesContent":["import { createSignal, createRoot } from 'solid-js';\nimport { getConfig } from '../config';\n\nconst cartStorageKey = () => `${getConfig().storagePrefix}-cart`;\nconst promoStorageKey = () => `${getConfig().storagePrefix}-cart-promo`;\n\nexport interface CartItem {\n productId: string;\n productName: string;\n dosage: string;\n /** Dose redesign (Phase 8): optional patient-requested intake hints, mirroring\n * Apex intake — `requestedSku` is the binding patient-bought SKU,\n * `requestedClinicalDose` is the advisory dose. Default undefined; carried\n * through to the /apex/requests medications payload. Nothing sets these yet. */\n requestedSku?: string;\n /** SKU identity S4: the stable, opaque `skus[].id` form of `requestedSku`\n * (from Apex's /v1/drugs catalog). Preferred over the label — survives a\n * relabel. Additive; carried through to the medications payload. */\n requestedSkuId?: string;\n requestedClinicalDose?: { value: number; unit: string };\n quantity: number;\n priceCents: number;\n drugId: string | null;\n /** The linked Apex drug id, copied from the catalog product. Matches the id\n * the survey qualification verdict (`drugResults[].drugId`) is keyed on, so\n * request creation can gate out drugs the survey marked ineligible. Null/\n * undefined for non-Apex products or carts saved before this field existed. */\n apexDrugId?: string | null;\n categories: string[];\n thumbnailUrl?: string;\n /** True when the product uses flat_fee pricing. The dosage is still set\n * (Apex needs it for the prescription) but consumer cart drawers should\n * skip rendering the dose suffix. */\n hideDoseLabel?: boolean;\n /** Copied from the catalog's `is_subscription` at add-time. The one-time\n * checkout flow excludes subscription items (the backend 400s a\n * /payments/checkout containing one, and stays the authority). Undefined —\n * legacy persisted carts, non-catalog adds — is treated as one-time-purchasable. */\n isSubscription?: boolean;\n}\n\nexport interface AppliedPromoCode {\n code: string;\n discountType: 'percent' | 'fixed';\n discountValueCents: number;\n discountCents: number;\n}\n\nfunction itemKey(productId: string, dosage: string): string {\n return `${productId}::${dosage}`;\n}\n\nfunction loadInitial(): CartItem[] {\n try {\n const raw = localStorage.getItem(cartStorageKey());\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n // Preserve a sane persisted quantity (set via setQuantity); anything else\n // — legacy carts, tampered storage — normalizes back to 1.\n return parsed.map((i: CartItem) => ({\n ...i,\n quantity: Number.isInteger(i.quantity) && i.quantity > 0 ? i.quantity : 1,\n }));\n } catch {\n return [];\n }\n}\n\nfunction loadInitialPromo(): AppliedPromoCode | null {\n try {\n const raw = localStorage.getItem(promoStorageKey());\n if (!raw) return null;\n return JSON.parse(raw) as AppliedPromoCode;\n } catch {\n return null;\n }\n}\n\nfunction persist(items: CartItem[]) {\n try {\n localStorage.setItem(cartStorageKey(), JSON.stringify(items));\n } catch {\n // noop\n }\n}\n\nfunction persistPromo(promo: AppliedPromoCode | null) {\n try {\n if (promo) localStorage.setItem(promoStorageKey(), JSON.stringify(promo));\n else localStorage.removeItem(promoStorageKey());\n } catch {\n // noop\n }\n}\n\nfunction createCartStore() {\n const [items, setItems] = createSignal<CartItem[]>(loadInitial());\n const [isOpen, setIsOpen] = createSignal(false);\n const [appliedPromo, setAppliedPromo] = createSignal<AppliedPromoCode | null>(loadInitialPromo());\n\n function write(next: CartItem[]) {\n setItems(next);\n persist(next);\n }\n\n function count() {\n return items().length;\n }\n\n function subtotalCents() {\n return items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);\n }\n\n function add(item: CartItem) {\n const key = itemKey(item.productId, item.dosage);\n const current = items();\n if (current.some(i => itemKey(i.productId, i.dosage) === key)) return;\n write([...current, { ...item, quantity: 1 }]);\n }\n\n function remove(key: string) {\n write(items().filter(i => itemKey(i.productId, i.dosage) !== key));\n }\n\n /** Set an item's quantity (floored, clamped to ≥1 — removing is `remove`'s\n * job). Non-finite input and unknown keys are ignored. `add` still starts\n * every item at 1; this is the only quantity mutator. */\n function setQuantity(key: string, quantity: number) {\n if (!Number.isFinite(quantity)) return;\n const clamped = Math.max(1, Math.floor(quantity));\n const current = items();\n if (!current.some(i => itemKey(i.productId, i.dosage) === key)) return;\n write(current.map(i => (itemKey(i.productId, i.dosage) === key ? { ...i, quantity: clamped } : i)));\n }\n\n /**\n * Replace the whole cart in one write. For catalog reconciliation\n * (`flows/cartReconcile`), which drops lines the catalog no longer offers and\n * refreshes the snapshots of the ones it does — neither expressible as\n * add/remove, and both must land as a single persist so a half-written cart\n * can never be read back. Quantities are taken as given (unlike `add`, which\n * always starts at 1).\n */\n function replace(next: CartItem[]) {\n write(next);\n }\n\n function clear() {\n // Preserve the applied promo across cart resets — the survey submission\n // clears the cart but the customer still expects the code they entered to\n // apply to subsequent prescription purchases. Removing the promo is an\n // explicit action via the cart drawer's \"remove\" link.\n write([]);\n }\n\n function hasGlp1() {\n return items().some(i =>\n i.categories.some(c => c.toLowerCase().includes('weight') || c.toLowerCase().includes('glp')),\n );\n }\n\n function isMultiItem() {\n return items().length > 1;\n }\n\n function setPromo(promo: AppliedPromoCode | null) {\n setAppliedPromo(promo);\n persistPromo(promo);\n }\n\n return {\n items,\n count,\n subtotalCents,\n add,\n remove,\n setQuantity,\n replace,\n clear,\n hasGlp1,\n isMultiItem,\n itemKey,\n isOpen,\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen(v => !v),\n appliedPromo,\n setPromo,\n };\n}\n\nconst cartStore = createRoot(createCartStore);\nexport default cartStore;\n","import { createSignal, createMemo, createRoot, batch } from 'solid-js';\nimport { onConfigured } from '../config';\nimport {\n authApi,\n getTokens,\n setTokens,\n clearTokens,\n usersApi,\n ApiError,\n onTokensCleared,\n authStorageKey,\n type User,\n type AuthTokens,\n type RegisterPayload,\n type RegisterAndSubscribePayload,\n} from '../api/client';\nimport cartStore from './cart';\n\nfunction createAuthStore() {\n // ── Signals ─────────────────────────────────────────────────────\n\n const [tokens, _setTokens] = createSignal<AuthTokens | null>(null);\n const [user, setUser] = createSignal<User | null>(null);\n const [isAuthenticated, setIsAuthenticated] = createSignal(false);\n const [loading, setLoading] = createSignal(false);\n\n // Derived, not a second signal: admin-ness must never be observable out of\n // step with the user it describes. As separate writes, Solid flushed\n // dependents between setUser and setIsAdmin, so an admin gate combining\n // \"hydrated\" (user() !== null) with isAdmin() saw \"hydrated but not admin\"\n // for one tick on every hard load of /admin and bounced to the fallback\n // route.\n const isAdmin = createMemo(() => user()?.role === 'admin');\n\n // ── Internal helpers ────────────────────────────────────────────\n\n /** Reset the in-memory session signals WITHOUT touching token storage.\n * Used by the token-cleared/storage listeners, where storage is already\n * gone (writing it back would re-notify and loop). */\n function dropSession() {\n batch(() => {\n _setTokens(null);\n setIsAuthenticated(false);\n setUser(null);\n });\n }\n\n function syncTokens(t: AuthTokens | null) {\n _setTokens(t);\n if (t) {\n setTokens(t);\n setIsAuthenticated(true);\n } else {\n clearTokens();\n dropSession();\n // Kiosk/shared-browser hygiene: ending the session must not hand the\n // next visitor the previous member's cart + promo (audit cart.ts:4).\n // Done HERE — not in dropSession — so an explicit logout or definitive\n // auth rejection wipes them, while an out-of-band token expiry in the\n // middle of an active shopper's visit leaves their cart alone.\n // Deliberately NOT userId-namespaced: the cart is populated anonymously\n // pre-signup and must survive the anonymous→signup transition.\n cartStore.clear();\n cartStore.setPromo(null);\n }\n }\n\n // The transport clears tokens out-of-band (refresh failure, post-refresh\n // 401). Without this subscription isAuthenticated() stayed true and the\n // chrome kept rendering an authenticated shell whose every request 401s\n // until a hard reload (audit auth.ts:26).\n onTokensCleared('patient', dropSession);\n\n // Cross-tab convergence: logout (or login) in another tab updates shared\n // localStorage but fires no event in-store — converge on the peer's state.\n // The `storage` event never fires in the acting tab, which is why the\n // same-tab path above is a separate, direct subscription.\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n let key: string;\n try {\n key = authStorageKey();\n } catch {\n return; // not configured yet — nothing to converge on\n }\n if (e.key !== null && e.key !== key) return; // null key = storage.clear()\n const stored = getTokens();\n if (stored?.accessToken) {\n const wasAuthenticated = isAuthenticated();\n batch(() => {\n _setTokens(stored);\n setIsAuthenticated(true);\n });\n if (!wasAuthenticated) void fetchProfile();\n } else {\n dropSession();\n }\n });\n }\n\n async function fetchProfile() {\n try {\n const res = await usersApi.getProfile();\n if (res.data) {\n setUser(res.data);\n }\n } catch (err) {\n // Only a definitive auth rejection ends the session. The transport has\n // already refreshed-and-retried before a 401 reaches here (and cleared\n // the stored tokens itself); a transient 5xx / network blip during a\n // reload must NOT destroy a valid refresh token and force-log-out a\n // returning member (audit auth.ts:46). The profile simply stays\n // unhydrated and can be fetched again later.\n if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {\n syncTokens(null);\n }\n }\n }\n\n // ── Initialize ──────────────────────────────────────────────────\n\n // Hydrate from token storage AFTER `configure()` runs. The store is a\n // singleton created at import time (see `createRoot` below), which is before\n // the host site calls `configure()`; reading `getTokens()` then would route\n // through `getConfig()` and throw, leaving a returning member rendered\n // logged-out until their first live API call. `onConfigured` defers this.\n let hydrated = false;\n function hydrate() {\n if (hydrated) return;\n hydrated = true;\n const stored = getTokens();\n if (stored?.accessToken) {\n _setTokens(stored);\n setIsAuthenticated(true);\n // Fire-and-forget profile hydration\n fetchProfile();\n }\n }\n onConfigured(hydrate);\n\n // ── Public API ──────────────────────────────────────────────────\n\n async function login(email: string, password: string) {\n setLoading(true);\n try {\n const res = await authApi.login({ email, password });\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n // Backend login doesn't return full user profile — fetch it\n await fetchProfile();\n }\n } finally {\n setLoading(false);\n }\n }\n\n async function signup(payload: RegisterPayload) {\n setLoading(true);\n try {\n const res = await authApi.register(payload);\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n await fetchProfile();\n }\n } finally {\n setLoading(false);\n }\n }\n\n async function signupAndSubscribe(\n payload: RegisterAndSubscribePayload,\n opts?: { idempotencyKey?: string },\n ) {\n setLoading(true);\n try {\n const res = await authApi.registerAndSubscribe(payload, opts);\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n await fetchProfile();\n return res.data;\n }\n } finally {\n setLoading(false);\n }\n }\n\n function logout() {\n syncTokens(null);\n }\n\n return {\n // Reactive getters\n tokens,\n user,\n isAuthenticated,\n isAdmin,\n loading,\n // Actions\n login,\n signup,\n signupAndSubscribe,\n logout,\n fetchProfile,\n };\n}\n\n// Singleton store created inside a reactive root\nconst authStore = createRoot(createAuthStore);\nexport default authStore;\n","import { createSignal, createRoot, batch } from 'solid-js';\nimport { onConfigured } from '../config';\nimport {\n affiliatePortalApi,\n getAffiliateTokens,\n setAffiliateTokens,\n clearAffiliateTokens,\n ApiError,\n onTokensCleared,\n affiliateAuthStorageKey,\n type Affiliate,\n type AffiliateAuthTokens,\n type AffiliateRegisterInput,\n} from '../api/client';\n\nfunction createAffiliateAuthStore() {\n const [tokens, _setTokens] = createSignal<AffiliateAuthTokens | null>(null);\n const [affiliate, setAffiliate] = createSignal<Affiliate | null>(null);\n const [isAuthenticated, setIsAuthenticated] = createSignal(false);\n const [isHydrated, setIsHydrated] = createSignal(false);\n const [loading, setLoading] = createSignal(false);\n\n /** Reset in-memory session signals WITHOUT touching token storage (see\n * stores/auth.ts dropSession — same loop-avoidance rationale). */\n function dropSession() {\n // Batched so a consumer combining these signals can never observe a\n // half-dropped session between flushes (same class of glitch as the\n // patient store's setUser→setIsAdmin admin-gate race).\n batch(() => {\n _setTokens(null);\n setIsAuthenticated(false);\n setAffiliate(null);\n });\n }\n\n function syncTokens(t: AffiliateAuthTokens | null) {\n _setTokens(t);\n if (t) {\n setAffiliateTokens(t);\n setIsAuthenticated(true);\n } else {\n clearAffiliateTokens();\n dropSession();\n }\n }\n\n // Same-tab: the transport's refresh-failure path clears affiliate tokens\n // out-of-band — flip the store immediately instead of rendering a stuck\n // authenticated-but-empty portal until a manual reload (audit client.ts:1682).\n onTokensCleared('affiliate', dropSession);\n\n // Cross-tab: converge on a peer tab's logout/login (audit affiliateAuth.ts:16).\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n let key: string;\n try {\n key = affiliateAuthStorageKey();\n } catch {\n return; // not configured yet\n }\n if (e.key !== null && e.key !== key) return; // null key = storage.clear()\n const stored = getAffiliateTokens();\n if (stored?.accessToken) {\n const wasAuthenticated = isAuthenticated();\n _setTokens(stored);\n setIsAuthenticated(true);\n if (!wasAuthenticated) void fetchProfile();\n } else {\n dropSession();\n }\n });\n }\n\n async function fetchProfile() {\n try {\n const res = await affiliatePortalApi.getProfile();\n setAffiliate(res.affiliate);\n } catch (err) {\n // Clear only on a definitive auth rejection (the transport has already\n // refreshed-and-retried before a 401 surfaces here). A transient\n // 5xx/network blip during hydration or right after login() must not\n // erase a valid refresh token — that logged out every affiliate loading\n // the app during a backend hiccup, and made login() resolve into an\n // instantly-dead session (audit affiliateAuth.ts:43 + :59). On a\n // transient failure the session stands; the profile stays null and can\n // be re-fetched.\n if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {\n syncTokens(null);\n }\n } finally {\n setIsHydrated(true);\n }\n }\n\n // Hydrate from token storage after `configure()` (see stores/auth.ts for the\n // boot-ordering rationale). fetchProfile() flips isHydrated in its finally;\n // the no-session branch flips it here.\n let hydrated = false;\n function hydrate() {\n if (hydrated) return;\n hydrated = true;\n const stored = getAffiliateTokens();\n if (stored?.accessToken) {\n _setTokens(stored);\n setIsAuthenticated(true);\n fetchProfile();\n } else {\n setIsHydrated(true);\n }\n }\n onConfigured(hydrate);\n\n async function login(email: string, password: string) {\n setLoading(true);\n try {\n const session = await affiliatePortalApi.login(email, password);\n syncTokens({\n accessToken: session.idToken,\n refreshToken: session.refreshToken,\n affiliateId: session.affiliateId,\n });\n setIsHydrated(false);\n await fetchProfile();\n } finally {\n setLoading(false);\n }\n }\n\n async function register(input: AffiliateRegisterInput) {\n setLoading(true);\n try {\n await affiliatePortalApi.register(input);\n // Backend register does NOT return tokens — new affiliates start as\n // 'pending' and must be approved by an admin before they can log in.\n // We surface the affiliate ID via the resolved promise so the page\n // can show a \"pending approval\" success state without logging in.\n } finally {\n setLoading(false);\n }\n }\n\n async function logout() {\n try {\n await affiliatePortalApi.logout();\n } finally {\n syncTokens(null);\n }\n }\n\n return {\n tokens,\n affiliate,\n isAuthenticated,\n isHydrated,\n loading,\n login,\n register,\n logout,\n fetchProfile,\n };\n}\n\nconst affiliateAuthStore = createRoot(createAffiliateAuthStore);\nexport default affiliateAuthStore;\n","import { createSignal, createRoot } from 'solid-js';\n\nexport interface MedicationSelection {\n drugId: string | null; // null = general consultation\n drugName: string;\n}\n\nfunction createMedicationStore() {\n const [selected, setSelected] = createSignal<MedicationSelection | null>(null);\n\n function select(medication: MedicationSelection) {\n setSelected(medication);\n }\n\n function clear() {\n setSelected(null);\n }\n\n return { selected, select, clear };\n}\n\nconst medicationStore = createRoot(createMedicationStore);\nexport default medicationStore;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './
|
|
2
|
-
import { cart_default, medication_default, auth_default, affiliateAuth_default } from './
|
|
3
|
-
import { newIdempotencyKey, apexApi, usersApi, addressesApi, paymentsApi, subscriptionsApi, membersApi, affiliatePortalApi, ApiError, ordersApi,
|
|
1
|
+
import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './J3OK2PQA.js';
|
|
2
|
+
import { cart_default, medication_default, auth_default, affiliateAuth_default } from './GODF2NJN.js';
|
|
3
|
+
import { newIdempotencyKey, apexApi, usersApi, addressesApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, ApiError, ordersApi, messagesApi, authApi } from './UPZPR5TU.js';
|
|
4
4
|
import { getConfig } from './5XGPFYIJ.js';
|
|
5
|
-
import { createSignal, onMount, createEffect, onCleanup, createResource } from 'solid-js';
|
|
5
|
+
import { createSignal, onMount, createEffect, onCleanup, on, createResource, createMemo } from 'solid-js';
|
|
6
6
|
import { useSurveyV2Flow as useSurveyV2Flow$1 } from '@apextelemed/survey-solid';
|
|
7
7
|
import { createLocalDraftStore, draftKey as draftKey$1 } from '@apextelemed/survey-core';
|
|
8
8
|
|
|
@@ -116,13 +116,23 @@ function useSurveyFlow(options = {}) {
|
|
|
116
116
|
const [createRequestKey, setCreateRequestKey] = createSignal(newIdempotencyKey());
|
|
117
117
|
const [hydrated, setHydrated] = createSignal(false);
|
|
118
118
|
const totalSteps = () => steps().length;
|
|
119
|
-
const isLastStep = () => currentStep() >= totalSteps() - 1;
|
|
120
119
|
const step2 = () => steps()[currentStep()] ?? null;
|
|
121
120
|
const visibleQuestions = () => {
|
|
122
121
|
const s = step2();
|
|
123
122
|
if (!s) return [];
|
|
124
123
|
return s.questions.filter((q) => isQuestionVisible(q, answers()));
|
|
125
124
|
};
|
|
125
|
+
const stepHasVisibleQuestions = (i) => {
|
|
126
|
+
const s = steps()[i];
|
|
127
|
+
return !!s && s.questions.some((q) => isQuestionVisible(q, answers()));
|
|
128
|
+
};
|
|
129
|
+
const nearestVisibleStep = (from, dir) => {
|
|
130
|
+
for (let i = from + dir; i >= 0 && i < steps().length; i += dir) {
|
|
131
|
+
if (stepHasVisibleQuestions(i)) return i;
|
|
132
|
+
}
|
|
133
|
+
return -1;
|
|
134
|
+
};
|
|
135
|
+
const isLastStep = () => nearestVisibleStep(currentStep(), 1) === -1;
|
|
126
136
|
onMount(async () => {
|
|
127
137
|
const cartItems = cart_default.items();
|
|
128
138
|
const hasCart = cartItems.length > 0;
|
|
@@ -184,7 +194,12 @@ function useSurveyFlow(options = {}) {
|
|
|
184
194
|
const draft = loadSurveyDraft();
|
|
185
195
|
if (draft.surveyId === sid) {
|
|
186
196
|
if (draft.answers) setAnswers(draft.answers);
|
|
187
|
-
|
|
197
|
+
const restoredStep = Math.min(Math.max(draft.currentStep ?? 0, 0), Math.max(flat.length - 1, 0));
|
|
198
|
+
setCurrentStep(restoredStep);
|
|
199
|
+
if (!stepHasVisibleQuestions(restoredStep)) {
|
|
200
|
+
const fwd = nearestVisibleStep(restoredStep, 1);
|
|
201
|
+
setCurrentStep(fwd !== -1 ? fwd : Math.max(nearestVisibleStep(restoredStep, -1), 0));
|
|
202
|
+
}
|
|
188
203
|
if (draft.responseId) setResponseId(draft.responseId);
|
|
189
204
|
if (draft.submitSurveyKey) setSubmitSurveyKey(draft.submitSurveyKey);
|
|
190
205
|
if (draft.createRequestKey) setCreateRequestKey(draft.createRequestKey);
|
|
@@ -419,11 +434,13 @@ function useSurveyFlow(options = {}) {
|
|
|
419
434
|
} finally {
|
|
420
435
|
setSubmitting(false);
|
|
421
436
|
}
|
|
422
|
-
|
|
437
|
+
const nextStep = nearestVisibleStep(currentStep(), 1);
|
|
438
|
+
if (nextStep !== -1) setCurrentStep(nextStep);
|
|
423
439
|
}
|
|
424
440
|
function back() {
|
|
425
441
|
setValidationError(null);
|
|
426
|
-
|
|
442
|
+
const prev = nearestVisibleStep(currentStep(), -1);
|
|
443
|
+
if (prev !== -1) setCurrentStep(prev);
|
|
427
444
|
}
|
|
428
445
|
async function confirmDrugSelection() {
|
|
429
446
|
if (!selectedDrugId()) {
|
|
@@ -1382,6 +1399,10 @@ function useSignupFlow(options) {
|
|
|
1382
1399
|
const [tokenizedData, setTokenizedData] = createSignal(null);
|
|
1383
1400
|
const [promoCode, setPromoCode] = createSignal("");
|
|
1384
1401
|
const [idempotencyKey, setIdempotencyKey] = createSignal(newIdempotencyKey());
|
|
1402
|
+
const cartIsEmpty = () => cart_default.items().length === 0;
|
|
1403
|
+
onMount(() => {
|
|
1404
|
+
if (options.requireCart && cartIsEmpty()) setOutcome({ kind: "needs_cart" });
|
|
1405
|
+
});
|
|
1385
1406
|
onMount(() => {
|
|
1386
1407
|
createEffect(() => {
|
|
1387
1408
|
saveDraft({
|
|
@@ -1487,6 +1508,10 @@ function useSignupFlow(options) {
|
|
|
1487
1508
|
}
|
|
1488
1509
|
async function submit() {
|
|
1489
1510
|
if (submitting()) return;
|
|
1511
|
+
if (options.requireCart && cartIsEmpty()) {
|
|
1512
|
+
setOutcome({ kind: "needs_cart" });
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1490
1515
|
const opaque = tokenizedData();
|
|
1491
1516
|
if (!opaque) {
|
|
1492
1517
|
setError("Card not tokenized. Please go back and re-enter your card details.");
|
|
@@ -1866,6 +1891,8 @@ function useSubscribeFlow(options) {
|
|
|
1866
1891
|
const [outcome, setOutcome] = createSignal({ kind: "loading" });
|
|
1867
1892
|
const [error, setError] = createSignal(null);
|
|
1868
1893
|
const [submitting, setSubmitting] = createSignal(false);
|
|
1894
|
+
const [quote, setQuote] = createSignal(null);
|
|
1895
|
+
const [quoteError, setQuoteError] = createSignal(null);
|
|
1869
1896
|
const [street, setStreet] = createSignal("");
|
|
1870
1897
|
const [city, setCity] = createSignal("");
|
|
1871
1898
|
const [state, setState] = createSignal("");
|
|
@@ -1903,6 +1930,83 @@ function useSubscribeFlow(options) {
|
|
|
1903
1930
|
}
|
|
1904
1931
|
setOutcome({ kind: "in_progress" });
|
|
1905
1932
|
});
|
|
1933
|
+
const cartProducts = () => cart_default.items().map((i) => ({
|
|
1934
|
+
productId: i.productId,
|
|
1935
|
+
productName: i.productName,
|
|
1936
|
+
quantity: i.quantity,
|
|
1937
|
+
dosage: i.dosage
|
|
1938
|
+
}));
|
|
1939
|
+
function estimateFromCart() {
|
|
1940
|
+
const lines = cart_default.items().map((i) => ({
|
|
1941
|
+
productId: i.productId,
|
|
1942
|
+
productName: i.productName,
|
|
1943
|
+
dosage: i.dosage || null,
|
|
1944
|
+
quantity: i.quantity || 1,
|
|
1945
|
+
amountCents: i.priceCents * (i.quantity || 1)
|
|
1946
|
+
}));
|
|
1947
|
+
let subtotalCents = lines.reduce((s, l) => s + l.amountCents, 0);
|
|
1948
|
+
if (subtotalCents === 0 && lines.length === 0) subtotalCents = options.membershipAmountCents;
|
|
1949
|
+
const discountCents = Math.min(subtotalCents, cart_default.appliedPromo()?.discountCents ?? 0);
|
|
1950
|
+
return {
|
|
1951
|
+
source: "estimate",
|
|
1952
|
+
model: "per_product",
|
|
1953
|
+
intervalDays: options.membershipIntervalDays ?? 30,
|
|
1954
|
+
lines,
|
|
1955
|
+
subtotalCents,
|
|
1956
|
+
discountCents,
|
|
1957
|
+
totalCents: subtotalCents - discountCents
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
let quoteSeq = 0;
|
|
1961
|
+
async function refreshQuote() {
|
|
1962
|
+
const seq = ++quoteSeq;
|
|
1963
|
+
setQuoteError(null);
|
|
1964
|
+
try {
|
|
1965
|
+
const p = await subscriptionsApi.preview({
|
|
1966
|
+
products: cartProducts(),
|
|
1967
|
+
productId: cartProducts()[0]?.productId,
|
|
1968
|
+
promoCode: cart_default.appliedPromo()?.code,
|
|
1969
|
+
intervalDays: options.membershipIntervalDays
|
|
1970
|
+
});
|
|
1971
|
+
if (seq !== quoteSeq) return;
|
|
1972
|
+
if (p.alreadySubscribed) {
|
|
1973
|
+
setOutcome({ kind: "already_subscribed" });
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
setQuote({
|
|
1977
|
+
source: "server",
|
|
1978
|
+
model: p.model,
|
|
1979
|
+
intervalDays: p.intervalDays,
|
|
1980
|
+
lines: (p.lines ?? []).map((l) => ({
|
|
1981
|
+
productId: l.productId,
|
|
1982
|
+
productName: l.productName,
|
|
1983
|
+
dosage: l.dosage ?? null,
|
|
1984
|
+
quantity: l.quantity,
|
|
1985
|
+
amountCents: l.amountCents
|
|
1986
|
+
})),
|
|
1987
|
+
subtotalCents: p.subtotalCents,
|
|
1988
|
+
discountCents: p.discountCents,
|
|
1989
|
+
totalCents: p.totalCents
|
|
1990
|
+
});
|
|
1991
|
+
} catch (e) {
|
|
1992
|
+
if (seq !== quoteSeq) return;
|
|
1993
|
+
const status = e instanceof ApiError ? e.status : void 0;
|
|
1994
|
+
if (status && status >= 400 && status < 500 && status !== 404 && status !== 405) {
|
|
1995
|
+
setQuote(null);
|
|
1996
|
+
setQuoteError(e instanceof Error ? e.message : "This order cannot be priced right now.");
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
setQuote(estimateFromCart());
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
createEffect(
|
|
2003
|
+
on(
|
|
2004
|
+
() => [outcome().kind, cart_default.items(), cart_default.appliedPromo()],
|
|
2005
|
+
([kind]) => {
|
|
2006
|
+
if (kind === "in_progress") void refreshQuote();
|
|
2007
|
+
}
|
|
2008
|
+
)
|
|
2009
|
+
);
|
|
1906
2010
|
function validate() {
|
|
1907
2011
|
const a = validateAddress(
|
|
1908
2012
|
{ street: street(), city: city(), state: state(), zip: zip() },
|
|
@@ -1926,6 +2030,10 @@ function useSubscribeFlow(options) {
|
|
|
1926
2030
|
setOutcome({ kind: "needs_cart" });
|
|
1927
2031
|
return;
|
|
1928
2032
|
}
|
|
2033
|
+
if (quoteError()) {
|
|
2034
|
+
setError(quoteError());
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
1929
2037
|
const err = validate();
|
|
1930
2038
|
if (err) {
|
|
1931
2039
|
setError(err);
|
|
@@ -1949,7 +2057,9 @@ function useSubscribeFlow(options) {
|
|
|
1949
2057
|
const res = await subscriptionsApi.create(
|
|
1950
2058
|
{
|
|
1951
2059
|
opaqueData: opaque,
|
|
1952
|
-
|
|
2060
|
+
// Informational only — the backend prices the cart itself. Send what
|
|
2061
|
+
// the customer was shown so the two are auditable together.
|
|
2062
|
+
amountCents: quote()?.totalCents ?? options.membershipAmountCents,
|
|
1953
2063
|
intervalDays: options.membershipIntervalDays ?? 30,
|
|
1954
2064
|
billingAddress: {
|
|
1955
2065
|
street: street().trim(),
|
|
@@ -1997,6 +2107,8 @@ function useSubscribeFlow(options) {
|
|
|
1997
2107
|
acceptJsError: accept.error,
|
|
1998
2108
|
error,
|
|
1999
2109
|
submitting,
|
|
2110
|
+
quote,
|
|
2111
|
+
quoteError,
|
|
2000
2112
|
street,
|
|
2001
2113
|
setStreet,
|
|
2002
2114
|
city,
|
|
@@ -2374,7 +2486,7 @@ var LIFECYCLE_LABEL = {
|
|
|
2374
2486
|
past_due: "Past due",
|
|
2375
2487
|
paused: "Paused",
|
|
2376
2488
|
incomplete: "Incomplete signup",
|
|
2377
|
-
cancelled: "
|
|
2489
|
+
cancelled: "Canceled",
|
|
2378
2490
|
card_declined: "Card declined",
|
|
2379
2491
|
awaiting_prescriber: "Awaiting prescriber",
|
|
2380
2492
|
never_subscribed: "Never subscribed"
|
|
@@ -2528,12 +2640,12 @@ function lifecycleReason(o) {
|
|
|
2528
2640
|
o.subscriptions.filter((x) => x.status === "cancelled"),
|
|
2529
2641
|
(x) => x.cancelledAt
|
|
2530
2642
|
)[0] ?? sub;
|
|
2531
|
-
if (!s) return "Subscription
|
|
2643
|
+
if (!s) return "Subscription canceled.";
|
|
2532
2644
|
const started = ms(s.createdAt);
|
|
2533
2645
|
const ended = ms(s.cancelledAt);
|
|
2534
2646
|
const months = started !== null && ended !== null ? Math.max(0, Math.round((ended - started) / (30 * DAY_MS2))) : null;
|
|
2535
2647
|
const tenure = months !== null && months > 0 ? ` after ${months} month${months === 1 ? "" : "s"}` : "";
|
|
2536
|
-
return `
|
|
2648
|
+
return `Canceled on ${fmtDay(s.cancelledAt)}${tenure}.`;
|
|
2537
2649
|
}
|
|
2538
2650
|
default:
|
|
2539
2651
|
return o.lifecycle.label || "";
|
|
@@ -2659,7 +2771,7 @@ function deriveAttention(o, now = /* @__PURE__ */ new Date()) {
|
|
|
2659
2771
|
id: "cancelled-with-pending",
|
|
2660
2772
|
severity: "warning",
|
|
2661
2773
|
title: `${pending.length} unapproved prescription request${pending.length === 1 ? " is" : "s are"} still in the prescriber queue after cancellation`,
|
|
2662
|
-
detail: "A
|
|
2774
|
+
detail: "A canceled customer should not be prescribed. Cancel the pending requests.",
|
|
2663
2775
|
action: { kind: "cancel_unapproved", label: "Cancel unapproved requests" }
|
|
2664
2776
|
});
|
|
2665
2777
|
}
|
|
@@ -2685,8 +2797,8 @@ var JOURNEY_LABEL = {
|
|
|
2685
2797
|
shipped: "Shipped",
|
|
2686
2798
|
renewing: "Renewing"
|
|
2687
2799
|
};
|
|
2688
|
-
function step(key, state, date = null, detail = null) {
|
|
2689
|
-
return { key, label
|
|
2800
|
+
function step(key, state, date = null, detail = null, label = JOURNEY_LABEL[key]) {
|
|
2801
|
+
return { key, label, state, date, detail };
|
|
2690
2802
|
}
|
|
2691
2803
|
function deriveJourney(o) {
|
|
2692
2804
|
const steps = [];
|
|
@@ -2818,7 +2930,7 @@ function deriveJourney(o) {
|
|
|
2818
2930
|
}
|
|
2819
2931
|
} else if (subs.some((s) => s.status === "cancelled")) {
|
|
2820
2932
|
const c = newestFirst(subs.filter((s) => s.status === "cancelled"), (s) => s.cancelledAt)[0];
|
|
2821
|
-
steps.push(step("renewing", "blocked", c?.cancelledAt ?? null, "
|
|
2933
|
+
steps.push(step("renewing", "blocked", c?.cancelledAt ?? null, "Subscription ended", "Canceled"));
|
|
2822
2934
|
} else {
|
|
2823
2935
|
steps.push(step("renewing", "upcoming"));
|
|
2824
2936
|
}
|
|
@@ -2918,7 +3030,7 @@ function buildTimeline(o, limit = 200) {
|
|
|
2918
3030
|
ev.push({ id: `sub-paused-${s.id}`, at: s.pausedAt, kind: "subscription", title: "Subscription paused", tone: "neutral" });
|
|
2919
3031
|
}
|
|
2920
3032
|
if (s.cancelledAt) {
|
|
2921
|
-
ev.push({ id: `sub-cancelled-${s.id}`, at: s.cancelledAt, kind: "subscription", title: "Subscription
|
|
3033
|
+
ev.push({ id: `sub-cancelled-${s.id}`, at: s.cancelledAt, kind: "subscription", title: "Subscription canceled", tone: "danger" });
|
|
2922
3034
|
}
|
|
2923
3035
|
for (const a of s.billingAttempts ?? []) {
|
|
2924
3036
|
if (a.status === "succeeded") continue;
|
|
@@ -3203,10 +3315,12 @@ async function subscribeToSupportTopic(topic, onPing) {
|
|
|
3203
3315
|
try {
|
|
3204
3316
|
const config = await supportApi.getRealtimeToken();
|
|
3205
3317
|
if (!config?.token || !config.url || !config.anonKey) return null;
|
|
3318
|
+
const topicName = typeof topic === "string" ? topic : config.topics ? topic(config.topics) : void 0;
|
|
3319
|
+
if (!topicName) return null;
|
|
3206
3320
|
const { createClient } = await import('@supabase/supabase-js');
|
|
3207
3321
|
const client = createClient(config.url, config.anonKey);
|
|
3208
3322
|
await client.realtime.setAuth(config.token);
|
|
3209
|
-
const channel = client.channel(
|
|
3323
|
+
const channel = client.channel(topicName, {
|
|
3210
3324
|
config: { private: true }
|
|
3211
3325
|
});
|
|
3212
3326
|
channel.on("broadcast", { event: "thread_updated" }, (message) => {
|
|
@@ -3701,6 +3815,224 @@ function useMessagesThread(options = {}) {
|
|
|
3701
3815
|
resolveAttachmentUrl
|
|
3702
3816
|
};
|
|
3703
3817
|
}
|
|
3818
|
+
function priceForDosage(product, dosage) {
|
|
3819
|
+
const overlay = (product.dosage_prices ?? []).find((d) => d.dosage === dosage);
|
|
3820
|
+
if (overlay && overlay.price != null) return overlay.price;
|
|
3821
|
+
return product.price;
|
|
3822
|
+
}
|
|
3823
|
+
function lowestPrice(product) {
|
|
3824
|
+
const available = product.available_dosages ?? [];
|
|
3825
|
+
if (available.length === 0) return product.price;
|
|
3826
|
+
let min = null;
|
|
3827
|
+
for (const dose of available) {
|
|
3828
|
+
const p = priceForDosage(product, dose);
|
|
3829
|
+
if (p != null && (min == null || p < min)) min = p;
|
|
3830
|
+
}
|
|
3831
|
+
return min ?? product.price;
|
|
3832
|
+
}
|
|
3833
|
+
function salePriceForBase(product, basePrice) {
|
|
3834
|
+
if (basePrice == null || !product.activeSale) return null;
|
|
3835
|
+
const sale = product.activeSale;
|
|
3836
|
+
const baseCents = Math.round(basePrice * 100);
|
|
3837
|
+
if (sale.discountCents <= 0) return null;
|
|
3838
|
+
if (product.salePriceCents != null && product.price != null && Math.abs(product.price - basePrice) < 1e-3) {
|
|
3839
|
+
return product.salePriceCents / 100;
|
|
3840
|
+
}
|
|
3841
|
+
if (product.price != null && product.salePriceCents != null && product.price > 0) {
|
|
3842
|
+
const ratio = product.salePriceCents / Math.round(product.price * 100);
|
|
3843
|
+
return Math.max(0, basePrice * ratio);
|
|
3844
|
+
}
|
|
3845
|
+
return Math.max(0, (baseCents - sale.discountCents) / 100);
|
|
3846
|
+
}
|
|
3847
|
+
function lowestSalePrice(product, basePrice) {
|
|
3848
|
+
return salePriceForBase(product, basePrice);
|
|
3849
|
+
}
|
|
3850
|
+
function useCatalog() {
|
|
3851
|
+
const [products] = createResource(async () => {
|
|
3852
|
+
try {
|
|
3853
|
+
const res = await productsApi.list();
|
|
3854
|
+
return res.products;
|
|
3855
|
+
} catch {
|
|
3856
|
+
return [];
|
|
3857
|
+
}
|
|
3858
|
+
});
|
|
3859
|
+
const weightLoss = () => (products() ?? []).filter((p) => (p.categories ?? []).includes("weight-loss"));
|
|
3860
|
+
const peptides = () => (products() ?? []).filter((p) => !(p.categories ?? []).includes("weight-loss"));
|
|
3861
|
+
const filterByCategory = (slug) => (products() ?? []).filter((p) => (p.categories ?? []).includes(slug));
|
|
3862
|
+
return { products, weightLoss, peptides, filterByCategory };
|
|
3863
|
+
}
|
|
3864
|
+
function useProductDetail(productId) {
|
|
3865
|
+
const [product] = createResource(productId, async (id) => {
|
|
3866
|
+
if (!id) return null;
|
|
3867
|
+
try {
|
|
3868
|
+
const res = await productsApi.list();
|
|
3869
|
+
return res.products.find((p) => p.id === id) ?? null;
|
|
3870
|
+
} catch {
|
|
3871
|
+
return null;
|
|
3872
|
+
}
|
|
3873
|
+
});
|
|
3874
|
+
const pricingMode = createMemo(
|
|
3875
|
+
() => product()?.pricing_mode ?? "per_dose"
|
|
3876
|
+
);
|
|
3877
|
+
const dosageOptions = createMemo(() => {
|
|
3878
|
+
const p = product();
|
|
3879
|
+
if (!p) return [];
|
|
3880
|
+
const all = (p.available_dosages ?? []).map((dosage) => {
|
|
3881
|
+
const overlay = (p.dosage_prices ?? []).find((d) => d.dosage === dosage);
|
|
3882
|
+
const price = overlay && overlay.price != null ? overlay.price : p.price;
|
|
3883
|
+
return { dosage, price, savingsPrice: overlay?.savingsPrice ?? null };
|
|
3884
|
+
}).filter((o) => o.price != null);
|
|
3885
|
+
if (pricingMode() !== "flat_fee" || all.length === 0) return all;
|
|
3886
|
+
const override = p.dosage_override;
|
|
3887
|
+
const chosen = override && all.find((d) => d.dosage === override) || all[0];
|
|
3888
|
+
return [chosen];
|
|
3889
|
+
});
|
|
3890
|
+
const [selectedDosage, setSelectedDosage] = createSignal("");
|
|
3891
|
+
createMemo(() => {
|
|
3892
|
+
const opts = dosageOptions();
|
|
3893
|
+
if (opts.length > 0 && !selectedDosage()) setSelectedDosage(opts[0].dosage);
|
|
3894
|
+
});
|
|
3895
|
+
const selectedPrice = createMemo(() => {
|
|
3896
|
+
const opts = dosageOptions();
|
|
3897
|
+
const chosen = opts.find((d) => d.dosage === selectedDosage());
|
|
3898
|
+
if (chosen) return chosen.price;
|
|
3899
|
+
return product()?.price ?? null;
|
|
3900
|
+
});
|
|
3901
|
+
const selectedSalePrice = createMemo(() => {
|
|
3902
|
+
const p = product();
|
|
3903
|
+
const base = selectedPrice();
|
|
3904
|
+
if (!p || base == null || !p.activeSale) return null;
|
|
3905
|
+
if (p.salePriceCents != null && p.price != null && p.price > 0) {
|
|
3906
|
+
const ratio = p.salePriceCents / Math.round(p.price * 100);
|
|
3907
|
+
return Math.max(0, base * ratio);
|
|
3908
|
+
}
|
|
3909
|
+
return Math.max(0, base - p.activeSale.discountCents / 100);
|
|
3910
|
+
});
|
|
3911
|
+
const inCart = createMemo(() => {
|
|
3912
|
+
const p = product();
|
|
3913
|
+
if (!p) return false;
|
|
3914
|
+
const dosage = selectedDosage() || (dosageOptions()[0]?.dosage ?? "");
|
|
3915
|
+
const key = cart_default.itemKey(p.id, dosage);
|
|
3916
|
+
return cart_default.items().some((i) => cart_default.itemKey(i.productId, i.dosage) === key);
|
|
3917
|
+
});
|
|
3918
|
+
function addToCart() {
|
|
3919
|
+
const p = product();
|
|
3920
|
+
if (!p) return;
|
|
3921
|
+
const dosage = selectedDosage() || (dosageOptions()[0]?.dosage ?? "");
|
|
3922
|
+
const effective = selectedSalePrice() ?? selectedPrice() ?? 0;
|
|
3923
|
+
const priceCents = Math.round(effective * 100);
|
|
3924
|
+
cart_default.add({
|
|
3925
|
+
productId: p.id,
|
|
3926
|
+
productName: p.name,
|
|
3927
|
+
dosage,
|
|
3928
|
+
quantity: 1,
|
|
3929
|
+
priceCents,
|
|
3930
|
+
drugId: p.id,
|
|
3931
|
+
apexDrugId: p.apex_drug_id ?? null,
|
|
3932
|
+
categories: p.categories ?? [],
|
|
3933
|
+
thumbnailUrl: p.thumbnail_url ?? void 0,
|
|
3934
|
+
hideDoseLabel: pricingMode() === "flat_fee" ? true : void 0,
|
|
3935
|
+
isSubscription: p.is_subscription ? true : void 0
|
|
3936
|
+
});
|
|
3937
|
+
cart_default.open();
|
|
3938
|
+
}
|
|
3939
|
+
return {
|
|
3940
|
+
product,
|
|
3941
|
+
dosageOptions,
|
|
3942
|
+
selectedDosage,
|
|
3943
|
+
setSelectedDosage,
|
|
3944
|
+
selectedPrice,
|
|
3945
|
+
selectedSalePrice,
|
|
3946
|
+
pricingMode,
|
|
3947
|
+
inCart,
|
|
3948
|
+
addToCart
|
|
3949
|
+
};
|
|
3950
|
+
}
|
|
3951
|
+
function useMedicationSelect(options = {}) {
|
|
3952
|
+
const catalog = useCatalog();
|
|
3953
|
+
function selectMedication(product) {
|
|
3954
|
+
medication_default.select({ drugId: product.id, drugName: product.name });
|
|
3955
|
+
options.onSelected?.();
|
|
3956
|
+
}
|
|
3957
|
+
function selectGeneralConsultation() {
|
|
3958
|
+
medication_default.select({
|
|
3959
|
+
drugId: null,
|
|
3960
|
+
drugName: options.generalConsultationLabel ?? "General Consultation"
|
|
3961
|
+
});
|
|
3962
|
+
options.onSelected?.();
|
|
3963
|
+
}
|
|
3964
|
+
return {
|
|
3965
|
+
products: catalog.products,
|
|
3966
|
+
weightLoss: catalog.weightLoss,
|
|
3967
|
+
peptides: catalog.peptides,
|
|
3968
|
+
selectMedication,
|
|
3969
|
+
selectGeneralConsultation
|
|
3970
|
+
};
|
|
3971
|
+
}
|
|
3972
|
+
function snapshotChanged(before, after) {
|
|
3973
|
+
return before.productName !== after.productName || before.priceCents !== after.priceCents || (before.apexDrugId ?? null) !== (after.apexDrugId ?? null) || !!before.isSubscription !== !!after.isSubscription || !!before.hideDoseLabel !== !!after.hideDoseLabel;
|
|
3974
|
+
}
|
|
3975
|
+
function reconcileCartLines(items, products, opts = {}) {
|
|
3976
|
+
const byId = new Map(products.map((p) => [p.id, p]));
|
|
3977
|
+
const kept = [];
|
|
3978
|
+
const dropped = [];
|
|
3979
|
+
const refreshed = [];
|
|
3980
|
+
for (const item of items) {
|
|
3981
|
+
const product = byId.get(item.productId);
|
|
3982
|
+
if (!product) {
|
|
3983
|
+
dropped.push({ item, reason: "unavailable" });
|
|
3984
|
+
continue;
|
|
3985
|
+
}
|
|
3986
|
+
if (opts.requireApexDrug && !product.apex_drug_id) {
|
|
3987
|
+
dropped.push({ item, reason: "not_prescribable" });
|
|
3988
|
+
continue;
|
|
3989
|
+
}
|
|
3990
|
+
const base = priceForDosage(product, item.dosage);
|
|
3991
|
+
if (base == null) {
|
|
3992
|
+
dropped.push({ item, reason: "unpriced" });
|
|
3993
|
+
continue;
|
|
3994
|
+
}
|
|
3995
|
+
const effective = salePriceForBase(product, base) ?? base;
|
|
3996
|
+
const next = {
|
|
3997
|
+
...item,
|
|
3998
|
+
productName: product.name,
|
|
3999
|
+
priceCents: Math.round(effective * 100),
|
|
4000
|
+
apexDrugId: product.apex_drug_id ?? null,
|
|
4001
|
+
categories: product.categories ?? [],
|
|
4002
|
+
thumbnailUrl: product.thumbnail_url ?? void 0,
|
|
4003
|
+
hideDoseLabel: product.pricing_mode === "flat_fee" ? true : void 0,
|
|
4004
|
+
isSubscription: product.is_subscription ? true : void 0
|
|
4005
|
+
};
|
|
4006
|
+
if (snapshotChanged(item, next)) refreshed.push(next);
|
|
4007
|
+
kept.push(next);
|
|
4008
|
+
}
|
|
4009
|
+
return { items: kept, dropped, refreshed, checked: true };
|
|
4010
|
+
}
|
|
4011
|
+
var UNCHECKED = { items: [], dropped: [], refreshed: [], checked: false };
|
|
4012
|
+
async function reconcileCartAgainstCatalog(opts = {}) {
|
|
4013
|
+
const items = cart_default.items();
|
|
4014
|
+
if (items.length === 0) return { ...UNCHECKED, checked: true };
|
|
4015
|
+
let products;
|
|
4016
|
+
try {
|
|
4017
|
+
products = (await productsApi.list()).products ?? [];
|
|
4018
|
+
} catch {
|
|
4019
|
+
return UNCHECKED;
|
|
4020
|
+
}
|
|
4021
|
+
if (products.length === 0) return UNCHECKED;
|
|
4022
|
+
const result = reconcileCartLines(items, products, opts);
|
|
4023
|
+
if (result.dropped.length > 0 || result.refreshed.length > 0) {
|
|
4024
|
+
cart_default.replace(result.items);
|
|
4025
|
+
}
|
|
4026
|
+
return result;
|
|
4027
|
+
}
|
|
4028
|
+
function useCartReconcile(opts = {}) {
|
|
4029
|
+
const [result] = createResource(() => reconcileCartAgainstCatalog(opts));
|
|
4030
|
+
return {
|
|
4031
|
+
dropped: () => result()?.dropped ?? [],
|
|
4032
|
+
refreshed: () => result()?.refreshed ?? [],
|
|
4033
|
+
pending: () => result.loading
|
|
4034
|
+
};
|
|
4035
|
+
}
|
|
3704
4036
|
function useAffiliateStats() {
|
|
3705
4037
|
const [stats, { refetch }] = createResource(
|
|
3706
4038
|
() => affiliateAuth_default.isAuthenticated(),
|
|
@@ -3761,6 +4093,45 @@ function useAffiliateLinks() {
|
|
|
3761
4093
|
return { links, refetch: () => refetch() };
|
|
3762
4094
|
}
|
|
3763
4095
|
|
|
4096
|
+
// src/flows/categoryVisual.ts
|
|
4097
|
+
function hashId(id) {
|
|
4098
|
+
let h = 5381;
|
|
4099
|
+
for (let i = 0; i < id.length; i++) h = (h << 5) + h + id.charCodeAt(i) | 0;
|
|
4100
|
+
return Math.abs(h);
|
|
4101
|
+
}
|
|
4102
|
+
var DEFAULT_COLOR_PALETTE = [
|
|
4103
|
+
"#4f46e5",
|
|
4104
|
+
// indigo
|
|
4105
|
+
"#0891b2",
|
|
4106
|
+
// cyan
|
|
4107
|
+
"#0d9488",
|
|
4108
|
+
// teal
|
|
4109
|
+
"#f59e0b",
|
|
4110
|
+
// amber
|
|
4111
|
+
"#e11d48",
|
|
4112
|
+
// rose
|
|
4113
|
+
"#10b981",
|
|
4114
|
+
// emerald
|
|
4115
|
+
"#8b5cf6",
|
|
4116
|
+
// violet
|
|
4117
|
+
"#f97316"
|
|
4118
|
+
// orange
|
|
4119
|
+
];
|
|
4120
|
+
function categoryColor(id, opts = {}) {
|
|
4121
|
+
const palette = opts.palette ?? DEFAULT_COLOR_PALETTE;
|
|
4122
|
+
if (palette.length === 0) return "currentColor";
|
|
4123
|
+
return palette[hashId(id) % palette.length];
|
|
4124
|
+
}
|
|
4125
|
+
function isCssColorValue(value) {
|
|
4126
|
+
return /^(#[0-9a-f]{3,8}|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^;{}()]*\)|var\(--[\w-]+\))$/i.test(
|
|
4127
|
+
value.trim()
|
|
4128
|
+
);
|
|
4129
|
+
}
|
|
4130
|
+
function resolveCategoryColor(category, opts = {}) {
|
|
4131
|
+
const set = category.color?.trim();
|
|
4132
|
+
return set && isCssColorValue(set) ? set : categoryColor(category.id, opts);
|
|
4133
|
+
}
|
|
4134
|
+
|
|
3764
4135
|
// src/flows/funnel.ts
|
|
3765
4136
|
var FORWARDED = /* @__PURE__ */ new Set([
|
|
3766
4137
|
"survey:loaded",
|
|
@@ -3968,6 +4339,6 @@ async function uploadPrescriptionPhoto(file) {
|
|
|
3968
4339
|
return { photoId: parsed.photoId };
|
|
3969
4340
|
}
|
|
3970
4341
|
|
|
3971
|
-
export { ACCOUNT_SOURCE_LABEL, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, categoryLabel, createFunnelTelemetry, deriveAttention, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, markEmailGateAnswered, normalizeState, primarySubscription, redeemResumeLink, resetResumeRedemption, resolveSurveyV2DrugIntent, stateAvailabilityNote, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCheckoutFlow, useDashboardData, useMemberPortalData, useMessagesThread, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
|
|
3972
|
-
//# sourceMappingURL=
|
|
3973
|
-
//# sourceMappingURL=
|
|
4342
|
+
export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, categoryColor, categoryLabel, createFunnelTelemetry, deriveAttention, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, lowestPrice, lowestSalePrice, markEmailGateAnswered, normalizeState, primarySubscription, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, resetResumeRedemption, resolveCategoryColor, resolveSurveyV2DrugIntent, salePriceForBase, stateAvailabilityNote, subscribeToSupportTopic, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
|
|
4343
|
+
//# sourceMappingURL=J3IRPONP.js.map
|
|
4344
|
+
//# sourceMappingURL=J3IRPONP.js.map
|