@apextelemed/partner-core 0.10.0-dev.22 → 0.10.0-dev.23
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 +21 -2
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/index.jsx +5 -3
- package/dist/chunk/{NSEWFPUP.js → 7MCMXXYQ.js} +50 -3
- package/dist/chunk/7MCMXXYQ.js.map +1 -0
- package/dist/chunk/{TYXWVNC3.js → BNH4UOGN.js} +55 -12
- package/dist/chunk/BNH4UOGN.js.map +1 -0
- package/dist/chunk/{ET3GPUTR.jsx → CLNLTAG7.jsx} +59 -12
- package/dist/chunk/{BALHOD46.jsx → EZG74SQL.jsx} +49 -1
- package/dist/chunk/{DHVOZQQ2.js → FA4D2S5A.js} +3 -3
- package/dist/chunk/{DHVOZQQ2.js.map → FA4D2S5A.js.map} +1 -1
- package/dist/chunk/{OA3A3PUC.jsx → FM3JH2ZD.jsx} +1638 -860
- package/dist/chunk/{L2ZMGXWR.js → JKUWPGEW.js} +31 -6
- package/dist/chunk/JKUWPGEW.js.map +1 -0
- package/dist/chunk/{JL7B6RHG.js → M2LV5JQD.js} +3 -3
- package/dist/chunk/{JL7B6RHG.js.map → M2LV5JQD.js.map} +1 -1
- package/dist/chunk/{CYGHTTCA.js → NHNMRJL6.js} +1715 -905
- package/dist/chunk/NHNMRJL6.js.map +1 -0
- package/dist/chunk/{DBW2RWHV.jsx → RRKAKQ77.jsx} +2 -2
- package/dist/chunk/{QIBVNW2V.jsx → VF7FTWCG.jsx} +2 -2
- package/dist/chunk/{75F4YFYC.jsx → VG35MW6B.jsx} +33 -4
- package/dist/chunk/{ZW2HBOS5.jsx → XW4PEQPI.jsx} +2 -2
- package/dist/chunk/{4CTTOSOW.js → XZXPLS3K.js} +3 -3
- package/dist/chunk/{4CTTOSOW.js.map → XZXPLS3K.js.map} +1 -1
- package/dist/{client-CDpCqI4d.d.ts → client-DsIvVM5a.d.ts} +143 -1
- package/dist/flows/index.d.ts +213 -141
- package/dist/flows/index.js +6 -6
- package/dist/flows/index.jsx +16 -6
- package/dist/index/index.d.ts +2 -2
- package/dist/index/index.js +7 -7
- package/dist/index/index.jsx +19 -7
- package/dist/pages/index.d.ts +2 -2
- 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/CYGHTTCA.js.map +0 -1
- package/dist/chunk/L2ZMGXWR.js.map +0 -1
- package/dist/chunk/NSEWFPUP.js.map +0 -1
- package/dist/chunk/TYXWVNC3.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/flows/subscriptionIntake.ts","../../src/flows/cartCapture.ts"],"names":["createEffect","on"],"mappings":";;;;;;;AAwBA,IAAM,YAAA,GAAe,CAAA,GAAI,EAAA,GAAK,IAAA,GAAO,GAAA;AACrC,IAAM,mBAAA,GAAsB,CAAA;AAoB5B,SAAS,QAAA,GAAmB;AAC1B,EAAA,OAAO,CAAA,EAAG,SAAA,EAAU,CAAE,aAAa,CAAA,0BAAA,CAAA;AACrC;AAEA,SAAS,SAAA,GAAyB;AAChC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,YAAA,CAAa,OAAA,CAAQ,QAAA,EAAU,CAAA;AAC3C,IAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC7B,IAAA,IAAI,OAAO,OAAA,IAAW,IAAA,CAAK,KAAI,GAAI,MAAA,CAAO,UAAU,YAAA,EAAc;AAChE,MAAA,YAAA,CAAa,UAAA,CAAW,UAAU,CAAA;AAClC,MAAA,OAAO,EAAC;AAAA,IACV;AACA,IAAA,OAAO,UAAU,EAAC;AAAA,EACpB,CAAA,CAAA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AAA,WAAkB,CAAC,CAAA;AAAA,EACzB,CAAC,CAAA;AAID,EAAA,MAAM,UAAA,GAAa,MAAM,KAAA,EAAM;AAC/B,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,MAAA,CAAO,qBAAqB,UAAA,EAAY;AAClF,IAAA,MAAA,CAAO,gBAAA,CAAiB,YAAY,UAAU,CAAA;AAAA,EAChD;AAEA,EAAA,OAAO,MAAM;AACX,IAAA,IAAI,KAAA,eAAoB,KAAK,CAAA;AAC7B,IAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,MAAA,CAAO,wBAAwB,UAAA,EAAY;AACrF,MAAA,MAAA,CAAO,mBAAA,CAAoB,YAAY,UAAU,CAAA;AAAA,IACnD;AACA,IAAA,OAAA,EAAQ;AACR,IAAA,aAAA,GAAgB,IAAA;AAChB,IAAA,OAAA,GAAU,KAAA;AAAA,EACZ,CAAA;AACF","file":"BNH4UOGN.js","sourcesContent":["import { createEffect, createSignal, on, onMount, type Accessor } from 'solid-js';\nimport {\n offersApi,\n promoCodesApi,\n subscriptionsApi,\n usersApi,\n newIdempotencyKey,\n ApiError,\n type MemberOffer,\n type PromoValidationResponse,\n type ApiResponse,\n} from '../api/client';\nimport { bestOfferDiscount, offerBeatsPromo } from './offers';\nimport { readPromoCode, clearPromoCode } from '../api/promoRef';\nimport authStore from '../stores/auth';\nimport { useCardTokenizer } from './_internal/cardTokenizer';\nimport { formatCardNumber, formatExpiry, formatCvv } from './checkout';\nimport { getConfig } from '../config';\nimport { useAddressPair, validateAddress, firstAddressError, type AddressPair } from './address';\nimport { isLive } from './subscriptionStatus';\nimport { useCatalogAvailability, catalogUnavailableMessage, type CatalogAvailabilityState } from './catalogAvailability';\n\n// ── Draft persistence ───────────────────────────────────────────────\n\nconst DRAFT_TTL_MS = 7 * 24 * 3600 * 1000;\nconst MAX_RESTORABLE_STEP = 1; // Account + Address only; never restore into Payment\n\ninterface IntakeDraft {\n step?: number;\n firstName?: string;\n lastName?: string;\n dateOfBirth?: string;\n email?: string;\n phone?: string;\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n /** Idempotency key for THIS draft's create/signup attempt. Persisted so a\n * refresh mid-submit retries with the SAME key and the backend dedupes\n * instead of double-charging; rotated after a definitive rejection. */\n idempotencyKey?: string;\n savedAt?: number;\n}\n\nfunction draftKey(): string {\n return `${getConfig().storagePrefix}-subscription-intake-draft`;\n}\n\nfunction loadDraft(): IntakeDraft {\n try {\n const raw = localStorage.getItem(draftKey());\n if (!raw) return {};\n const parsed = JSON.parse(raw) as IntakeDraft;\n if (parsed.savedAt && Date.now() - parsed.savedAt > DRAFT_TTL_MS) {\n localStorage.removeItem(draftKey());\n return {};\n }\n return parsed ?? {};\n } catch {\n return {};\n }\n}\n\nfunction saveDraft(draft: IntakeDraft) {\n try {\n localStorage.setItem(draftKey(), JSON.stringify({ ...draft, savedAt: Date.now() }));\n } catch {\n // noop\n }\n}\n\nfunction clearDraft() {\n try {\n localStorage.removeItem(draftKey());\n } catch {\n // noop\n }\n}\n\n// ── Types ───────────────────────────────────────────────────────────\n\nexport interface SurveyResult {\n surveyResponseId: string;\n /**\n * v2 survey response id. When set, the Rx is linked to the Apex survey\n * snapshot and Apex generates the prescriber case notes from it (no local\n * caseNotes synthesis). Leave unset for the legacy v1 flow.\n */\n v2SurveyResponseId?: string;\n caseNotes?: string;\n drugId: string;\n drugName: string;\n dosage: string;\n}\n\nexport interface MedicationPricing {\n productId: string;\n productName: string;\n priceCents: number;\n savingsPriceCents?: number | null;\n}\n\nexport type SubscriptionIntakeOutcome =\n | { kind: 'in_progress' }\n | { kind: 'tokenizing' }\n | { kind: 'submitting' }\n /**\n * The member already holds a live subscription, so this intake must not create\n * a second one. Emitted ONLY under `singleSubscription` — without that option\n * the flow behaves exactly as before, so existing consumers that switch on\n * 'completed' alone are unaffected.\n *\n * Deliberately NOT 'completed': that kind means *this* purchase succeeded, and\n * hosts navigate onward celebrating it. This one means the member arrived\n * already subscribed and needs telling, not congratulating.\n */\n | { kind: 'already_subscribed'; productId?: string }\n | { kind: 'completed' };\n\nexport interface UseSubscriptionIntakeFlowOptions {\n surveyResult: SurveyResult;\n pricing: MedicationPricing;\n intervalDays?: number;\n /**\n * Whether the member is enrolled in the savings program — read reactively, so\n * a verification that completes mid-intake re-quotes. When true and the\n * product defines `savingsPriceCents`, that rate is quoted instead of list.\n *\n * Must track the same member the SERVER will resolve at charge time (the\n * persisted savings link), or the quote and the charge disagree.\n */\n isSavingsMember?: () => boolean;\n /**\n * The verified savings member id to send on the unauthenticated signup path,\n * so an account created AT checkout is linked and charged the savings rate\n * (the backend accepts and links `savingsMemberId` on register-and-subscribe,\n * but it was never sent). Read at submit time; null/empty sends nothing. The\n * authenticated path ignores it — the server prices off the persisted link.\n */\n savingsMemberId?: () => string | null;\n /**\n * Single-subscription tenants: the site sells ONE subscription program, so a\n * member may hold at most one live subscription — of ANY product.\n *\n * Widens the mount reconcile below from \"already subscribed to THIS product\"\n * to \"already subscribed to anything\", and turns the server's\n * `SUBSCRIPTION_EXISTS` rejection into an `already_subscribed` outcome instead\n * of a raw error banner. Mirrors `features.singleSubscription` on the tenant;\n * setting it here without the tenant flag still guards the common paths, but\n * the server is what actually enforces it.\n */\n singleSubscription?: boolean;\n}\n\nexport interface PromoPricing {\n baseCents: number;\n /** What is actually taken off: the promo's discount or the offer's, never both. */\n discountCents: number;\n finalCents: number;\n /** Set when the typed promo code is the discount applied. */\n promoCode?: string;\n /**\n * Set ONLY when the member's own offer is the discount applied — it beat the\n * typed promo code, or there was none. Absent whenever `promoCode` is set.\n */\n offer?: {\n label: string;\n /** \"$10\" / \"15%\". */\n amountText: string;\n /** The last day to claim it, ready to print (\"November 11, 2026\"). */\n deadlineText: string;\n recurringIndefinite: boolean;\n /** Rebills after the first charge that carry the discount. */\n recurringCharges: number;\n discountCents: number;\n };\n}\n\n/** Shown when a typed code is valid but the member's offer is worth more. */\nexport const OFFER_BEATS_PROMO_NOTICE =\n 'Your offer is the better discount, so it is the one applied. A promo code does not combine with an offer.';\n\nexport interface SubscriptionIntakeFlow {\n // Step 0 = Account, 1 = Address, 2 = Payment\n step: Accessor<number>;\n stepCount: 3;\n next: () => Promise<void>;\n back: () => void;\n\n outcome: Accessor<SubscriptionIntakeOutcome>;\n error: Accessor<string | null>;\n submitting: Accessor<boolean>;\n tokenizing: Accessor<boolean>;\n /** True once the card tokenizer is ready (config loaded; for AuthNet, Accept.js loaded too). Gate submission on this. */\n tokenizerReady: Accessor<boolean>;\n /** @deprecated alias of tokenizerReady (pre-rename name). */\n acceptJsReady: Accessor<boolean>;\n /** Non-null when payment setup failed to initialize — render as a banner. */\n /** Tokenizer init failure, or null. */\n tokenizerError: Accessor<string | null>;\n /** @deprecated alias of tokenizerError (pre-rename name). */\n acceptJsError: Accessor<string | null>;\n\n // Step 0 — Account\n firstName: Accessor<string>; setFirstName: (v: string) => void;\n lastName: Accessor<string>; setLastName: (v: string) => void;\n email: Accessor<string>; setEmail: (v: string) => void;\n password: Accessor<string>; setPassword: (v: string) => void;\n dateOfBirth: Accessor<string>; setDateOfBirth: (v: string) => void;\n phone: Accessor<string>; setPhone: (v: string) => void;\n\n // Step 1 — Address (delivery + billing override; see AddressPair).\n // `address.billingSameAsShipping` is this flow's \"billing same as delivery\".\n address: AddressPair;\n\n /** Per-item deliverability for `medication.productId` in the address's\n * shipping state — a catalog item routed to a pharmacy that doesn't serve\n * that state. Per ITEM, on top of the tenant-level `unavailableStates`\n * gating the address step already applies. `submit()` refuses to charge\n * while `availability.blocking()` is true. */\n availability: CatalogAvailabilityState;\n\n // Step 2 — Payment\n cardNumber: Accessor<string>; setCardNumber: (v: string) => void;\n expiry: Accessor<string>; setExpiry: (v: string) => void;\n cvv: Accessor<string>; setCvv: (v: string) => void;\n\n // Promo\n promoCode: Accessor<string>; setPromoCode: (v: string) => void;\n promoValidating: Accessor<boolean>;\n promoError: Accessor<string | null>;\n promoApplied: Accessor<PromoValidationResponse | null>;\n applyPromo: () => Promise<void>;\n clearPromo: () => void;\n /**\n * Plain words for the member when their valid promo code is NOT the discount\n * applied because their offer is worth more; null otherwise. Render it by the\n * promo field so a code that \"did nothing\" is explained.\n */\n promoNotice: Accessor<string | null>;\n\n // Pricing (reflects the applied promo or the member's offer, whichever is better)\n pricing: Accessor<PromoPricing>;\n\n // Context (read-only, from options)\n surveyResult: SurveyResult;\n medication: MedicationPricing;\n\n submit: () => Promise<void>;\n}\n\n// ── Hook ────────────────────────────────────────────────────────────\n\nexport function useSubscriptionIntakeFlow(\n options: UseSubscriptionIntakeFlowOptions,\n): SubscriptionIntakeFlow {\n const accept = useCardTokenizer();\n\n let restored: IntakeDraft = {};\n if (typeof window !== 'undefined') restored = loadDraft();\n\n const [step, setStep] = createSignal(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));\n const [error, setError] = createSignal<string | null>(null);\n const [tokenizing, setTokenizing] = createSignal(false);\n const [submitting, setSubmitting] = createSignal(false);\n const [outcome, setOutcome] = createSignal<SubscriptionIntakeOutcome>({ kind: 'in_progress' });\n\n // Account\n const [firstName, setFirstName] = createSignal(restored.firstName ?? '');\n const [lastName, setLastName] = createSignal(restored.lastName ?? '');\n const [email, setEmail] = createSignal(restored.email ?? '');\n const [password, setPassword] = createSignal('');\n const [dateOfBirth, setDateOfBirth] = createSignal(restored.dateOfBirth ?? '');\n const [phone, setPhone] = createSignal(restored.phone ?? '');\n\n // Address (delivery/shipping + billing override), backed by the shared\n // useAddressPair so validation and the same-as / copy-on-uncheck behavior\n // match the checkout flow. The individual accessors below keep this flow's\n // public interface stable for consuming storefronts (no breaking change).\n const addr = useAddressPair({\n initialShipping: {\n street: restored.street ?? '',\n city: restored.city ?? '',\n state: restored.state ?? '',\n zip: restored.zip ?? '',\n },\n });\n\n // Internal shipping getters for draft persistence + payload building; the full\n // read/write surface (incl. billing override) is exposed as `address` below.\n const street = () => addr.shipping().street;\n const city = () => addr.shipping().city;\n const state = () => addr.shipping().state;\n const zip = () => addr.shipping().zip;\n\n // Effective billing address sent as the charge's billTo.\n const effectiveBillingAddress = () => {\n const b = addr.effectiveBilling();\n return { street: b.street.trim(), city: b.city.trim(), state: b.state, zip: b.zip.trim() };\n };\n\n // Single-item intake: `medication.productId` (the-backend product id) is\n // the same id the survey composed against. Runs from mount — harmless\n // before the address step, since `state` is empty and the hook skips the\n // call until it isn't.\n const availability = useCatalogAvailability(\n () => [options.pricing.productId],\n () => state(),\n );\n\n // Payment\n const [cardNumberRaw, setCardNumberRaw] = createSignal('', { equals: false });\n const [expiryRaw, setExpiryRaw] = createSignal('', { equals: false });\n const [cvvRaw, setCvvRaw] = createSignal('', { equals: false });\n\n // Promo\n const [promoCode, setPromoCode] = createSignal('');\n const [promoValidating, setPromoValidating] = createSignal(false);\n const [promoError, setPromoError] = createSignal<string | null>(null);\n const [promoApplied, setPromoApplied] = createSignal<PromoValidationResponse | null>(null);\n\n // ── Pre-fill from a `?promo=` landing ───────────────────────────\n //\n // A campaign link stashes its code (see api/promoRef). Being inside the\n // storage window says nothing about the CODE still being live — a sale can end\n // while the stash is fresh — so re-validate before showing it to anyone, and\n // drop it silently when the server says no. An expired or withdrawn code must\n // not greet a member with an error they did nothing to cause.\n //\n // A code that validates is APPLIED, not merely pre-filled. The page that\n // handed it over already showed the member a price with it taken off (the\n // savings page quotes \"an extra $X off with TRUE10\"); leaving it for them to\n // press Apply meant most were charged $X more than they were shown. The\n // validation above is the same one Apply runs, so a code the server refuses\n // — expired, or exclusive for a savings member — is dropped silently rather\n // than surfacing a refusal on arrival.\n //\n // Yields to anything already in the field. Nothing sets it before mount today\n // (the draft does not persist a promo), but a member's own entry must never be\n // overwritten by a stale link if that changes.\n onMount(async () => {\n if (promoCode().trim()) return;\n const stashed = readPromoCode();\n if (!stashed) return;\n try {\n const res = await promoCodesApi.validate(stashed, {\n productIds: [options.pricing.productId],\n subtotalCents: savingsBaseCents(),\n });\n if (res.valid) {\n setPromoCode(stashed);\n setPromoApplied(res);\n } else clearPromoCode();\n } catch {\n // Network/-server blip: leave the stash for the next visit rather than\n // discarding a code that may be perfectly good.\n }\n });\n\n // Idempotency key for the create/signup POST — restored with the draft so a\n // retry after a refresh presents the same key (see IntakeDraft.idempotencyKey).\n const [idemKey, setIdemKey] = createSignal(restored.idempotencyKey ?? '');\n\n // ── Auto-save draft ─────────────────────────────────────────────\n\n onMount(() => {\n createEffect(() => {\n saveDraft({\n step: step(),\n firstName: firstName(),\n lastName: lastName(),\n dateOfBirth: dateOfBirth(),\n email: email(),\n phone: phone(),\n street: street(),\n city: city(),\n state: state(),\n zip: zip(),\n idempotencyKey: idemKey() || undefined,\n });\n });\n });\n\n // ── Mount reconcile (authenticated re-subscribe path) ───────────\n //\n // The restored draft re-arms submit with no memory of a create that already\n // committed: if the subscription landed server-side but this client never saw\n // the response (refresh mid-submit, dropped connection), the user is invited\n // to subscribe — and be charged — again. Ask the server before offering the\n // form.\n //\n // Scope depends on the tenant's model:\n // default → THIS product only. A subscription to a different\n // medication is a legitimate separate purchase and\n // must not block this intake.\n // singleSubscription → any live subscription. The program IS the\n // subscription, so a second one of any product is a\n // double charge, not a second purchase.\n //\n // The unauthenticated path needs no reconcile (a committed signup makes the\n // email taken, so a re-submit fails instead of double-charging). Fails open —\n // the server refuses the duplicate regardless, and blocking a real intake on a\n // lookup blip costs a customer.\n onMount(async () => {\n if (!authStore.isAuthenticated()) return;\n try {\n const res = (await subscriptionsApi.list()) as {\n subscriptions?: Array<{ productId?: string; status?: string }>;\n } | null;\n const existing = res?.subscriptions?.find(\n (s) =>\n isLive(s.status) &&\n (options.singleSubscription || s.productId === options.pricing.productId),\n );\n if (existing) {\n clearDraft();\n // Same-product is the ambiguous-retry case this reconcile was built for:\n // the purchase this very flow was configured for already exists, so the\n // member is done. A DIFFERENT product means they came back to buy\n // something they can't have alongside what they hold — a distinct\n // outcome, and only reachable under singleSubscription.\n setOutcome(\n existing.productId === options.pricing.productId\n ? { kind: 'completed' }\n : { kind: 'already_subscribed', productId: existing.productId },\n );\n }\n } catch {\n // Reconcile is a guard, not a gate — never block intake on a lookup blip.\n }\n });\n\n // ── Pricing ─────────────────────────────────────────────────────\n\n /**\n * The base price to quote: the product's savings rate for an enrolled member,\n * otherwise list.\n *\n * `savingsPriceCents` was carried on MedicationPricing but never actually\n * read, so enrolled members were quoted (and charged) list price. This mirrors\n * the SERVER rule exactly — `resolveProductPricing` in the-backend keys off\n * the member's savings link and treats a null savings price as \"no savings\n * rate for this item\", never as free — because the server re-derives the\n * charge from the DB and ignores the amount posted here. If the two rules ever\n * disagree, the member sees one number and is charged another; that mismatch\n * is the whole reason this exists, so keep them in step.\n */\n const savingsBaseCents = (): number => {\n const list = options.pricing.priceCents;\n const savings = options.pricing.savingsPriceCents;\n return options.isSavingsMember?.() && savings != null ? savings : list;\n };\n\n // ── The member's own offers ─────────────────────────────────────\n //\n // An offer is a discount this person holds (the-backend offers.ts). The\n // server applies it at checkout without being asked, so the total shown here\n // has to include it or the member reads one number and is charged a lower\n // one. Loaded for the session when there is one, and for a guest by the address\n // they are registering with, so nobody reaches the payment step looking at a\n // price they will not be charged. A failed read is \"no offers\": a backend from before\n // offers has no such endpoint, and a discount we cannot show must never\n // stand between a member and checkout.\n const [offers, setOffers] = createSignal<MemberOffer[]>([]);\n // Who to ask about: the session when there is one; otherwise the address a\n // guest has given, once they are past the Account step — it cannot change\n // from there on, so this asks once, not per keystroke. '' = nobody yet.\n const offerSubject = (): string => {\n if (authStore.isAuthenticated()) return 'session';\n const address = email().trim().toLowerCase();\n return step() > 0 && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(address) ? address : '';\n };\n createEffect(\n on(offerSubject, (subject) => {\n if (!subject) {\n setOffers([]);\n return;\n }\n void (async () => {\n let found: MemberOffer[] = [];\n try {\n const res = subject === 'session' ? await offersApi.mine() : await offersApi.forEmail(subject);\n if (Array.isArray(res?.offers)) found = res.offers;\n } catch {\n // No offers to show; the server still applies any they hold.\n }\n // The session or the address may have changed while this was in flight.\n setOffers(offerSubject() === subject ? found : []);\n })();\n }),\n );\n\n /**\n * One slot, two contenders: the typed promo code and the member's best offer.\n * The larger discount applies and the other is dropped — they never add up —\n * and a tie goes to the code. Same rule as the server's discount engine,\n * which is what actually prices the charge.\n */\n const pricing = (): PromoPricing => {\n const baseCents = savingsBaseCents();\n const promo = promoApplied();\n const promoCents = promo?.valid && promo.discountCents ? Math.min(baseCents, promo.discountCents) : 0;\n const best = bestOfferDiscount(offers(), { productIds: [options.pricing.productId], baseCents });\n\n if (best && offerBeatsPromo(best.discountCents, promoCents)) {\n const o = best.offer;\n return {\n baseCents,\n discountCents: best.discountCents,\n finalCents: baseCents - best.discountCents,\n offer: {\n label: o.label,\n amountText: o.amountText,\n deadlineText: o.deadlineText,\n recurringIndefinite: o.recurringIndefinite,\n recurringCharges: o.recurringCharges ?? 0,\n discountCents: best.discountCents,\n },\n };\n }\n if (promoCents === 0) {\n return { baseCents, discountCents: 0, finalCents: baseCents };\n }\n return {\n baseCents,\n discountCents: promoCents,\n finalCents: promo!.finalCents ?? Math.max(0, baseCents - promoCents),\n promoCode: promo!.promoCode?.code,\n };\n };\n\n const promoNotice = (): string | null =>\n promoApplied()?.valid && pricing().offer ? OFFER_BEATS_PROMO_NOTICE : null;\n\n // ── Promo code ──────────────────────────────────────────────────\n\n async function applyPromo() {\n const code = promoCode().trim();\n if (!code) {\n setPromoError('Enter a promo code.');\n return;\n }\n setPromoError(null);\n setPromoValidating(true);\n try {\n const res = await promoCodesApi.validate(code, {\n productIds: [options.pricing.productId],\n // The base the promo will actually be applied to. For a savings member\n // that is the savings price, not list: the server discounts the\n // savings-substituted subtotal at checkout, so quoting off list would\n // show a percentage promo as a bigger saving than it is (10% of $399\n // displayed, 10% of $280 charged). Same rule as savingsBaseCents — keep\n // the two in step.\n subtotalCents: savingsBaseCents(),\n });\n if (!res.valid) {\n setPromoError(res.error ?? 'Invalid promo code.');\n setPromoApplied(null);\n } else {\n setPromoApplied(res);\n setPromoError(null);\n }\n } catch {\n setPromoError('Could not validate promo code. Please try again.');\n setPromoApplied(null);\n } finally {\n setPromoValidating(false);\n }\n }\n\n function clearPromo() {\n setPromoCode('');\n setPromoApplied(null);\n setPromoError(null);\n }\n\n // ── Validation per step ─────────────────────────────────────────\n\n function validateStep(s: number): string | null {\n if (s === 0) {\n if (!firstName().trim()) return 'First name is required.';\n if (!lastName().trim()) return 'Last name is required.';\n // Authenticated members already have an account — they don't re-enter\n // credentials; submit() subscribes their existing account instead.\n if (!authStore.isAuthenticated()) {\n if (!email().trim()) return 'Email is required.';\n if (!password().trim()) return 'Password is required.';\n if (password().length < 8) return 'Password must be at least 8 characters.';\n }\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(dateOfBirth())) return 'Enter a valid date of birth.';\n const dob = new Date(dateOfBirth() + 'T00:00:00');\n if (Number.isNaN(dob.getTime())) return 'Enter a valid date of birth.';\n const age = (Date.now() - dob.getTime()) / (365.25 * 24 * 3600 * 1000);\n if (age < 18) return 'You must be at least 18 to register.';\n if (age > 120) return 'Enter a valid date of birth.';\n } else if (s === 1) {\n return firstAddressError(validateAddress(addr.shipping(), '', { enforceAvailability: true }));\n } else if (s === 2) {\n if (!cardNumberRaw().trim()) return 'Card number is required.';\n if (!expiryRaw().trim()) return 'Expiration date is required.';\n if (!cvvRaw().trim()) return 'CVV is required.';\n }\n return null;\n }\n\n // ── Navigation ───────────────────────────────────────────────────\n\n async function next() {\n const err = validateStep(step());\n if (err) {\n setError(err);\n return;\n }\n setError(null);\n setStep((s) => s + 1);\n }\n\n function back() {\n setError(null);\n if (step() > 0) setStep((s) => s - 1);\n }\n\n // ── Submit (from Payment step) ──────────────────────────────────\n\n let awaitingAvailability = false;\n\n async function submit() {\n // Never charge (or create the Rx) for an item Apex just told us can't be\n // filled at this shipping address — checked before tokenizing so a\n // blocked patient never enters a card for nothing.\n // Held across the wait: a second click while the check is pending must\n // not start a second submit (the submitting flag is only set below).\n if (awaitingAvailability) return;\n awaitingAvailability = true;\n try {\n await availability.settled();\n } finally {\n awaitingAvailability = false;\n }\n if (availability.blocking()) {\n setError(catalogUnavailableMessage(options.pricing.productName, state()));\n return;\n }\n\n const finalPricing = pricing();\n const isFree = finalPricing.finalCents === 0;\n\n if (!isFree) {\n const cardErr = validateStep(2);\n if (cardErr) {\n setError(cardErr);\n return;\n }\n if (addr.billingIsOverride()) {\n const bErr = firstAddressError(validateAddress(addr.billing(), 'Billing'));\n if (bErr) { setError(bErr); return; }\n }\n }\n\n setError(null);\n\n let opaque: Record<string, unknown> | undefined;\n if (!isFree) {\n setTokenizing(true);\n setOutcome({ kind: 'tokenizing' });\n try {\n opaque = await accept.tokenize({\n cardNumber: cardNumberRaw(),\n expiry: expiryRaw(),\n cvv: cvvRaw(),\n });\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Card tokenization failed.');\n setTokenizing(false);\n setOutcome({ kind: 'in_progress' });\n return;\n }\n setTokenizing(false);\n }\n\n setSubmitting(true);\n setOutcome({ kind: 'submitting' });\n\n // One key per logical purchase attempt: minted on first submit, persisted in\n // the draft (the auto-save effect tracks it), reused verbatim on retries so\n // the backend's idempotency middleware can collapse a replay of a create\n // that already committed.\n let idempotencyKey = idemKey();\n if (!idempotencyKey) {\n idempotencyKey = newIdempotencyKey();\n setIdemKey(idempotencyKey);\n }\n\n try {\n const promo = promoApplied();\n\n if (authStore.isAuthenticated()) {\n // Logged-in member (e.g. a savings member who created an account first):\n // subscribe their EXISTING account instead of creating a second one. The\n // account may be name-only, so first persist the profile entered during\n // intake, then create the subscription + Apex Rx on that account.\n await usersApi.updateProfile({\n firstName: firstName().trim(),\n lastName: lastName().trim(),\n dateOfBirth: dateOfBirth(),\n phone: phone().trim() || undefined,\n address1: street().trim(),\n city: city().trim(),\n state: state(),\n zip: zip().trim(),\n });\n\n const res = await subscriptionsApi.create({\n opaqueData: opaque,\n amountCents: finalPricing.baseCents,\n intervalDays: options.intervalDays ?? 30,\n billingAddress: effectiveBillingAddress(),\n products: [{\n productId: options.pricing.productId,\n productName: options.pricing.productName,\n quantity: 1,\n dosage: options.surveyResult.dosage,\n }],\n productId: options.pricing.productId,\n promoCode: promo?.valid ? promo.promoCode?.code : undefined,\n metadata: {\n drugId: options.surveyResult.drugId,\n selectedDosage: options.surveyResult.dosage,\n caseNotes: options.surveyResult.caseNotes,\n v2SurveyResponseId: options.surveyResult.v2SurveyResponseId,\n },\n }, { idempotencyKey });\n if ((res as ApiResponse).error) {\n throw new Error((res as ApiResponse).error || 'Subscription failed. Please try again.');\n }\n } else {\n const savingsMemberId = options.savingsMemberId?.() || undefined;\n await authStore.signupAndSubscribe({\n email: email().trim(),\n password: password(),\n member: {\n firstName: firstName().trim(),\n lastName: lastName().trim(),\n dateOfBirth: dateOfBirth(),\n phone: phone().trim() || undefined,\n address1: street().trim(),\n city: city().trim(),\n state: state(),\n zip: zip().trim(),\n },\n opaqueData: opaque,\n amountCents: finalPricing.baseCents,\n intervalDays: options.intervalDays ?? 30,\n medication: options.surveyResult.drugId,\n products: [{\n productId: options.pricing.productId,\n productName: options.pricing.productName,\n quantity: 1,\n dosage: options.surveyResult.dosage,\n }],\n billingAddress: effectiveBillingAddress(),\n surveyResponseId: options.surveyResult.surveyResponseId,\n v2SurveyResponseId: options.surveyResult.v2SurveyResponseId,\n caseNotes: options.surveyResult.caseNotes,\n promoCode: promo?.valid ? promo.promoCode?.code : undefined,\n ...(savingsMemberId ? { savingsMemberId } : {}),\n }, { idempotencyKey });\n }\n\n clearDraft();\n setOutcome({ kind: 'completed' });\n } catch (err) {\n // The server refused because this member already holds a live\n // subscription. Not an error the member can act on by retrying — nothing\n // is wrong with what they typed — so surface it as its own outcome and\n // let the host explain, rather than as a red banner over a form that will\n // never succeed. Draft cleared so a later legitimate intake (after a\n // cancellation) starts clean.\n if (err instanceof ApiError && err.code === 'SUBSCRIPTION_EXISTS') {\n clearDraft();\n setOutcome({ kind: 'already_subscribed' });\n return;\n }\n\n // A definitive rejection (4xx: decline, validation) means nothing was\n // committed — the next attempt is a NEW operation and must not be\n // deduped against this one, so rotate the key. An AMBIGUOUS failure\n // (connection dropped, 5xx) may have committed server-side: keep the key\n // so the retry collapses into the original instead of charging twice.\n const maybeCommitted = err instanceof ApiError && err.ambiguous;\n if (!maybeCommitted) setIdemKey(newIdempotencyKey());\n\n setError(err instanceof Error ? err.message : 'Registration failed. Please try again.');\n setOutcome({ kind: 'in_progress' });\n } finally {\n setSubmitting(false);\n }\n }\n\n return {\n step,\n stepCount: 3,\n next,\n back,\n\n outcome,\n error,\n submitting,\n tokenizing,\n tokenizerReady: accept.ready,\n acceptJsReady: accept.ready,\n tokenizerError: accept.error,\n acceptJsError: accept.error,\n\n firstName, setFirstName,\n lastName, setLastName,\n email, setEmail,\n password, setPassword,\n dateOfBirth, setDateOfBirth,\n phone, setPhone,\n\n address: addr,\n availability,\n\n cardNumber: cardNumberRaw,\n setCardNumber: (v) => setCardNumberRaw(formatCardNumber(v)),\n expiry: expiryRaw,\n setExpiry: (v) => setExpiryRaw(formatExpiry(v)),\n cvv: cvvRaw,\n setCvv: (v) => setCvvRaw(formatCvv(v)),\n\n promoCode,\n setPromoCode,\n promoValidating,\n promoError,\n promoApplied,\n applyPromo,\n clearPromo,\n promoNotice,\n\n pricing,\n\n surveyResult: options.surveyResult,\n medication: options.pricing,\n\n submit,\n };\n}\n","import { createEffect, createRoot, on } from 'solid-js';\nimport cartStore, { type CartItem } from '../stores/cart';\nimport { promoCodesApi } from '../api/client';\nimport {\n adoptCartId,\n fetchCartConfig,\n fetchResumedCart,\n postCartSnapshot,\n readCartToken,\n resetCartId,\n stripCartToken,\n type CartSnapshotLine,\n type ResumedCart,\n} from '../api/cart';\n\n// Abandoned-cart capture, wired to core's cart store by default and to a\n// site's own basket via `options.source` (see CartSource).\n//\n// Two halves, both best-effort:\n//\n// - SNAPSHOT: every cart change is mirrored to the-backend (debounced, plus a\n// flush on pagehide — a shopper leaving is exactly the moment this exists\n// for). Identity only; the server re-prices.\n// - RESTORE: a `?cart=` token in the URL is traded for the saved cart and\n// rebuilt locally, so a recovery email opened on a phone brings the basket\n// with it.\n//\n// Nothing here may block, slow or break shopping. Every failure path ends in\n// \"carry on with the cart this browser already had\".\n\nexport interface CartCaptureOptions {\n /** Debounce for snapshot writes. Quantity steppers fire fast. */\n debounceMs?: number;\n /**\n * Address for an anonymous shopper, if the site collected one outside the\n * survey's email gate (e.g. checkout step 1). Logged-in shoppers need\n * nothing here — the backend reads their email off the token.\n */\n email?: () => string | null | undefined;\n /**\n * Where the basket lives, for a site that has no catalog cart.\n *\n * Abandonment is not a storefront-only event: a single-subscription partner\n * (mytruemeds, axiom-md) lets a patient choose a medication and a dose and\n * then walk away from the payment step, which is the same loss and the same\n * recoverable moment — but the selection lives in that site's own intake\n * state, not in `stores/cart`, so the default wiring watches an empty store\n * forever.\n *\n * Read and write are one option rather than two on purpose: a site that\n * supplies its own items must also say how a resumed cart gets back in, or\n * the `?cart=` link would rebuild into core's cart store, which such a site\n * never renders. Omit entirely to drive core's cart store (the default).\n */\n source?: CartSource;\n}\n\n/** A site's own basket, in the shape the wire already speaks. */\nexport interface CartSource {\n /** Current lines. Must be reactive — this is tracked. */\n items: () => CartSnapshotLine[];\n /** Promo code riding on the cart, if the site has one. */\n promoCode?: () => string | null | undefined;\n /**\n * Rebuild the site's own state from a cart resumed off a `?cart=` link. The\n * lines are re-priced against today's catalog; the promo code (if any) is\n * NOT re-validated for a custom source — `validateResumedPromo` does that\n * for a site that wants it.\n */\n restore: (cart: ResumedCart) => void;\n}\n\nfunction toSnapshotLines(items: CartItem[]): CartSnapshotLine[] {\n return items.map((i) => ({\n productId: i.productId,\n ...(i.dosage ? { dosage: i.dosage } : {}),\n quantity: i.quantity || 1,\n }));\n}\n\n/**\n * Who a resumed cart is handed to. Default rebuilds core's cart store; a site\n * with its own basket claims it in `startCartCapture` (synchronously, before\n * anything can await), so a later `restoreCartFromLink()` reaches the right\n * place.\n */\nlet restoreTarget: ((cart: ResumedCart) => void) | null = null;\n\n/** Rebuild the local cart from a resumed one, replacing whatever was there. */\nfunction applyResumedCart(resumed: ResumedCart): void {\n cartStore.clear();\n for (const line of resumed.items) {\n cartStore.add({\n productId: line.productId,\n productName: line.name,\n dosage: line.dosage ?? '',\n quantity: 1,\n // The sale price when one is running — same figure the catalog shows.\n priceCents: line.salePriceCents ?? line.priceCents,\n drugId: line.productId,\n apexDrugId: line.apexDrugId,\n categories: line.categories,\n thumbnailUrl: line.thumbnailUrl ?? undefined,\n hideDoseLabel: line.hideDoseLabel || undefined,\n isSubscription: line.isSubscription || undefined,\n });\n if (line.quantity > 1) {\n cartStore.setQuantity(cartStore.itemKey(line.productId, line.dosage ?? ''), line.quantity);\n }\n }\n}\n\nexport interface ValidatedResumedPromo {\n code: string;\n discountType: 'percent' | 'fixed';\n discountValueCents: number;\n discountCents: number;\n}\n\n/**\n * Re-check the promo code a resumed cart was carrying, against today's rules\n * and today's lines. Null when there was no code, when it no longer validates,\n * or when the check itself fails — the cart is restored either way.\n *\n * Exported because a site with its own `CartSource` needs the same guarantee\n * without core's cart store: showing a discount checkout won't honor is worse\n * than showing none.\n */\nexport async function validateResumedPromo(resumed: ResumedCart): Promise<ValidatedResumedPromo | null> {\n if (!resumed.promoCode) return null;\n try {\n const res = await promoCodesApi.validate(resumed.promoCode, {\n productIds: resumed.items.map((i) => i.productId),\n subtotalCents: resumed.subtotalCents,\n });\n if (!res.valid || !res.promoCode) return null;\n return {\n code: res.promoCode.code,\n discountType: res.promoCode.discountType,\n discountValueCents: res.promoCode.discountValueCents,\n discountCents: res.discountCents ?? 0,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Re-apply the promo code the cart was carrying when it was abandoned, to\n * core's cart store. Re-VALIDATED, never trusted: a code can expire, get\n * revoked, or stop covering the products still in the cart between abandonment\n * and return.\n */\nasync function restorePromo(resumed: ResumedCart): Promise<void> {\n const promo = await validateResumedPromo(resumed);\n if (promo) cartStore.setPromo(promo);\n}\n\nlet restoreInFlight: Promise<ResumedCart | null> | null = null;\n\n/**\n * Redeem a `?cart=` token if the URL carries one.\n *\n * Exported for sites that want to act on the restore — opening their cart\n * drawer on arrival, say, or waiting for their catalog first.\n *\n * Single-flight: `startCartCapture()` restores on its own, so a site calling\n * this directly would otherwise race it — both read the token before either\n * strips it, and the cart gets rebuilt twice. Concurrent callers share one\n * restore and one result.\n */\nexport function restoreCartFromLink(): Promise<ResumedCart | null> {\n if (!restoreInFlight) {\n restoreInFlight = runRestore().finally(() => {\n restoreInFlight = null;\n });\n }\n return restoreInFlight;\n}\n\nasync function runRestore(): Promise<ResumedCart | null> {\n const token = readCartToken();\n if (!token) return null;\n\n const resumed = await fetchResumedCart(token);\n // Strip either way: a dead token that stays in the URL re-fires this on\n // every navigation and, worse, gets shared or bookmarked.\n stripCartToken();\n if (!resumed) return null;\n\n // Keep writing to the cart the email was about, not the one this browser\n // happened to mint — otherwise the reminder history and the conversion land\n // on different rows.\n adoptCartId(resumed.cartId);\n if (restoreTarget) {\n // A site with its own basket. It owns the promo too — core has no store to\n // put one in — so `validateResumedPromo` is left for it to call.\n restoreTarget(resumed);\n } else {\n applyResumedCart(resumed);\n void restorePromo(resumed);\n }\n return resumed;\n}\n\nlet running = false;\n\n/**\n * Start mirroring the cart. Call once at app boot; returns a disposer.\n *\n * No-ops for tenants that never opted in (`GET /config/cart`), so it is safe to\n * call unconditionally from shared site scaffolding.\n */\nexport function startCartCapture(opts: CartCaptureOptions = {}): () => void {\n if (running) return () => {};\n running = true;\n\n // Claim the restore BEFORE anything awaits, so a site that calls\n // `restoreCartFromLink()` itself can't race core's cart store into place.\n restoreTarget = opts.source?.restore ?? null;\n\n // Core's cart store is just the default source; the wire shape is the same\n // either way, so everything below reads lines, not cart items.\n const source: CartSource = opts.source ?? {\n items: () => toSnapshotLines(cartStore.items()),\n promoCode: () => cartStore.appliedPromo()?.code ?? null,\n restore: applyResumedCart,\n };\n\n const debounceMs = opts.debounceMs ?? 2000;\n let enabled: boolean | null = null;\n let pending: CartSnapshotLine[] | null = null;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let lastSentEmpty = true;\n\n function flush(): void {\n if (timer) clearTimeout(timer);\n timer = undefined;\n const items = pending;\n pending = null;\n if (!items || enabled !== true) return;\n\n // An empty cart is not an abandoned one: the snapshot deletes the row, and\n // the id is retired so the next basket starts a clean one. This is also the\n // post-purchase path — checkout clears the cart — which is why converting\n // doesn't need its own wiring here.\n if (items.length === 0) {\n if (lastSentEmpty) return;\n postCartSnapshot({ items: [], promoCode: null });\n resetCartId();\n lastSentEmpty = true;\n return;\n }\n\n postCartSnapshot({\n items,\n promoCode: source.promoCode?.() ?? null,\n email: opts.email?.() ?? null,\n });\n lastSentEmpty = false;\n }\n\n function schedule(ms: number): void {\n if (timer) clearTimeout(timer);\n timer = setTimeout(flush, ms);\n }\n\n const dispose = createRoot((disposeRoot) => {\n // `defer` so merely starting capture doesn't post the cart the shopper\n // hasn't touched; the first real change schedules the first write.\n createEffect(\n on(\n source.items,\n (items) => {\n pending = items;\n if (enabled === true) schedule(debounceMs);\n },\n { defer: true },\n ),\n );\n return disposeRoot;\n });\n\n void fetchCartConfig().then((cfg) => {\n enabled = cfg.snapshot;\n if (!enabled) return;\n void restoreCartFromLink();\n if (pending) schedule(0);\n });\n\n // The shopper leaving with items in the cart is the whole point; don't let a\n // pending debounce die with the page.\n const onPageHide = () => flush();\n if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {\n window.addEventListener('pagehide', onPageHide);\n }\n\n return () => {\n if (timer) clearTimeout(timer);\n if (typeof window !== 'undefined' && typeof window.removeEventListener === 'function') {\n window.removeEventListener('pagehide', onPageHide);\n }\n dispose();\n restoreTarget = null;\n running = false;\n };\n}\n"]}
|
|
@@ -8,36 +8,39 @@ import {
|
|
|
8
8
|
readPromoCode,
|
|
9
9
|
resetCartId,
|
|
10
10
|
stripCartToken
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./VF7FTWCG.jsx";
|
|
12
12
|
import {
|
|
13
|
+
bestOfferDiscount,
|
|
13
14
|
catalogUnavailableMessage,
|
|
14
15
|
firstAddressError,
|
|
15
16
|
formatCardNumber,
|
|
16
17
|
formatCvv,
|
|
17
18
|
formatExpiry,
|
|
18
19
|
isLive,
|
|
20
|
+
offerBeatsPromo,
|
|
19
21
|
useAddressPair,
|
|
20
22
|
useCardTokenizer,
|
|
21
23
|
useCatalogAvailability,
|
|
22
24
|
validateAddress
|
|
23
|
-
} from "./
|
|
25
|
+
} from "./VG35MW6B.jsx";
|
|
24
26
|
import {
|
|
25
27
|
auth_default,
|
|
26
28
|
cart_default
|
|
27
|
-
} from "./
|
|
29
|
+
} from "./RRKAKQ77.jsx";
|
|
28
30
|
import {
|
|
29
31
|
ApiError,
|
|
30
32
|
newIdempotencyKey,
|
|
33
|
+
offersApi,
|
|
31
34
|
promoCodesApi,
|
|
32
35
|
subscriptionsApi,
|
|
33
36
|
usersApi
|
|
34
|
-
} from "./
|
|
37
|
+
} from "./EZG74SQL.jsx";
|
|
35
38
|
import {
|
|
36
39
|
getConfig
|
|
37
40
|
} from "./LDZIUFDM.jsx";
|
|
38
41
|
|
|
39
42
|
// src/flows/subscriptionIntake.ts
|
|
40
|
-
import { createEffect, createSignal, onMount } from "solid-js";
|
|
43
|
+
import { createEffect, createSignal, on, onMount } from "solid-js";
|
|
41
44
|
var DRAFT_TTL_MS = 7 * 24 * 3600 * 1e3;
|
|
42
45
|
var MAX_RESTORABLE_STEP = 1;
|
|
43
46
|
function draftKey() {
|
|
@@ -69,6 +72,7 @@ function clearDraft() {
|
|
|
69
72
|
} catch {
|
|
70
73
|
}
|
|
71
74
|
}
|
|
75
|
+
var OFFER_BEATS_PROMO_NOTICE = "Your offer is the better discount, so it is the one applied. A promo code does not combine with an offer.";
|
|
72
76
|
function useSubscriptionIntakeFlow(options) {
|
|
73
77
|
const accept = useCardTokenizer();
|
|
74
78
|
let restored = {};
|
|
@@ -166,20 +170,61 @@ function useSubscriptionIntakeFlow(options) {
|
|
|
166
170
|
const savings = options.pricing.savingsPriceCents;
|
|
167
171
|
return options.isSavingsMember?.() && savings != null ? savings : list;
|
|
168
172
|
};
|
|
173
|
+
const [offers, setOffers] = createSignal([]);
|
|
174
|
+
const offerSubject = () => {
|
|
175
|
+
if (auth_default.isAuthenticated()) return "session";
|
|
176
|
+
const address = email().trim().toLowerCase();
|
|
177
|
+
return step() > 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(address) ? address : "";
|
|
178
|
+
};
|
|
179
|
+
createEffect(
|
|
180
|
+
on(offerSubject, (subject) => {
|
|
181
|
+
if (!subject) {
|
|
182
|
+
setOffers([]);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
void (async () => {
|
|
186
|
+
let found = [];
|
|
187
|
+
try {
|
|
188
|
+
const res = subject === "session" ? await offersApi.mine() : await offersApi.forEmail(subject);
|
|
189
|
+
if (Array.isArray(res?.offers)) found = res.offers;
|
|
190
|
+
} catch {
|
|
191
|
+
}
|
|
192
|
+
setOffers(offerSubject() === subject ? found : []);
|
|
193
|
+
})();
|
|
194
|
+
})
|
|
195
|
+
);
|
|
169
196
|
const pricing = () => {
|
|
170
197
|
const baseCents = savingsBaseCents();
|
|
171
198
|
const promo = promoApplied();
|
|
172
|
-
|
|
199
|
+
const promoCents = promo?.valid && promo.discountCents ? Math.min(baseCents, promo.discountCents) : 0;
|
|
200
|
+
const best = bestOfferDiscount(offers(), { productIds: [options.pricing.productId], baseCents });
|
|
201
|
+
if (best && offerBeatsPromo(best.discountCents, promoCents)) {
|
|
202
|
+
const o = best.offer;
|
|
203
|
+
return {
|
|
204
|
+
baseCents,
|
|
205
|
+
discountCents: best.discountCents,
|
|
206
|
+
finalCents: baseCents - best.discountCents,
|
|
207
|
+
offer: {
|
|
208
|
+
label: o.label,
|
|
209
|
+
amountText: o.amountText,
|
|
210
|
+
deadlineText: o.deadlineText,
|
|
211
|
+
recurringIndefinite: o.recurringIndefinite,
|
|
212
|
+
recurringCharges: o.recurringCharges ?? 0,
|
|
213
|
+
discountCents: best.discountCents
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (promoCents === 0) {
|
|
173
218
|
return { baseCents, discountCents: 0, finalCents: baseCents };
|
|
174
219
|
}
|
|
175
|
-
const discountCents = Math.min(baseCents, promo.discountCents);
|
|
176
220
|
return {
|
|
177
221
|
baseCents,
|
|
178
|
-
discountCents,
|
|
179
|
-
finalCents: promo.finalCents ?? Math.max(0, baseCents -
|
|
222
|
+
discountCents: promoCents,
|
|
223
|
+
finalCents: promo.finalCents ?? Math.max(0, baseCents - promoCents),
|
|
180
224
|
promoCode: promo.promoCode?.code
|
|
181
225
|
};
|
|
182
226
|
};
|
|
227
|
+
const promoNotice = () => promoApplied()?.valid && pricing().offer ? OFFER_BEATS_PROMO_NOTICE : null;
|
|
183
228
|
async function applyPromo() {
|
|
184
229
|
const code = promoCode().trim();
|
|
185
230
|
if (!code) {
|
|
@@ -435,6 +480,7 @@ function useSubscriptionIntakeFlow(options) {
|
|
|
435
480
|
promoApplied,
|
|
436
481
|
applyPromo,
|
|
437
482
|
clearPromo,
|
|
483
|
+
promoNotice,
|
|
438
484
|
pricing,
|
|
439
485
|
surveyResult: options.surveyResult,
|
|
440
486
|
medication: options.pricing,
|
|
@@ -443,7 +489,7 @@ function useSubscriptionIntakeFlow(options) {
|
|
|
443
489
|
}
|
|
444
490
|
|
|
445
491
|
// src/flows/cartCapture.ts
|
|
446
|
-
import { createEffect as createEffect2, createRoot, on } from "solid-js";
|
|
492
|
+
import { createEffect as createEffect2, createRoot, on as on2 } from "solid-js";
|
|
447
493
|
function toSnapshotLines(items) {
|
|
448
494
|
return items.map((i) => ({
|
|
449
495
|
productId: i.productId,
|
|
@@ -562,7 +608,7 @@ function startCartCapture(opts = {}) {
|
|
|
562
608
|
}
|
|
563
609
|
const dispose = createRoot((disposeRoot) => {
|
|
564
610
|
createEffect2(
|
|
565
|
-
|
|
611
|
+
on2(
|
|
566
612
|
source.items,
|
|
567
613
|
(items) => {
|
|
568
614
|
pending = items;
|
|
@@ -595,9 +641,10 @@ function startCartCapture(opts = {}) {
|
|
|
595
641
|
}
|
|
596
642
|
|
|
597
643
|
export {
|
|
644
|
+
OFFER_BEATS_PROMO_NOTICE,
|
|
598
645
|
useSubscriptionIntakeFlow,
|
|
599
646
|
validateResumedPromo,
|
|
600
647
|
restoreCartFromLink,
|
|
601
648
|
startCartCapture
|
|
602
649
|
};
|
|
603
|
-
//# sourceMappingURL=
|
|
650
|
+
//# sourceMappingURL=CLNLTAG7.jsx.map
|
|
@@ -758,6 +758,21 @@ var promoCodesApi = {
|
|
|
758
758
|
return apiFetch(`/promo-codes/validate${qs(params)}`);
|
|
759
759
|
}
|
|
760
760
|
};
|
|
761
|
+
var offersApi = {
|
|
762
|
+
/** The signed-in member's unclaimed offers (member JWT). */
|
|
763
|
+
mine() {
|
|
764
|
+
return apiFetch("/offers/mine");
|
|
765
|
+
},
|
|
766
|
+
/**
|
|
767
|
+
* The offers waiting for someone with no account yet, by the address they
|
|
768
|
+
* are registering with — so a guest is shown the price they will be charged.
|
|
769
|
+
* Empty for an address that already has an account. POST: the address never
|
|
770
|
+
* goes in a URL.
|
|
771
|
+
*/
|
|
772
|
+
forEmail(email) {
|
|
773
|
+
return post("/offers/for-email", { email });
|
|
774
|
+
}
|
|
775
|
+
};
|
|
761
776
|
var ordersApi = {
|
|
762
777
|
create(payload) {
|
|
763
778
|
return post("/orders", payload);
|
|
@@ -1102,6 +1117,38 @@ var adminApi = {
|
|
|
1102
1117
|
deletePromoCode(id) {
|
|
1103
1118
|
return del(`/admin/promo-codes/${id}`);
|
|
1104
1119
|
},
|
|
1120
|
+
// ── Offers ─────────────────────────────────────────────────────
|
|
1121
|
+
// A discount one person holds before they subscribe. The offer is the
|
|
1122
|
+
// definition; a grant is one person holding it, with their own deadline.
|
|
1123
|
+
getOffers() {
|
|
1124
|
+
return apiFetch("/admin/offers");
|
|
1125
|
+
},
|
|
1126
|
+
createOffer(payload) {
|
|
1127
|
+
return post("/admin/offers", payload);
|
|
1128
|
+
},
|
|
1129
|
+
/** Whole object. Grants already issued keep the terms they were issued with. */
|
|
1130
|
+
updateOffer(id, payload) {
|
|
1131
|
+
return put(`/admin/offers/${id}`, payload);
|
|
1132
|
+
},
|
|
1133
|
+
/** Archive. 409 (the message names the sequence) while a sequence hands it out. */
|
|
1134
|
+
archiveOffer(id) {
|
|
1135
|
+
return del(`/admin/offers/${id}`);
|
|
1136
|
+
},
|
|
1137
|
+
getOfferGrants(offerId, params) {
|
|
1138
|
+
return apiFetch(`/admin/offers/${offerId}/grants${qs(params)}`);
|
|
1139
|
+
},
|
|
1140
|
+
/**
|
|
1141
|
+
* Give the offer to one person. Idempotent: a person holds an offer once, so
|
|
1142
|
+
* `created: false` returns the grant they already have, original deadline
|
|
1143
|
+
* included.
|
|
1144
|
+
*/
|
|
1145
|
+
issueOfferGrant(offerId, payload) {
|
|
1146
|
+
return post(`/admin/offers/${offerId}/grants`, payload);
|
|
1147
|
+
},
|
|
1148
|
+
/** Take back an unclaimed grant. 409 once it has been claimed. */
|
|
1149
|
+
revokeOfferGrant(grantId) {
|
|
1150
|
+
return apiFetch(`/admin/offers/grants/${grantId}`, { method: "DELETE" });
|
|
1151
|
+
},
|
|
1105
1152
|
// ── Categories ─────────────────────────────────────────────────
|
|
1106
1153
|
getCategories() {
|
|
1107
1154
|
return apiFetch("/admin/categories");
|
|
@@ -1419,6 +1466,7 @@ export {
|
|
|
1419
1466
|
supportApi,
|
|
1420
1467
|
productsApi,
|
|
1421
1468
|
promoCodesApi,
|
|
1469
|
+
offersApi,
|
|
1422
1470
|
ordersApi,
|
|
1423
1471
|
usersApi,
|
|
1424
1472
|
membersApi,
|
|
@@ -1431,4 +1479,4 @@ export {
|
|
|
1431
1479
|
clearAffiliateTokens,
|
|
1432
1480
|
affiliatePortalApi
|
|
1433
1481
|
};
|
|
1434
|
-
//# sourceMappingURL=
|
|
1482
|
+
//# sourceMappingURL=EZG74SQL.jsx.map
|
|
@@ -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 './7MCMXXYQ.js';
|
|
2
2
|
import { onConfigured, getConfig } from './5XGPFYIJ.js';
|
|
3
3
|
import { createRoot, createSignal, createMemo, batch } from 'solid-js';
|
|
4
4
|
|
|
@@ -382,5 +382,5 @@ var medicationStore = createRoot(createMedicationStore);
|
|
|
382
382
|
var medication_default = medicationStore;
|
|
383
383
|
|
|
384
384
|
export { affiliateAuth_default, auth_default, cart_default, medication_default };
|
|
385
|
-
//# sourceMappingURL=
|
|
386
|
-
//# sourceMappingURL=
|
|
385
|
+
//# sourceMappingURL=FA4D2S5A.js.map
|
|
386
|
+
//# sourceMappingURL=FA4D2S5A.js.map
|
|
@@ -1 +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,OAAA,CAAQ,cAAA,EAAgB,CAAA;AACjD,IAAA,IA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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":"DHVOZQQ2.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
|
+
{"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,C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;AACF;AAEA,IAAM,kBAAA,GAAqBD,WAAW,wBAAwB,CAAA;AAC9D,IAAO,qBAAA,GAAQ;AC5Jf,SAAS,qBAAA,GAAwB;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":"FA4D2S5A.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"]}
|