@apextelemed/partner-core 0.23.0-dev.82 → 0.23.0-dev.84
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/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/index.jsx +3 -3
- package/dist/chunk/{Z33DIIG6.jsx → 3PC2Z2QD.jsx} +2 -2
- package/dist/chunk/{4GYQYONL.js → ANR4H6TB.js} +5 -5
- package/dist/chunk/{4GYQYONL.js.map → ANR4H6TB.js.map} +1 -1
- package/dist/chunk/{74A4ERWQ.js → DFZFYIME.js} +3 -3
- package/dist/chunk/{74A4ERWQ.js.map → DFZFYIME.js.map} +1 -1
- package/dist/chunk/{Y74YTJXR.js → FFHPVSPW.js} +4 -12
- package/dist/chunk/FFHPVSPW.js.map +1 -0
- package/dist/chunk/{L7TIWRSK.jsx → GYVEVOH7.jsx} +4 -4
- package/dist/chunk/{L5DLLO2G.jsx → JQEJL7HE.jsx} +5 -5
- package/dist/chunk/{K2TKMLIY.js → JQIEY5VS.js} +3 -3
- package/dist/chunk/{K2TKMLIY.js.map → JQIEY5VS.js.map} +1 -1
- package/dist/chunk/{6TJPPA6S.jsx → K4SFTGFZ.jsx} +99 -62
- package/dist/chunk/{SAHG4GZB.js → MFW42ITZ.js} +6 -6
- package/dist/chunk/{SAHG4GZB.js.map → MFW42ITZ.js.map} +1 -1
- package/dist/chunk/{PK74TNA6.js → TUIMLDLN.js} +3 -3
- package/dist/chunk/{PK74TNA6.js.map → TUIMLDLN.js.map} +1 -1
- package/dist/chunk/{2TGKQDQV.jsx → UWWII3GE.jsx} +2 -2
- package/dist/chunk/{6TO6ZQVD.js → XB27METC.js} +167 -120
- package/dist/chunk/XB27METC.js.map +1 -0
- package/dist/chunk/{GIJCNQCB.jsx → XRFUHRLK.jsx} +2 -2
- package/dist/chunk/{GWVFWHTO.jsx → XWGLSZKD.jsx} +3 -11
- package/dist/{client-BdY7wkDp.d.ts → client-C-0_UTAb.d.ts} +4 -20
- package/dist/flows/index.d.ts +1 -1
- package/dist/flows/index.js +6 -6
- package/dist/flows/index.jsx +6 -6
- package/dist/index/index.d.ts +1 -1
- package/dist/index/index.js +7 -7
- package/dist/index/index.jsx +7 -7
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +5 -5
- package/dist/pages/index.jsx +5 -5
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.js +2 -2
- package/dist/stores/index.jsx +2 -2
- package/package.json +1 -1
- package/dist/chunk/6TO6ZQVD.js.map +0 -1
- package/dist/chunk/Y74YTJXR.js.map +0 -1
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
resetSmsConfigCache,
|
|
9
9
|
saveFunnelDraft,
|
|
10
10
|
stripResumeToken
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./UWWII3GE.jsx";
|
|
12
12
|
import {
|
|
13
13
|
affiliateAuth_default,
|
|
14
14
|
auth_default,
|
|
15
15
|
cart_default,
|
|
16
16
|
medication_default
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./3PC2Z2QD.jsx";
|
|
18
18
|
import {
|
|
19
19
|
ApiError,
|
|
20
20
|
addressesApi,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
subscriptionsApi,
|
|
36
36
|
supportApi,
|
|
37
37
|
usersApi
|
|
38
|
-
} from "./
|
|
38
|
+
} from "./XWGLSZKD.jsx";
|
|
39
39
|
import {
|
|
40
40
|
getConfig
|
|
41
41
|
} from "./QVZ7BRNO.jsx";
|
|
@@ -6805,4 +6805,4 @@ export {
|
|
|
6805
6805
|
useAddPharmacy,
|
|
6806
6806
|
useSmsPreferences
|
|
6807
6807
|
};
|
|
6808
|
-
//# sourceMappingURL=
|
|
6808
|
+
//# sourceMappingURL=GYVEVOH7.jsx.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
readPromoCode,
|
|
9
9
|
resetCartId,
|
|
10
10
|
stripCartToken
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./XRFUHRLK.jsx";
|
|
12
12
|
import {
|
|
13
13
|
PHONE_ERROR,
|
|
14
14
|
bestOfferDiscount,
|
|
@@ -25,11 +25,11 @@ import {
|
|
|
25
25
|
useCatalogAvailability,
|
|
26
26
|
useSmsConsent,
|
|
27
27
|
validateAddress
|
|
28
|
-
} from "./
|
|
28
|
+
} from "./GYVEVOH7.jsx";
|
|
29
29
|
import {
|
|
30
30
|
auth_default,
|
|
31
31
|
cart_default
|
|
32
|
-
} from "./
|
|
32
|
+
} from "./3PC2Z2QD.jsx";
|
|
33
33
|
import {
|
|
34
34
|
ApiError,
|
|
35
35
|
newIdempotencyKey,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
promoCodesApi,
|
|
38
38
|
subscriptionsApi,
|
|
39
39
|
usersApi
|
|
40
|
-
} from "./
|
|
40
|
+
} from "./XWGLSZKD.jsx";
|
|
41
41
|
import {
|
|
42
42
|
getConfig
|
|
43
43
|
} from "./QVZ7BRNO.jsx";
|
|
@@ -661,4 +661,4 @@ export {
|
|
|
661
661
|
restoreCartFromLink,
|
|
662
662
|
startCartCapture
|
|
663
663
|
};
|
|
664
|
-
//# sourceMappingURL=
|
|
664
|
+
//# sourceMappingURL=JQEJL7HE.jsx.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { peekFunnelSessionId, captureAuthHeader } from './
|
|
1
|
+
import { peekFunnelSessionId, captureAuthHeader } from './TUIMLDLN.js';
|
|
2
2
|
import { getConfig } from './2IFPDU4D.js';
|
|
3
3
|
|
|
4
4
|
// src/api/promoRef.ts
|
|
@@ -156,5 +156,5 @@ function stripCartToken() {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
export { adoptCartId, capturePromoCode, cartId, clearPromoCode, fetchCartConfig, fetchResumedCart, postCartSnapshot, readCartToken, readPromoCode, resetCartConfigCache, resetCartId, stripCartToken };
|
|
159
|
-
//# sourceMappingURL=
|
|
160
|
-
//# sourceM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,WAAA,EAAa,MAAM,OAAA,CAAQ,IAAA,CAAK,WAAW,CAAA,GAAI,IAAA,CAAK,cAAc,EAAC;AAAA,MACnE,SAAA,EAAW,KAAK,SAAA,IAAa,IAAA;AAAA,MAC7B,eAAe,OAAO,IAAA,CAAK,aAAA,KAAkB,QAAA,GAAW,KAAK,aAAA,GAAgB;AAAA,KAC/E;AAAA,EACF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAGO,SAAS,aAAA,GAA+B;AAC7C,EAAA,IAAI;AACF,IAAA,MAAM,KAAA,GAAQ,IAAI,eAAA,CAAgB,MAAA,CAAO,SAAS,MAAM,CAAA,CAAE,IAAI,MAAM,CAAA;AACpE,IAAA,OAAO,KAAA,IAAS,KAAA,CAAM,MAAA,GAAS,CAAA,GAAI,KAAA,GAAQ,IAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAOO,SAAS,cAAA,GAAuB;AACrC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,MAAA,CAAO,SAAS,IAAI,CAAA;AACxC,IAAA,IAAI,CAAC,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG;AACnC,IAAA,GAAA,CAAI,YAAA,CAAa,OAAO,MAAM,CAAA;AAC9B,IAAA,MAAA,CAAO,QAAQ,YAAA,CAAa,IAAI,EAAA,EAAI,GAAA,CAAI,UAAU,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"K2TKMLIY.js","sourcesContent":["// ── First-party promo-code capture from a `?promo=` landing ──────────\n//\n// A campaign link can carry its own code (`/?promo=TRUE10`) so the member does\n// not have to type it. Stashed in the storefront's own localStorage and read\n// back when the intake reaches the promo field.\n//\n// Mirrors `affiliateRef` deliberately — same storage shape, same 30-day window —\n// but is a SEPARATE concern: an affiliate ref attributes a sale to a partner and\n// is validated server-side at checkout, while this only pre-fills an input the\n// member still has to submit.\n\nimport { getConfig } from '../config';\n\n// Matches the affiliate-ref window. A stash that outlives the promo it carries\n// is not a correctness problem — the code is re-validated before it is used,\n// and silently dropped if it has expired — but there is no reason to keep one\n// around longer than a campaign plausibly runs.\nconst TTL_MS = 30 * 24 * 60 * 60 * 1000;\n\nconst storageKey = () => `${getConfig().storagePrefix}-promo-code`;\n\ninterface StoredPromo {\n code: string;\n ts: number;\n}\n\n/** Persist a promo code from a `?promo=` landing. No-op for empty input. */\nexport function capturePromoCode(code: string): void {\n if (typeof localStorage === 'undefined') return;\n const trimmed = code.trim();\n if (!trimmed) return;\n try {\n const entry: StoredPromo = { code: trimmed, ts: Date.now() };\n localStorage.setItem(storageKey(), JSON.stringify(entry));\n } catch {\n // storage unavailable (private mode / quota) — non-fatal\n }\n}\n\n/**\n * Read the stored promo code, or null if absent or past the storage window.\n *\n * Being within the window says nothing about whether the CODE is still valid —\n * a campaign can end while the stash is fresh. The caller re-validates against\n * the server before showing it to anyone.\n */\nexport function readPromoCode(): string | null {\n if (typeof localStorage === 'undefined') return null;\n try {\n const raw = localStorage.getItem(storageKey());\n if (!raw) return null;\n const parsed = JSON.parse(raw) as Partial<StoredPromo>;\n if (!parsed.code || typeof parsed.ts !== 'number') return null;\n if (Date.now() - parsed.ts > TTL_MS) {\n localStorage.removeItem(storageKey());\n return null;\n }\n return parsed.code;\n } catch {\n return null;\n }\n}\n\n/** Drop the stored promo code. */\nexport function clearPromoCode(): void {\n if (typeof localStorage === 'undefined') return;\n try {\n localStorage.removeItem(storageKey());\n } catch {\n // non-fatal\n }\n}\n","import { getConfig } from '../config';\nimport { captureAuthHeader, peekFunnelSessionId } from './funnel';\n\n// ── Abandoned-cart transport ────────────────────────────────────────────────\n//\n// Thin client for the-backend's cart-capture endpoints:\n// GET /config/cart → whether this tenant mirrors carts at all\n// POST /cart/snapshot → server-side mirror of the browser's cart\n// GET /cart/resume → trade an emailed token for the saved cart\n//\n// Sibling of ./funnel, and the same posture: fire-and-forget, fail-silent.\n// Cart capture is marketing instrumentation and must never break, block or\n// slow down shopping.\n\nexport interface CartCaptureConfig {\n /** Tenant opted in (features.cartRecovery); false = never send anything. */\n snapshot: boolean;\n}\n\nconst DISABLED: CartCaptureConfig = { snapshot: false };\n\nlet configPromise: Promise<CartCaptureConfig> | null = null;\n\n/**\n * The tenant's cart-capture posture, fetched once per page load and cached.\n * Fails closed: any error reads as \"off\".\n */\nexport function fetchCartConfig(): Promise<CartCaptureConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/cart`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<CartCaptureConfig>;\n return { snapshot: body.snapshot === true };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetCartConfigCache(): void {\n configPromise = null;\n}\n\nconst cartIdKey = () => `${getConfig().storagePrefix}-cart-id`;\n\n/**\n * Stable id for this shopper's cart, minted on first use and kept in\n * localStorage — NOT sessionStorage like the survey session.\n *\n * A cart outlives the tab it was filled in: someone adds items, closes the\n * browser, comes back tomorrow and finds the cart still there (the cart store\n * itself persists the same way). The id has to survive with it, or every visit\n * would look like a brand-new abandoned cart and one shopper would accumulate\n * a row — and a reminder track — per session.\n */\nexport function cartId(): string {\n let id: string | null = null;\n try {\n id = localStorage.getItem(cartIdKey());\n } catch {\n /* storage unavailable (private mode) — fall through to an ephemeral id */\n }\n if (!id) {\n id =\n typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* ephemeral it is */\n }\n }\n return id;\n}\n\n/**\n * Continue the cart a recovery email points at, instead of the one this browser\n * happens to hold. Adopting the emailed id keeps the reminder history, the\n * email address and the eventual conversion on ONE row.\n */\nexport function adoptCartId(id: string): void {\n if (!id) return;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* storage unavailable — the adoption is ephemeral */\n }\n}\n\n/**\n * Start a fresh cart id. Called after a purchase: the old id is stamped\n * converted server-side and must never be written to again, or a new cart\n * would inherit a bought cart's row (and its silence — converted rows are\n * never nudged).\n */\nexport function resetCartId(): void {\n try {\n localStorage.removeItem(cartIdKey());\n } catch {\n /* nothing to clear */\n }\n}\n\nexport interface CartSnapshotLine {\n productId: string;\n dosage?: string;\n quantity: number;\n}\n\n/**\n * Mirror the cart server-side. Identity only — the backend re-prices from the\n * catalog and ignores anything else we send, so there is no point shipping\n * names or prices.\n *\n * `keepalive` lets the request survive the page unload that so often IS the\n * abandonment.\n *\n * The bearer token, when there is one, is how a signed-in shopper's cart gets\n * their user id: the endpoint takes identity from the token and never from the\n * body (`optionalAuth`), so omitting it left every logged-in cart anonymous —\n * joinable only by whatever email happened to be attached.\n */\nexport function postCartSnapshot(params: {\n items: CartSnapshotLine[];\n promoCode?: string | null;\n email?: string | null;\n}): void {\n try {\n const cfg = getConfig();\n void fetch(`${cfg.apiBase}/cart/snapshot`, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Tenant-Key': cfg.tenantKey,\n ...captureAuthHeader(),\n },\n body: JSON.stringify({\n cartId: cartId(),\n items: params.items,\n promoCode: params.promoCode ?? null,\n ...(params.email ? { email: params.email } : {}),\n // Only when a survey session already exists: it lets the backend reuse\n // the address the pre-survey email gate collected, which is often the\n // only handle we have on an anonymous shopper.\n ...(peekFunnelSessionId() ? { sessionId: peekFunnelSessionId() } : {}),\n }),\n }).catch(() => {});\n } catch {\n /* not configured yet — drop */\n }\n}\n\n/** A resumed cart line, already re-priced against today's catalog. */\nexport interface ResumedCartLine {\n productId: string;\n dosage?: string;\n quantity: number;\n name: string;\n priceCents: number;\n salePriceCents: number | null;\n thumbnailUrl: string | null;\n isSubscription: boolean;\n apexDrugId: string | null;\n categories: string[];\n hideDoseLabel: boolean;\n}\n\nexport interface ResumedCart {\n cartId: string;\n items: ResumedCartLine[];\n /** Lines whose product has since been discontinued or deactivated. */\n unavailable: Array<{ productId: string; dosage?: string; quantity: number }>;\n promoCode: string | null;\n subtotalCents: number;\n}\n\n/**\n * Exchange an emailed recovery token for the saved cart.\n *\n * The token is the ONLY thing authorizing this read — the-backend verifies its\n * HMAC before returning anything. A 404 (expired, already bought, tampered, or\n * every product gone) resolves to null so the caller simply keeps whatever cart\n * this browser already had.\n */\nexport async function fetchResumedCart(token: string): Promise<ResumedCart | null> {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/cart/resume?token=${encodeURIComponent(token)}`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Partial<ResumedCart>;\n if (!body.cartId || !Array.isArray(body.items) || body.items.length === 0) return null;\n return {\n cartId: body.cartId,\n items: body.items,\n unavailable: Array.isArray(body.unavailable) ? body.unavailable : [],\n promoCode: body.promoCode ?? null,\n subtotalCents: typeof body.subtotalCents === 'number' ? body.subtotalCents : 0,\n };\n } catch {\n return null;\n }\n}\n\n/** Read the `?cart=` token from the current URL. */\nexport function readCartToken(): string | null {\n try {\n const token = new URLSearchParams(window.location.search).get('cart');\n return token && token.length > 0 ? token : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Drop `?cart=` from the address bar once it's been redeemed, so a refresh (or\n * a shared URL) doesn't re-run the restore over a cart the shopper has since\n * edited. History is replaced, not pushed — the token was never a page.\n */\nexport function stripCartToken(): void {\n try {\n const url = new URL(window.location.href);\n if (!url.searchParams.has('cart')) return;\n url.searchParams.delete('cart');\n window.history.replaceState({}, '', url.toString());\n } catch {\n /* no history API — leaving the param is harmless */\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/promoRef.ts","../../src/api/cart.ts"],"names":[],"mappings":";;;;AAiBA,IA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AW,KAAK,aAAA,GAAgB;AAAA,KAC/E;AAAA,EACF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAGO,SAAS,aAAA,GAA+B;AAC7C,EAAA,IAAI;AACF,IAAA,MAAM,KAAA,GAAQ,IAAI,eAAA,CAAgB,MAAA,CAAO,SAAS,MAAM,CAAA,CAAE,IAAI,MAAM,CAAA;AACpE,IAAA,OAAO,KAAA,IAAS,KAAA,CAAM,MAAA,GAAS,CAAA,GAAI,KAAA,GAAQ,IAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAOO,SAAS,cAAA,GAAuB;AACrC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,MAAA,CAAO,SAAS,IAAI,CAAA;AACxC,IAAA,IAAI,CAAC,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG;AACnC,IAAA,GAAA,CAAI,YAAA,CAAa,OAAO,MAAM,CAAA;AAC9B,IAAA,MAAA,CAAO,QAAQ,YAAA,CAAa,IAAI,EAAA,EAAI,GAAA,CAAI,UAAU,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"JQIEY5VS.js","sourcesContent":["// ── First-party promo-code capture from a `?promo=` landing ──────────\n//\n// A campaign link can carry its own code (`/?promo=TRUE10`) so the member does\n// not have to type it. Stashed in the storefront's own localStorage and read\n// back when the intake reaches the promo field.\n//\n// Mirrors `affiliateRef` deliberately — same storage shape, same 30-day window —\n// but is a SEPARATE concern: an affiliate ref attributes a sale to a partner and\n// is validated server-side at checkout, while this only pre-fills an input the\n// member still has to submit.\n\nimport { getConfig } from '../config';\n\n// Matches the affiliate-ref window. A stash that outlives the promo it carries\n// is not a correctness problem — the code is re-validated before it is used,\n// and silently dropped if it has expired — but there is no reason to keep one\n// around longer than a campaign plausibly runs.\nconst TTL_MS = 30 * 24 * 60 * 60 * 1000;\n\nconst storageKey = () => `${getConfig().storagePrefix}-promo-code`;\n\ninterface StoredPromo {\n code: string;\n ts: number;\n}\n\n/** Persist a promo code from a `?promo=` landing. No-op for empty input. */\nexport function capturePromoCode(code: string): void {\n if (typeof localStorage === 'undefined') return;\n const trimmed = code.trim();\n if (!trimmed) return;\n try {\n const entry: StoredPromo = { code: trimmed, ts: Date.now() };\n localStorage.setItem(storageKey(), JSON.stringify(entry));\n } catch {\n // storage unavailable (private mode / quota) — non-fatal\n }\n}\n\n/**\n * Read the stored promo code, or null if absent or past the storage window.\n *\n * Being within the window says nothing about whether the CODE is still valid —\n * a campaign can end while the stash is fresh. The caller re-validates against\n * the server before showing it to anyone.\n */\nexport function readPromoCode(): string | null {\n if (typeof localStorage === 'undefined') return null;\n try {\n const raw = localStorage.getItem(storageKey());\n if (!raw) return null;\n const parsed = JSON.parse(raw) as Partial<StoredPromo>;\n if (!parsed.code || typeof parsed.ts !== 'number') return null;\n if (Date.now() - parsed.ts > TTL_MS) {\n localStorage.removeItem(storageKey());\n return null;\n }\n return parsed.code;\n } catch {\n return null;\n }\n}\n\n/** Drop the stored promo code. */\nexport function clearPromoCode(): void {\n if (typeof localStorage === 'undefined') return;\n try {\n localStorage.removeItem(storageKey());\n } catch {\n // non-fatal\n }\n}\n","import { getConfig } from '../config';\nimport { captureAuthHeader, peekFunnelSessionId } from './funnel';\n\n// ── Abandoned-cart transport ────────────────────────────────────────────────\n//\n// Thin client for the-backend's cart-capture endpoints:\n// GET /config/cart → whether this tenant mirrors carts at all\n// POST /cart/snapshot → server-side mirror of the browser's cart\n// GET /cart/resume → trade an emailed token for the saved cart\n//\n// Sibling of ./funnel, and the same posture: fire-and-forget, fail-silent.\n// Cart capture is marketing instrumentation and must never break, block or\n// slow down shopping.\n\nexport interface CartCaptureConfig {\n /** Tenant opted in (features.cartRecovery); false = never send anything. */\n snapshot: boolean;\n}\n\nconst DISABLED: CartCaptureConfig = { snapshot: false };\n\nlet configPromise: Promise<CartCaptureConfig> | null = null;\n\n/**\n * The tenant's cart-capture posture, fetched once per page load and cached.\n * Fails closed: any error reads as \"off\".\n */\nexport function fetchCartConfig(): Promise<CartCaptureConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/cart`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<CartCaptureConfig>;\n return { snapshot: body.snapshot === true };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetCartConfigCache(): void {\n configPromise = null;\n}\n\nconst cartIdKey = () => `${getConfig().storagePrefix}-cart-id`;\n\n/**\n * Stable id for this shopper's cart, minted on first use and kept in\n * localStorage — NOT sessionStorage like the survey session.\n *\n * A cart outlives the tab it was filled in: someone adds items, closes the\n * browser, comes back tomorrow and finds the cart still there (the cart store\n * itself persists the same way). The id has to survive with it, or every visit\n * would look like a brand-new abandoned cart and one shopper would accumulate\n * a row — and a reminder track — per session.\n */\nexport function cartId(): string {\n let id: string | null = null;\n try {\n id = localStorage.getItem(cartIdKey());\n } catch {\n /* storage unavailable (private mode) — fall through to an ephemeral id */\n }\n if (!id) {\n id =\n typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* ephemeral it is */\n }\n }\n return id;\n}\n\n/**\n * Continue the cart a recovery email points at, instead of the one this browser\n * happens to hold. Adopting the emailed id keeps the reminder history, the\n * email address and the eventual conversion on ONE row.\n */\nexport function adoptCartId(id: string): void {\n if (!id) return;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* storage unavailable — the adoption is ephemeral */\n }\n}\n\n/**\n * Start a fresh cart id. Called after a purchase: the old id is stamped\n * converted server-side and must never be written to again, or a new cart\n * would inherit a bought cart's row (and its silence — converted rows are\n * never nudged).\n */\nexport function resetCartId(): void {\n try {\n localStorage.removeItem(cartIdKey());\n } catch {\n /* nothing to clear */\n }\n}\n\nexport interface CartSnapshotLine {\n productId: string;\n dosage?: string;\n quantity: number;\n}\n\n/**\n * Mirror the cart server-side. Identity only — the backend re-prices from the\n * catalog and ignores anything else we send, so there is no point shipping\n * names or prices.\n *\n * `keepalive` lets the request survive the page unload that so often IS the\n * abandonment.\n *\n * The bearer token, when there is one, is how a signed-in shopper's cart gets\n * their user id: the endpoint takes identity from the token and never from the\n * body (`optionalAuth`), so omitting it left every logged-in cart anonymous —\n * joinable only by whatever email happened to be attached.\n */\nexport function postCartSnapshot(params: {\n items: CartSnapshotLine[];\n promoCode?: string | null;\n email?: string | null;\n}): void {\n try {\n const cfg = getConfig();\n void fetch(`${cfg.apiBase}/cart/snapshot`, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Tenant-Key': cfg.tenantKey,\n ...captureAuthHeader(),\n },\n body: JSON.stringify({\n cartId: cartId(),\n items: params.items,\n promoCode: params.promoCode ?? null,\n ...(params.email ? { email: params.email } : {}),\n // Only when a survey session already exists: it lets the backend reuse\n // the address the pre-survey email gate collected, which is often the\n // only handle we have on an anonymous shopper.\n ...(peekFunnelSessionId() ? { sessionId: peekFunnelSessionId() } : {}),\n }),\n }).catch(() => {});\n } catch {\n /* not configured yet — drop */\n }\n}\n\n/** A resumed cart line, already re-priced against today's catalog. */\nexport interface ResumedCartLine {\n productId: string;\n dosage?: string;\n quantity: number;\n name: string;\n priceCents: number;\n salePriceCents: number | null;\n thumbnailUrl: string | null;\n isSubscription: boolean;\n apexDrugId: string | null;\n categories: string[];\n hideDoseLabel: boolean;\n}\n\nexport interface ResumedCart {\n cartId: string;\n items: ResumedCartLine[];\n /** Lines whose product has since been discontinued or deactivated. */\n unavailable: Array<{ productId: string; dosage?: string; quantity: number }>;\n promoCode: string | null;\n subtotalCents: number;\n}\n\n/**\n * Exchange an emailed recovery token for the saved cart.\n *\n * The token is the ONLY thing authorizing this read — the-backend verifies its\n * HMAC before returning anything. A 404 (expired, already bought, tampered, or\n * every product gone) resolves to null so the caller simply keeps whatever cart\n * this browser already had.\n */\nexport async function fetchResumedCart(token: string): Promise<ResumedCart | null> {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/cart/resume?token=${encodeURIComponent(token)}`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Partial<ResumedCart>;\n if (!body.cartId || !Array.isArray(body.items) || body.items.length === 0) return null;\n return {\n cartId: body.cartId,\n items: body.items,\n unavailable: Array.isArray(body.unavailable) ? body.unavailable : [],\n promoCode: body.promoCode ?? null,\n subtotalCents: typeof body.subtotalCents === 'number' ? body.subtotalCents : 0,\n };\n } catch {\n return null;\n }\n}\n\n/** Read the `?cart=` token from the current URL. */\nexport function readCartToken(): string | null {\n try {\n const token = new URLSearchParams(window.location.search).get('cart');\n return token && token.length > 0 ? token : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Drop `?cart=` from the address bar once it's been redeemed, so a refresh (or\n * a shared URL) doesn't re-run the restore over a cart the shopper has since\n * edited. History is replaced, not pushed — the token was never a page.\n */\nexport function stripCartToken(): void {\n try {\n const url = new URL(window.location.href);\n if (!url.searchParams.has('cart')) return;\n url.searchParams.delete('cart');\n window.history.replaceState({}, '', url.toString());\n } catch {\n /* no history API — leaving the param is harmless */\n }\n}\n"]}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
MATCH_DEPENDENT_WARNINGS,
|
|
11
11
|
MATCH_HOW_LABEL,
|
|
12
12
|
ORPHAN_REASON,
|
|
13
|
+
PHONE_ERROR,
|
|
13
14
|
READINESS_LABEL,
|
|
14
15
|
SOURCE_FIELD_NOTE,
|
|
15
16
|
SUPPORT_CATEGORIES,
|
|
@@ -47,6 +48,7 @@ import {
|
|
|
47
48
|
isCatalogItemId,
|
|
48
49
|
isCssColorValue,
|
|
49
50
|
isImageAttachment,
|
|
51
|
+
isValidUsPhone,
|
|
50
52
|
lifecycleReason,
|
|
51
53
|
markEmailGateAnswered,
|
|
52
54
|
matchKey,
|
|
@@ -83,10 +85,10 @@ import {
|
|
|
83
85
|
useSurveyV2Flow,
|
|
84
86
|
useUpdatePaymentMethodFlow,
|
|
85
87
|
visibleWarnings
|
|
86
|
-
} from "./
|
|
88
|
+
} from "./GYVEVOH7.jsx";
|
|
87
89
|
import {
|
|
88
90
|
fetchFunnelConfig
|
|
89
|
-
} from "./
|
|
91
|
+
} from "./UWWII3GE.jsx";
|
|
90
92
|
import {
|
|
91
93
|
usePrimitives
|
|
92
94
|
} from "./J63XPQP4.jsx";
|
|
@@ -94,7 +96,7 @@ import {
|
|
|
94
96
|
affiliateAuth_default,
|
|
95
97
|
auth_default,
|
|
96
98
|
cart_default
|
|
97
|
-
} from "./
|
|
99
|
+
} from "./3PC2Z2QD.jsx";
|
|
98
100
|
import {
|
|
99
101
|
ADMIN_ROLES,
|
|
100
102
|
ApiError,
|
|
@@ -111,7 +113,7 @@ import {
|
|
|
111
113
|
offersApi,
|
|
112
114
|
subscriptionsApi,
|
|
113
115
|
usersApi
|
|
114
|
-
} from "./
|
|
116
|
+
} from "./XWGLSZKD.jsx";
|
|
115
117
|
|
|
116
118
|
// src/pages/Survey.tsx
|
|
117
119
|
import { Show, For, createEffect, on } from "solid-js";
|
|
@@ -23520,100 +23522,135 @@ function testMessage(res) {
|
|
|
23520
23522
|
}
|
|
23521
23523
|
}
|
|
23522
23524
|
function TemplateRow(props) {
|
|
23523
|
-
const
|
|
23524
|
-
const [enabled, setEnabled] = createSignal48(saved().enabled);
|
|
23525
|
-
const [saving, setSaving] = createSignal48(false);
|
|
23526
|
-
const [error, setError] = createSignal48(null);
|
|
23525
|
+
const t = () => props.template;
|
|
23527
23526
|
const [testing, setTesting] = createSignal48(false);
|
|
23528
23527
|
const [test, setTest] = createSignal48(null);
|
|
23529
|
-
const dirty = () => enabled() !== saved().enabled;
|
|
23530
|
-
const save = async () => {
|
|
23531
|
-
if (!dirty() || saving()) return;
|
|
23532
|
-
setSaving(true);
|
|
23533
|
-
setError(null);
|
|
23534
|
-
try {
|
|
23535
|
-
const res = await adminApi.saveSmsTemplates({ [saved().key]: { enabled: enabled() } });
|
|
23536
|
-
const next = res.templates.find((t) => t.key === saved().key);
|
|
23537
|
-
if (next) {
|
|
23538
|
-
setEnabled(next.enabled);
|
|
23539
|
-
props.onSaved(next);
|
|
23540
|
-
}
|
|
23541
|
-
toastSuccess(`${saved().label} text saved`);
|
|
23542
|
-
} catch (e) {
|
|
23543
|
-
setError(e instanceof Error ? e.message : "Could not save.");
|
|
23544
|
-
} finally {
|
|
23545
|
-
setSaving(false);
|
|
23546
|
-
}
|
|
23547
|
-
};
|
|
23548
23528
|
const sendTest = async () => {
|
|
23549
23529
|
if (testing()) return;
|
|
23550
23530
|
setTesting(true);
|
|
23551
23531
|
setTest(null);
|
|
23552
23532
|
try {
|
|
23553
|
-
setTest(testMessage(await adminApi.sendSmsTemplateTest(
|
|
23533
|
+
setTest(testMessage(await adminApi.sendSmsTemplateTest(t().key)));
|
|
23554
23534
|
} catch (e) {
|
|
23555
23535
|
setTest({ tone: "bad", text: e instanceof Error ? e.message : "Could not send the test." });
|
|
23556
23536
|
} finally {
|
|
23557
23537
|
setTesting(false);
|
|
23558
23538
|
}
|
|
23559
23539
|
};
|
|
23560
|
-
return <div class="app-admin-card-soft" data-template={
|
|
23561
|
-
<div style={{
|
|
23562
|
-
<div style={{ "font-size": "0.875rem", "font-weight": "600" }}>{saved().label}</div>
|
|
23563
|
-
<label style={{ display: "flex", "align-items": "center", gap: "0.5rem", "font-size": "0.8125rem", cursor: "pointer" }}>
|
|
23564
|
-
<input
|
|
23565
|
-
type="checkbox"
|
|
23566
|
-
role="switch"
|
|
23567
|
-
aria-label={`Send the ${saved().label} text`}
|
|
23568
|
-
checked={enabled()}
|
|
23569
|
-
onChange={(e) => setEnabled(e.currentTarget.checked)}
|
|
23570
|
-
/>
|
|
23571
|
-
{enabled() ? "On" : "Off"}
|
|
23572
|
-
</label>
|
|
23573
|
-
</div>
|
|
23540
|
+
return <div class="app-admin-card-soft" data-template={t().key} style={{ padding: "0.875rem", display: "grid", gap: "0.625rem" }}>
|
|
23541
|
+
<div style={{ "font-size": "0.875rem", "font-weight": "600" }}>{t().label}</div>
|
|
23574
23542
|
|
|
23575
23543
|
<div data-testid="sms-preview" style={muted3}>
|
|
23576
|
-
Preview: <span style={{ color: "var(--app-admin-fg)" }}>{
|
|
23544
|
+
Preview: <span style={{ color: "var(--app-admin-fg)" }}>{t().preview}</span>
|
|
23577
23545
|
</div>
|
|
23578
23546
|
|
|
23579
|
-
<Show68 when={error()}>
|
|
23580
|
-
<div class="app-admin-notice" role="alert">{error()}</div>
|
|
23581
|
-
</Show68>
|
|
23582
|
-
|
|
23583
23547
|
<div class="app-admin-btn-row">
|
|
23584
|
-
<button type="button" class="app-admin-btn app-admin-btn-
|
|
23585
|
-
{saving() ? "Saving\u2026" : "Save"}
|
|
23586
|
-
</button>
|
|
23587
|
-
<button type="button" class="app-admin-btn app-admin-btn-sm" disabled={testing()} onClick={() => void sendTest()}>
|
|
23548
|
+
<button type="button" class="app-admin-btn app-admin-btn-sm" disabled={testing() || !props.canTest} onClick={() => void sendTest()}>
|
|
23588
23549
|
{testing() ? "Sending\u2026" : "Send test to my phone"}
|
|
23589
23550
|
</button>
|
|
23590
23551
|
</div>
|
|
23591
|
-
<Show68 when={dirty()}>
|
|
23592
|
-
<div style={muted3}>The test follows the saved setting. Save your change first.</div>
|
|
23593
|
-
</Show68>
|
|
23594
23552
|
<Show68 when={test()}>
|
|
23595
|
-
{(
|
|
23553
|
+
{(r) => <div
|
|
23596
23554
|
class="app-admin-notice"
|
|
23597
23555
|
role="status"
|
|
23598
|
-
style={
|
|
23556
|
+
style={r().tone === "bad" ? { color: "var(--app-admin-danger-fg)" } : void 0}
|
|
23599
23557
|
>
|
|
23600
|
-
{
|
|
23558
|
+
{r().text}
|
|
23559
|
+
</div>}
|
|
23560
|
+
</Show68>
|
|
23561
|
+
</div>;
|
|
23562
|
+
}
|
|
23563
|
+
function TestPhoneBlock(props) {
|
|
23564
|
+
const [value, setValue] = createSignal48("");
|
|
23565
|
+
const [saving, setSaving] = createSignal48(false);
|
|
23566
|
+
const [error, setError] = createSignal48("");
|
|
23567
|
+
const [note, setNote] = createSignal48(null);
|
|
23568
|
+
const [loaded] = createResource30(async () => {
|
|
23569
|
+
try {
|
|
23570
|
+
const res = await usersApi.getProfile();
|
|
23571
|
+
const raw = res.data?.phone;
|
|
23572
|
+
const phone = typeof raw === "string" ? raw : "";
|
|
23573
|
+
setValue(phone);
|
|
23574
|
+
props.onLoaded(phone);
|
|
23575
|
+
} catch {
|
|
23576
|
+
}
|
|
23577
|
+
return true;
|
|
23578
|
+
});
|
|
23579
|
+
const save = async () => {
|
|
23580
|
+
if (saving()) return;
|
|
23581
|
+
const phone = value().trim();
|
|
23582
|
+
setNote(null);
|
|
23583
|
+
if (!isValidUsPhone(phone)) {
|
|
23584
|
+
setError(PHONE_ERROR);
|
|
23585
|
+
return;
|
|
23586
|
+
}
|
|
23587
|
+
setError("");
|
|
23588
|
+
setSaving(true);
|
|
23589
|
+
try {
|
|
23590
|
+
await usersApi.updateProfile({ phone });
|
|
23591
|
+
props.onSaved(phone);
|
|
23592
|
+
setNote({ tone: "ok", text: "Saved to your account." });
|
|
23593
|
+
} catch (e) {
|
|
23594
|
+
setNote({ tone: "bad", text: e instanceof Error ? e.message : "Could not save your number." });
|
|
23595
|
+
} finally {
|
|
23596
|
+
setSaving(false);
|
|
23597
|
+
}
|
|
23598
|
+
};
|
|
23599
|
+
return <div class="app-admin-card-soft" data-testid="sms-test-phone" style={{ padding: "0.875rem", display: "grid", gap: "0.5rem" }}>
|
|
23600
|
+
<label class="app-admin-label" for="sms-test-phone-input" style={{ "font-size": "0.875rem", "font-weight": "600" }}>
|
|
23601
|
+
Your phone for test texts
|
|
23602
|
+
</label>
|
|
23603
|
+
<div style={muted3}>
|
|
23604
|
+
Test texts are sent to this number. It is the phone on your own account.
|
|
23605
|
+
</div>
|
|
23606
|
+
<div class="app-admin-btn-row">
|
|
23607
|
+
<input
|
|
23608
|
+
id="sms-test-phone-input"
|
|
23609
|
+
class="app-admin-input"
|
|
23610
|
+
type="tel"
|
|
23611
|
+
inputmode="tel"
|
|
23612
|
+
autocomplete="tel"
|
|
23613
|
+
placeholder="(555) 555-1234"
|
|
23614
|
+
value={value()}
|
|
23615
|
+
disabled={loaded.loading}
|
|
23616
|
+
onInput={(e) => {
|
|
23617
|
+
setValue(e.currentTarget.value);
|
|
23618
|
+
setError("");
|
|
23619
|
+
setNote(null);
|
|
23620
|
+
}}
|
|
23621
|
+
/>
|
|
23622
|
+
<button type="button" class="app-admin-btn app-admin-btn-sm" disabled={saving() || loaded.loading} onClick={() => void save()}>
|
|
23623
|
+
{saving() ? "Saving\u2026" : "Save"}
|
|
23624
|
+
</button>
|
|
23625
|
+
</div>
|
|
23626
|
+
<Show68 when={error()}>
|
|
23627
|
+
<div class="app-admin-notice" role="alert" style={{ color: "var(--app-admin-danger-fg)" }}>
|
|
23628
|
+
{error()}
|
|
23629
|
+
</div>
|
|
23630
|
+
</Show68>
|
|
23631
|
+
<Show68 when={note()}>
|
|
23632
|
+
{(r) => <div class="app-admin-notice" role="status" style={r().tone === "bad" ? { color: "var(--app-admin-danger-fg)" } : void 0}>
|
|
23633
|
+
{r().text}
|
|
23601
23634
|
</div>}
|
|
23602
23635
|
</Show68>
|
|
23603
23636
|
</div>;
|
|
23604
23637
|
}
|
|
23605
23638
|
function SmsTemplatesCard(props) {
|
|
23606
|
-
const [data
|
|
23639
|
+
const [data] = createResource30(async () => {
|
|
23607
23640
|
const res = await adminApi.getSmsTemplates();
|
|
23608
23641
|
props.onLoaded?.(res.templates);
|
|
23609
23642
|
return res;
|
|
23610
23643
|
});
|
|
23644
|
+
const [phone, setPhone] = createSignal48("");
|
|
23611
23645
|
const templates = () => data.error ? [] : data()?.templates ?? [];
|
|
23612
|
-
const replace = (next) => mutate({ templates: templates().map((t) => t.key === next.key ? next : t) });
|
|
23613
23646
|
return <SmsCard
|
|
23614
23647
|
title="What the texts say"
|
|
23615
|
-
note="
|
|
23648
|
+
note="Every text below is sent automatically once texts are set up. The wording is fixed."
|
|
23616
23649
|
>
|
|
23650
|
+
<TestPhoneBlock onSaved={setPhone} onLoaded={setPhone} />
|
|
23651
|
+
<Show68 when={!isValidUsPhone(phone())}>
|
|
23652
|
+
<div style={muted3}>Save your phone number above to send a test.</div>
|
|
23653
|
+
</Show68>
|
|
23617
23654
|
<Show68 when={data.error}>
|
|
23618
23655
|
<div class="app-admin-notice" role="alert">
|
|
23619
23656
|
The texts could not be loaded. {data.error?.message}
|
|
@@ -23622,7 +23659,7 @@ function SmsTemplatesCard(props) {
|
|
|
23622
23659
|
<Show68 when={!data.error && data.loading}>
|
|
23623
23660
|
<LoadingSpinner />
|
|
23624
23661
|
</Show68>
|
|
23625
|
-
<For53 each={templates()}>{(t) => <TemplateRow template={t}
|
|
23662
|
+
<For53 each={templates()}>{(t) => <TemplateRow template={t} canTest={isValidUsPhone(phone())} />}</For53>
|
|
23626
23663
|
</SmsCard>;
|
|
23627
23664
|
}
|
|
23628
23665
|
|
|
@@ -29017,4 +29054,4 @@ export {
|
|
|
29017
29054
|
AffiliateForgotPassword,
|
|
29018
29055
|
AffiliateResetPassword
|
|
29019
29056
|
};
|
|
29020
|
-
//# sourceMappingURL=
|
|
29057
|
+
//# sourceMappingURL=K4SFTGFZ.jsx.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readPromoCode, clearPromoCode, readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './
|
|
2
|
-
import { useCardTokenizer, useSmsConsent, useAddressPair, useCatalogAvailability, isLive, formatCvv, formatExpiry, formatCardNumber, bestOfferDiscount, offerBeatsPromo, catalogUnavailableMessage, firstAddressError, validateAddress, isValidUsPhone, PHONE_ERROR } from './
|
|
3
|
-
import { auth_default, cart_default } from './
|
|
4
|
-
import { promoCodesApi, subscriptionsApi, offersApi, newIdempotencyKey, usersApi, ApiError } from './
|
|
1
|
+
import { readPromoCode, clearPromoCode, readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './JQIEY5VS.js';
|
|
2
|
+
import { useCardTokenizer, useSmsConsent, useAddressPair, useCatalogAvailability, isLive, formatCvv, formatExpiry, formatCardNumber, bestOfferDiscount, offerBeatsPromo, catalogUnavailableMessage, firstAddressError, validateAddress, isValidUsPhone, PHONE_ERROR } from './ANR4H6TB.js';
|
|
3
|
+
import { auth_default, cart_default } from './DFZFYIME.js';
|
|
4
|
+
import { promoCodesApi, subscriptionsApi, offersApi, newIdempotencyKey, usersApi, ApiError } from './FFHPVSPW.js';
|
|
5
5
|
import { getConfig } from './2IFPDU4D.js';
|
|
6
6
|
import { createSignal, onMount, createEffect, on, createRoot } from 'solid-js';
|
|
7
7
|
|
|
@@ -613,5 +613,5 @@ function startCartCapture(opts = {}) {
|
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
export { OFFER_BEATS_PROMO_NOTICE, restoreCartFromLink, startCartCapture, useSubscriptionIntakeFlow, validateResumedPromo };
|
|
616
|
-
//# sourceMappingURL=
|
|
617
|
-
//# sourceMappingURL=
|
|
616
|
+
//# sourceMappingURL=MFW42ITZ.js.map
|
|
617
|
+
//# sourceMappingURL=MFW42ITZ.js.map
|