@apextelemed/partner-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +64 -0
- package/README.md +363 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.jsx +127 -0
- package/dist/cart-CBH8Em8f.d.ts +189 -0
- package/dist/cart-D4mVX_zx.d.ts +66 -0
- package/dist/chunk/2OXI5TKO.jsx +249 -0
- package/dist/chunk/3A3MF7R2.jsx +1 -0
- package/dist/chunk/3VEOP7TZ.jsx +16679 -0
- package/dist/chunk/5XGPFYIJ.js +26 -0
- package/dist/chunk/5XGPFYIJ.js.map +1 -0
- package/dist/chunk/67KHO66G.js +26 -0
- package/dist/chunk/67KHO66G.js.map +1 -0
- package/dist/chunk/6TFBQECC.jsx +135 -0
- package/dist/chunk/AN3WPMEP.js +3 -0
- package/dist/chunk/AN3WPMEP.js.map +1 -0
- package/dist/chunk/DHII7L5Y.js +686 -0
- package/dist/chunk/DHII7L5Y.js.map +1 -0
- package/dist/chunk/DS4E7FAI.js +132 -0
- package/dist/chunk/DS4E7FAI.js.map +1 -0
- package/dist/chunk/DY5BJ6UG.js +1195 -0
- package/dist/chunk/DY5BJ6UG.js.map +1 -0
- package/dist/chunk/E7722UPF.js +378 -0
- package/dist/chunk/E7722UPF.js.map +1 -0
- package/dist/chunk/HLXKWRRW.js +16774 -0
- package/dist/chunk/HLXKWRRW.js.map +1 -0
- package/dist/chunk/I46Y2J5W.jsx +144 -0
- package/dist/chunk/J63XPQP4.jsx +21 -0
- package/dist/chunk/J6KNY37T.js +122 -0
- package/dist/chunk/J6KNY37T.js.map +1 -0
- package/dist/chunk/KNTZTYXE.jsx +3315 -0
- package/dist/chunk/KZZSQ7LP.jsx +409 -0
- package/dist/chunk/L46OKCKG.jsx +733 -0
- package/dist/chunk/LDZIUFDM.jsx +31 -0
- package/dist/chunk/LZWA44KD.js +3 -0
- package/dist/chunk/LZWA44KD.js.map +1 -0
- package/dist/chunk/NVRAOAVV.js +3 -0
- package/dist/chunk/NVRAOAVV.js.map +1 -0
- package/dist/chunk/O3QK7YZR.jsx +1 -0
- package/dist/chunk/UZCST66N.jsx +21 -0
- package/dist/chunk/V42CGY2S.jsx +1229 -0
- package/dist/chunk/YJEHCCLY.js +467 -0
- package/dist/chunk/YJEHCCLY.js.map +1 -0
- package/dist/chunk/ZMOG2IIC.js +3194 -0
- package/dist/chunk/ZMOG2IIC.js.map +1 -0
- package/dist/client-BzSg2DEK.d.ts +1539 -0
- package/dist/config/index.d.ts +55 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.jsx +11 -0
- package/dist/flows/index.d.ts +1322 -0
- package/dist/flows/index.js +9 -0
- package/dist/flows/index.js.map +1 -0
- package/dist/flows/index.jsx +124 -0
- package/dist/index/index.d.ts +71 -0
- package/dist/index/index.js +15 -0
- package/dist/index/index.js.map +1 -0
- package/dist/index/index.jsx +311 -0
- package/dist/pages/index.d.ts +617 -0
- package/dist/pages/index.js +10 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/index.jsx +50 -0
- package/dist/primitives/default/index.d.ts +6 -0
- package/dist/primitives/default/index.js +3 -0
- package/dist/primitives/default/index.js.map +1 -0
- package/dist/primitives/default/index.jsx +7 -0
- package/dist/primitives/index.d.ts +122 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/index.jsx +9 -0
- package/dist/stores/index.d.ts +48 -0
- package/dist/stores/index.js +6 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/stores/index.jsx +16 -0
- package/dist/surveyV2-BgQHK0GE.d.ts +48 -0
- package/dist/testing/adapter.d.ts +104 -0
- package/dist/testing/adapter.d.ts.map +1 -0
- package/dist/testing/adapter.js +14 -0
- package/dist/testing/adapter.js.map +1 -0
- package/dist/testing/env.d.ts +29 -0
- package/dist/testing/env.d.ts.map +1 -0
- package/dist/testing/env.js +42 -0
- package/dist/testing/env.js.map +1 -0
- package/dist/testing/fixtures.d.ts +70 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +74 -0
- package/dist/testing/fixtures.js.map +1 -0
- package/dist/testing/index.d.ts +15 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +14 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mocks.d.ts +53 -0
- package/dist/testing/mocks.d.ts.map +1 -0
- package/dist/testing/mocks.js +90 -0
- package/dist/testing/mocks.js.map +1 -0
- package/dist/testing/seam-suite.d.ts +39 -0
- package/dist/testing/seam-suite.d.ts.map +1 -0
- package/dist/testing/seam-suite.js +196 -0
- package/dist/testing/seam-suite.js.map +1 -0
- package/dist/testing/storage.d.ts +40 -0
- package/dist/testing/storage.d.ts.map +1 -0
- package/dist/testing/storage.js +71 -0
- package/dist/testing/storage.js.map +1 -0
- package/dist/theme/admin.css +579 -0
- package/dist/theme/affiliate.css +191 -0
- package/dist/theme/flow.css +497 -0
- package/dist/theme/index.d.ts +84 -0
- package/dist/theme/index.js +94 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/index.jsx +97 -0
- package/dist/theme/member-portal.css +1762 -0
- package/package.json +199 -0
|
@@ -0,0 +1,1322 @@
|
|
|
1
|
+
import { Accessor, Resource } from 'solid-js';
|
|
2
|
+
import { A as AddressVerifyResult, O as CheckoutAddress, aF as User, _ as DeliveryInfo, am as RenewalStatus, af as PendingRenewalSurvey, N as CatalogProduct, u as AffiliateConversion, y as AffiliateDownlineMember, v as AffiliateDashboardLinks, x as AffiliateDashboardStats, ai as PromoValidationResponse } from '../client-BzSg2DEK.js';
|
|
3
|
+
import { C as CartItem } from '../cart-D4mVX_zx.js';
|
|
4
|
+
export { U as UseSurveyV2FlowOptions, u as useSurveyV2Flow } from '../surveyV2-BgQHK0GE.js';
|
|
5
|
+
import { EmbedEvent } from '@apextelemed/survey-solid';
|
|
6
|
+
export { SurveyV2Flow, SurveyV2Outcome } from '@apextelemed/survey-solid';
|
|
7
|
+
import { d as ResumedDraft, R as ResumedCart } from '../cart-CBH8Em8f.js';
|
|
8
|
+
import '@apextelemed/survey-core';
|
|
9
|
+
|
|
10
|
+
interface SurveyOption {
|
|
11
|
+
id: string;
|
|
12
|
+
text: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
interface VisibilityCondition {
|
|
16
|
+
conditionId: string;
|
|
17
|
+
questionId: string;
|
|
18
|
+
operator: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}
|
|
21
|
+
interface SurveyQuestion {
|
|
22
|
+
id: string;
|
|
23
|
+
type: string;
|
|
24
|
+
text: string;
|
|
25
|
+
required: boolean;
|
|
26
|
+
options?: SurveyOption[];
|
|
27
|
+
helpText?: string;
|
|
28
|
+
visibilityConditions?: VisibilityCondition[];
|
|
29
|
+
}
|
|
30
|
+
interface FlatStep {
|
|
31
|
+
sectionIndex: number;
|
|
32
|
+
stepIndex: number;
|
|
33
|
+
sectionTitle: string;
|
|
34
|
+
stepTitle?: string;
|
|
35
|
+
stepDescription?: string;
|
|
36
|
+
questions: SurveyQuestion[];
|
|
37
|
+
}
|
|
38
|
+
interface DrugResult {
|
|
39
|
+
drugId: string;
|
|
40
|
+
drugName: string;
|
|
41
|
+
qualified: boolean;
|
|
42
|
+
disqualificationReason?: string;
|
|
43
|
+
isRecommended?: boolean;
|
|
44
|
+
recommendationReasons?: string[];
|
|
45
|
+
}
|
|
46
|
+
type AnswerValue = string | string[] | number | boolean | Record<string, unknown>;
|
|
47
|
+
type SurveyOutcome = {
|
|
48
|
+
kind: 'loading';
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'needs_medication_selection';
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'load_failed';
|
|
53
|
+
error: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'in_progress';
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'disqualified';
|
|
58
|
+
reason: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'drug_selection';
|
|
61
|
+
drugs: DrugResult[];
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'completed';
|
|
64
|
+
};
|
|
65
|
+
declare function isQuestionVisible(question: SurveyQuestion, answers: Record<string, AnswerValue>): boolean;
|
|
66
|
+
interface UseSurveyFlowOptions {
|
|
67
|
+
/** ms to wait on the completion screen before firing `onComplete`. Default 3000. */
|
|
68
|
+
completionRedirectDelayMs?: number;
|
|
69
|
+
}
|
|
70
|
+
interface SurveyFlow {
|
|
71
|
+
outcome: Accessor<SurveyOutcome>;
|
|
72
|
+
surveyTitle: Accessor<string>;
|
|
73
|
+
totalSteps: Accessor<number>;
|
|
74
|
+
currentStep: Accessor<number>;
|
|
75
|
+
step: Accessor<FlatStep | null>;
|
|
76
|
+
visibleQuestions: Accessor<SurveyQuestion[]>;
|
|
77
|
+
answers: Accessor<Record<string, AnswerValue>>;
|
|
78
|
+
setAnswer: (questionId: string, value: AnswerValue) => void;
|
|
79
|
+
validationError: Accessor<string | null>;
|
|
80
|
+
submitting: Accessor<boolean>;
|
|
81
|
+
next: () => Promise<void>;
|
|
82
|
+
back: () => void;
|
|
83
|
+
isLastStep: Accessor<boolean>;
|
|
84
|
+
selectedDrugId: Accessor<string>;
|
|
85
|
+
setSelectedDrugId: (id: string) => void;
|
|
86
|
+
confirmDrugSelection: () => Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
declare function useSurveyFlow(options?: UseSurveyFlowOptions): SurveyFlow;
|
|
89
|
+
|
|
90
|
+
declare const US_STATES: readonly string[];
|
|
91
|
+
/** Options for a state `<Select>`, labelled by full name. */
|
|
92
|
+
declare const US_STATE_OPTIONS: Array<{
|
|
93
|
+
value: string;
|
|
94
|
+
label: string;
|
|
95
|
+
}>;
|
|
96
|
+
/** US_STATES minus the tenant's `unavailableStates` and any `extraExcluded`. */
|
|
97
|
+
declare function availableStates(extraExcluded?: readonly string[]): string[];
|
|
98
|
+
/** `availableStates()` as `<Select>` options — use for state dropdowns. */
|
|
99
|
+
declare function availableStateOptions(extraExcluded?: readonly string[]): Array<{
|
|
100
|
+
value: string;
|
|
101
|
+
label: string;
|
|
102
|
+
}>;
|
|
103
|
+
/** The tenant's configured availability note (e.g. "…cannot provide
|
|
104
|
+
* medications to customers in Delaware."), or null when unrestricted. */
|
|
105
|
+
declare function stateAvailabilityNote(): string | null;
|
|
106
|
+
/**
|
|
107
|
+
* Coerce a state value into a canonical 2-letter abbreviation for the `<Select>`.
|
|
108
|
+
* Accepts an abbreviation in any case (`tx` → `TX`) or a full name
|
|
109
|
+
* (`Texas` → `TX`). Returns `''` for anything unrecognized so the field falls
|
|
110
|
+
* back to its placeholder and validation prompts the user to pick a state.
|
|
111
|
+
*/
|
|
112
|
+
declare function normalizeState(input: string | null | undefined): string;
|
|
113
|
+
interface AddressValue {
|
|
114
|
+
street: string;
|
|
115
|
+
street2?: string;
|
|
116
|
+
city: string;
|
|
117
|
+
state: string;
|
|
118
|
+
zip: string;
|
|
119
|
+
}
|
|
120
|
+
interface AddressErrors {
|
|
121
|
+
street?: string;
|
|
122
|
+
city?: string;
|
|
123
|
+
state?: string;
|
|
124
|
+
zip?: string;
|
|
125
|
+
}
|
|
126
|
+
interface ValidateAddressOptions {
|
|
127
|
+
/** Also reject states in the tenant's `unavailableStates`. Turn on for
|
|
128
|
+
* SHIPPING addresses only — the dropdown already omits them, but a saved
|
|
129
|
+
* profile address can arrive prefilled with one. Billing stays unrestricted. */
|
|
130
|
+
enforceAvailability?: boolean;
|
|
131
|
+
}
|
|
132
|
+
/** `label` (e.g. "Billing") prefixes the messages; omit for the shipping form. */
|
|
133
|
+
declare function validateAddress(a: AddressValue, label?: string, opts?: ValidateAddressOptions): AddressErrors;
|
|
134
|
+
declare function hasErrors(e: AddressErrors): boolean;
|
|
135
|
+
interface UseAddressPairOptions {
|
|
136
|
+
/** Prefill the shipping address (e.g. from the member profile). */
|
|
137
|
+
initialShipping?: Partial<AddressValue>;
|
|
138
|
+
/** Prefill billing when it starts as an override; usually omitted. */
|
|
139
|
+
initialBilling?: Partial<AddressValue>;
|
|
140
|
+
/** Start with "billing same as shipping" checked. Default FALSE — see the
|
|
141
|
+
* useAddressPair docs for why the billing address is surfaced rather than
|
|
142
|
+
* assumed (AVS declines are otherwise invisible to the customer). */
|
|
143
|
+
billingSameAsShippingDefault?: boolean;
|
|
144
|
+
/** Override the deliverability verifier (defaults to `addressesApi.verify`).
|
|
145
|
+
* Injectable for testing / alternate providers. */
|
|
146
|
+
verify?: (a: CheckoutAddress) => Promise<AddressVerifyResult>;
|
|
147
|
+
}
|
|
148
|
+
interface AddressPair {
|
|
149
|
+
shipping: Accessor<AddressValue>;
|
|
150
|
+
setShippingField: (field: keyof AddressValue, value: string) => void;
|
|
151
|
+
setShipping: (patch: Partial<AddressValue>) => void;
|
|
152
|
+
billingSameAsShipping: Accessor<boolean>;
|
|
153
|
+
setBillingSameAsShipping: (v: boolean) => void;
|
|
154
|
+
billing: Accessor<AddressValue>;
|
|
155
|
+
setBillingField: (field: keyof AddressValue, value: string) => void;
|
|
156
|
+
/** True only when billing is a distinct override the user actually entered —
|
|
157
|
+
* i.e. "same as" is unchecked AND a billing field has been edited. Until then
|
|
158
|
+
* `billing`/`effectiveBilling` track live shipping. */
|
|
159
|
+
billingIsOverride: Accessor<boolean>;
|
|
160
|
+
/** Address to bill/charge to: live shipping unless billing is an override. */
|
|
161
|
+
effectiveBilling: Accessor<AddressValue>;
|
|
162
|
+
shippingErrors: Accessor<AddressErrors>;
|
|
163
|
+
billingErrors: Accessor<AddressErrors>;
|
|
164
|
+
/** Validate shipping (always) + billing (only when it's an override). Publishes
|
|
165
|
+
* errors to shippingErrors()/billingErrors() for inline display. Returns true if ok. */
|
|
166
|
+
validate: () => boolean;
|
|
167
|
+
/** Last deliverability result for the shipping address; null until verified or
|
|
168
|
+
* after any shipping edit. */
|
|
169
|
+
deliverability: Accessor<AddressVerifyResult | null>;
|
|
170
|
+
verifying: Accessor<boolean>;
|
|
171
|
+
/** Verify the shipping address's deliverability. No-ops (returns null) when the
|
|
172
|
+
* address is syntactically incomplete. Fails open (`unchecked`) on any error. */
|
|
173
|
+
verifyShipping: () => Promise<AddressVerifyResult | null>;
|
|
174
|
+
/** Adopt the verifier's normalized address into the shipping fields (used for a
|
|
175
|
+
* `corrected` result's "use suggested address" action). */
|
|
176
|
+
applyNormalized: () => void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Shared shipping + billing address state for checkout-bearing flows. Until the
|
|
180
|
+
* user actually edits a billing field, `billing` mirrors the LIVE shipping
|
|
181
|
+
* address — so the billing form always reads as populated, stays in sync if
|
|
182
|
+
* shipping is later corrected, and the address charged always matches what's
|
|
183
|
+
* displayed. The first billing edit "forks" billing into an independent
|
|
184
|
+
* override; from then on it holds the user's entered values.
|
|
185
|
+
*
|
|
186
|
+
* "Billing same as shipping" defaults OFF, and consumers render the billing
|
|
187
|
+
* fields unconditionally. The card's billing address is what the gateway runs
|
|
188
|
+
* AVS against, so a mismatch there is charged back to the customer as a bare
|
|
189
|
+
* "This transaction has been declined." Defaulting the box on and hiding the
|
|
190
|
+
* fields behind it meant a customer whose card bills to a different address
|
|
191
|
+
* had no obvious way to notice, let alone fix it. Showing the fields (mirrored
|
|
192
|
+
* from shipping, so the common case still needs no typing) makes the address
|
|
193
|
+
* being billed visible before the charge rather than after the decline.
|
|
194
|
+
*/
|
|
195
|
+
declare function useAddressPair(options?: UseAddressPairOptions): AddressPair;
|
|
196
|
+
|
|
197
|
+
interface RequestStatus {
|
|
198
|
+
status: 'pending' | 'approved' | 'denied' | 'new';
|
|
199
|
+
drugName?: string;
|
|
200
|
+
drugId?: string;
|
|
201
|
+
dosage?: string;
|
|
202
|
+
price?: number;
|
|
203
|
+
/** Locked catalog price for this prescription (cents). */
|
|
204
|
+
priceCents?: number;
|
|
205
|
+
/** Locked discount applied at request creation (cents). */
|
|
206
|
+
discountCents?: number;
|
|
207
|
+
/** Locked total to charge (cents). */
|
|
208
|
+
finalCents?: number;
|
|
209
|
+
/** The request has already been paid for. Guards against re-charging a request
|
|
210
|
+
* that was paid up front (pay-before-review) if the checkout is revisited. */
|
|
211
|
+
paymentConfirmed?: boolean;
|
|
212
|
+
reason?: string;
|
|
213
|
+
requestId?: string;
|
|
214
|
+
[key: string]: unknown;
|
|
215
|
+
}
|
|
216
|
+
type CheckoutOutcome = {
|
|
217
|
+
kind: 'loading';
|
|
218
|
+
} | {
|
|
219
|
+
kind: 'load_failed';
|
|
220
|
+
error: string;
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'no_prescription';
|
|
223
|
+
} | {
|
|
224
|
+
kind: 'pending_review';
|
|
225
|
+
prescription: RequestStatus;
|
|
226
|
+
} | {
|
|
227
|
+
kind: 'denied';
|
|
228
|
+
prescription: RequestStatus;
|
|
229
|
+
} | {
|
|
230
|
+
kind: 'awaiting_purchase';
|
|
231
|
+
prescription: RequestStatus;
|
|
232
|
+
} | {
|
|
233
|
+
kind: 'completed';
|
|
234
|
+
};
|
|
235
|
+
interface PricingBreakdown {
|
|
236
|
+
baseMedicationCents: number;
|
|
237
|
+
promoDiscountCents: number;
|
|
238
|
+
finalMedicationCents: number;
|
|
239
|
+
promoCode?: string;
|
|
240
|
+
}
|
|
241
|
+
declare function formatCardNumber(raw: string): string;
|
|
242
|
+
declare function formatExpiry(raw: string): string;
|
|
243
|
+
declare function formatCvv(raw: string): string;
|
|
244
|
+
interface UseCheckoutFlowOptions {
|
|
245
|
+
/** The prescription request ID to check out. Typically read from a URL query param by the site. If absent, the hook falls back to `user.apex_request_id` for legacy single-request flows. */
|
|
246
|
+
requestId?: string;
|
|
247
|
+
/** Specific drug (Apex drugId) within a multi-drug request to purchase. When set, the backend returns THAT line item's status + locked price, so an approved item in a partially-approved request is purchasable independently. */
|
|
248
|
+
drugId?: string;
|
|
249
|
+
/**
|
|
250
|
+
* Pay-before-review: treat a `pending` (not-yet-approved) request as
|
|
251
|
+
* purchasable, so the card form is shown immediately after the survey instead
|
|
252
|
+
* of only after a prescriber approves. Off by default — the standard flow
|
|
253
|
+
* collects payment only on an `approved` request. When on, the backend's
|
|
254
|
+
* approved+paid fulfilment gate still holds the order until a prescriber
|
|
255
|
+
* approves; this only moves WHEN the card is collected, not what ships.
|
|
256
|
+
*/
|
|
257
|
+
allowPendingPurchase?: boolean;
|
|
258
|
+
}
|
|
259
|
+
interface CheckoutFlow {
|
|
260
|
+
outcome: Accessor<CheckoutOutcome>;
|
|
261
|
+
profile: Accessor<User | null>;
|
|
262
|
+
/** Shipping + billing address state (pre-filled from the profile). Render with
|
|
263
|
+
* <AddressFields address={flow.address} />. */
|
|
264
|
+
address: AddressPair;
|
|
265
|
+
pricing: Accessor<PricingBreakdown>;
|
|
266
|
+
hasPaymentMethod: Accessor<boolean>;
|
|
267
|
+
/** True once the card tokenizer is ready. Gate submission on this. */
|
|
268
|
+
tokenizerReady: Accessor<boolean>;
|
|
269
|
+
/** @deprecated alias of tokenizerReady (pre-rename name). */
|
|
270
|
+
acceptJsLoaded: Accessor<boolean>;
|
|
271
|
+
/** Non-null when payment setup failed to initialize (config/SDK load) —
|
|
272
|
+
* render as a banner; the pay button will never enable in this state. */
|
|
273
|
+
/** Tokenizer init failure, or null. */
|
|
274
|
+
tokenizerError: Accessor<string | null>;
|
|
275
|
+
/** @deprecated alias of tokenizerError (pre-rename name). */
|
|
276
|
+
acceptJsError: Accessor<string | null>;
|
|
277
|
+
cardNumber: Accessor<string>;
|
|
278
|
+
setCardNumber: (v: string) => void;
|
|
279
|
+
expiry: Accessor<string>;
|
|
280
|
+
setExpiry: (v: string) => void;
|
|
281
|
+
cvv: Accessor<string>;
|
|
282
|
+
setCvv: (v: string) => void;
|
|
283
|
+
paymentError: Accessor<string | null>;
|
|
284
|
+
processing: Accessor<boolean>;
|
|
285
|
+
canSubmit: Accessor<boolean>;
|
|
286
|
+
submit: () => Promise<void>;
|
|
287
|
+
}
|
|
288
|
+
declare function useCheckoutFlow(options?: UseCheckoutFlowOptions): CheckoutFlow;
|
|
289
|
+
|
|
290
|
+
type CartCheckoutOutcome =
|
|
291
|
+
/** Initial profile load in flight. */
|
|
292
|
+
{
|
|
293
|
+
kind: 'loading';
|
|
294
|
+
}
|
|
295
|
+
/** No authenticated session. Sites route to signup/login (for a model-3
|
|
296
|
+
* tenant, typically RegisterPage) and back here afterwards. */
|
|
297
|
+
| {
|
|
298
|
+
kind: 'needs_auth';
|
|
299
|
+
}
|
|
300
|
+
/** The cart holds no one-time-purchasable items (empty, or subscription
|
|
301
|
+
* items only). Sites route to the catalog. */
|
|
302
|
+
| {
|
|
303
|
+
kind: 'needs_cart';
|
|
304
|
+
}
|
|
305
|
+
/** Ready: order summary + address + card form are live. */
|
|
306
|
+
| {
|
|
307
|
+
kind: 'in_progress';
|
|
308
|
+
}
|
|
309
|
+
/** A submit failed ambiguously; the flow is checking the order history
|
|
310
|
+
* before letting the user near the Pay button again. */
|
|
311
|
+
| {
|
|
312
|
+
kind: 'reconciling';
|
|
313
|
+
}
|
|
314
|
+
/** Charge succeeded (or was confirmed via reconcile). */
|
|
315
|
+
| {
|
|
316
|
+
kind: 'completed';
|
|
317
|
+
orderId?: string;
|
|
318
|
+
amountCents?: number;
|
|
319
|
+
};
|
|
320
|
+
interface CartCheckoutPricing {
|
|
321
|
+
/** Quantity-honoring subtotal of the purchasable items, in cents. */
|
|
322
|
+
subtotalCents: number;
|
|
323
|
+
/** Client-side ESTIMATE from the applied promo — the server re-validates the
|
|
324
|
+
* code and stacks active sales itself, so the charged amount can differ.
|
|
325
|
+
* `completed.amountCents` carries the authoritative figure. */
|
|
326
|
+
promoDiscountCents: number;
|
|
327
|
+
estimatedTotalCents: number;
|
|
328
|
+
promoCode?: string;
|
|
329
|
+
}
|
|
330
|
+
interface CartCheckoutFlow {
|
|
331
|
+
outcome: Accessor<CartCheckoutOutcome>;
|
|
332
|
+
profile: Accessor<User | null>;
|
|
333
|
+
/** Shipping + billing address state (pre-filled from the profile). Render
|
|
334
|
+
* with <AddressFields address={flow.address} />. */
|
|
335
|
+
address: AddressPair;
|
|
336
|
+
/** The one-time-purchasable subset of the cart — what will actually be
|
|
337
|
+
* charged. Subscription-flagged items are excluded (the backend 400s a
|
|
338
|
+
* checkout containing one). */
|
|
339
|
+
items: Accessor<CartItem[]>;
|
|
340
|
+
/** Subscription-flagged cart items excluded from this purchase, so pages can
|
|
341
|
+
* tell the customer those aren't part of the order. */
|
|
342
|
+
skippedSubscriptionItems: Accessor<CartItem[]>;
|
|
343
|
+
pricing: Accessor<CartCheckoutPricing>;
|
|
344
|
+
/** True once the card tokenizer is ready. Gate submission on this. */
|
|
345
|
+
tokenizerReady: Accessor<boolean>;
|
|
346
|
+
/** @deprecated alias of tokenizerReady (pre-rename name). */
|
|
347
|
+
acceptJsLoaded: Accessor<boolean>;
|
|
348
|
+
/** Non-null when payment setup failed to initialize (config/SDK load) —
|
|
349
|
+
* render as a banner; the pay button will never enable in this state. */
|
|
350
|
+
/** Tokenizer init failure, or null. */
|
|
351
|
+
tokenizerError: Accessor<string | null>;
|
|
352
|
+
/** @deprecated alias of tokenizerError (pre-rename name). */
|
|
353
|
+
acceptJsError: Accessor<string | null>;
|
|
354
|
+
cardNumber: Accessor<string>;
|
|
355
|
+
setCardNumber: (v: string) => void;
|
|
356
|
+
expiry: Accessor<string>;
|
|
357
|
+
setExpiry: (v: string) => void;
|
|
358
|
+
cvv: Accessor<string>;
|
|
359
|
+
setCvv: (v: string) => void;
|
|
360
|
+
paymentError: Accessor<string | null>;
|
|
361
|
+
processing: Accessor<boolean>;
|
|
362
|
+
canSubmit: Accessor<boolean>;
|
|
363
|
+
submit: () => Promise<void>;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* One-time cart checkout (model-3 support): charges the cart's non-subscription
|
|
367
|
+
* items once via POST /payments/checkout. No prescription, no recurring
|
|
368
|
+
* subscription, no card kept on file. Requires an authenticated member (the
|
|
369
|
+
* backend route is member-JWT only) — unauthenticated mounts emit `needs_auth`
|
|
370
|
+
* for the site to route to its signup/register page.
|
|
371
|
+
*/
|
|
372
|
+
declare function useCartCheckoutFlow(): CartCheckoutFlow;
|
|
373
|
+
|
|
374
|
+
type SignupOutcome = {
|
|
375
|
+
kind: 'in_progress';
|
|
376
|
+
} | {
|
|
377
|
+
kind: 'submitting';
|
|
378
|
+
}
|
|
379
|
+
/** Register+charge response was lost mid-flight; we're checking whether the
|
|
380
|
+
* account was actually created before letting the user retry. */
|
|
381
|
+
| {
|
|
382
|
+
kind: 'reconciling';
|
|
383
|
+
} | {
|
|
384
|
+
kind: 'completed';
|
|
385
|
+
};
|
|
386
|
+
interface UseSignupFlowOptions {
|
|
387
|
+
/** Membership amount charged on signup, in cents. Required — sites set their own pricing. */
|
|
388
|
+
membershipAmountCents: number;
|
|
389
|
+
/** Billing interval in days. Default 30. */
|
|
390
|
+
membershipIntervalDays?: number;
|
|
391
|
+
/** Label used when the cart is empty. Defaults to "Membership". */
|
|
392
|
+
membershipProductLabel?: string;
|
|
393
|
+
}
|
|
394
|
+
interface SignupFlow {
|
|
395
|
+
step: Accessor<number>;
|
|
396
|
+
/** True only on the very last step (Confirm). */
|
|
397
|
+
isConfirmStep: Accessor<boolean>;
|
|
398
|
+
next: () => Promise<void>;
|
|
399
|
+
back: () => void;
|
|
400
|
+
error: Accessor<string | null>;
|
|
401
|
+
/** True while tokenizing the card on the Payment step. */
|
|
402
|
+
tokenizing: Accessor<boolean>;
|
|
403
|
+
/** True while submitting on the Confirm step. */
|
|
404
|
+
submitting: Accessor<boolean>;
|
|
405
|
+
outcome: Accessor<SignupOutcome>;
|
|
406
|
+
/** True once the card tokenizer is ready. The Payment step "Continue" button gates on this. */
|
|
407
|
+
/** True once the card tokenizer is ready (config loaded; for AuthNet, Accept.js loaded too). Gate submission on this. */
|
|
408
|
+
tokenizerReady: Accessor<boolean>;
|
|
409
|
+
/** @deprecated alias of tokenizerReady (pre-rename name). */
|
|
410
|
+
acceptJsReady: Accessor<boolean>;
|
|
411
|
+
/** Non-null when payment setup failed to initialize — render as a banner;
|
|
412
|
+
* the Payment step can never proceed in this state. */
|
|
413
|
+
/** Tokenizer init failure, or null. */
|
|
414
|
+
tokenizerError: Accessor<string | null>;
|
|
415
|
+
/** @deprecated alias of tokenizerError (pre-rename name). */
|
|
416
|
+
acceptJsError: Accessor<string | null>;
|
|
417
|
+
firstName: Accessor<string>;
|
|
418
|
+
setFirstName: (v: string) => void;
|
|
419
|
+
lastName: Accessor<string>;
|
|
420
|
+
setLastName: (v: string) => void;
|
|
421
|
+
email: Accessor<string>;
|
|
422
|
+
setEmail: (v: string) => void;
|
|
423
|
+
password: Accessor<string>;
|
|
424
|
+
setPassword: (v: string) => void;
|
|
425
|
+
dateOfBirth: Accessor<string>;
|
|
426
|
+
setDateOfBirth: (v: string) => void;
|
|
427
|
+
phone: Accessor<string>;
|
|
428
|
+
setPhone: (v: string) => void;
|
|
429
|
+
street: Accessor<string>;
|
|
430
|
+
setStreet: (v: string) => void;
|
|
431
|
+
city: Accessor<string>;
|
|
432
|
+
setCity: (v: string) => void;
|
|
433
|
+
state: Accessor<string>;
|
|
434
|
+
setState: (v: string) => void;
|
|
435
|
+
zip: Accessor<string>;
|
|
436
|
+
setZip: (v: string) => void;
|
|
437
|
+
cardNumber: Accessor<string>;
|
|
438
|
+
setCardNumber: (v: string) => void;
|
|
439
|
+
expiry: Accessor<string>;
|
|
440
|
+
setExpiry: (v: string) => void;
|
|
441
|
+
cvv: Accessor<string>;
|
|
442
|
+
setCvv: (v: string) => void;
|
|
443
|
+
/**
|
|
444
|
+
* Optional promo / referral code applied at submit. Not persisted to the
|
|
445
|
+
* draft — codes can change and shouldn't survive a refresh. Sites surface
|
|
446
|
+
* this via `<SignupPage promoField={...}>`.
|
|
447
|
+
*/
|
|
448
|
+
promoCode: Accessor<string>;
|
|
449
|
+
setPromoCode: (v: string) => void;
|
|
450
|
+
/** Submit the signup at the Confirm step. */
|
|
451
|
+
submit: () => Promise<void>;
|
|
452
|
+
}
|
|
453
|
+
declare function useSignupFlow(options: UseSignupFlowOptions): SignupFlow;
|
|
454
|
+
|
|
455
|
+
type RegisterOutcome = {
|
|
456
|
+
kind: 'in_progress';
|
|
457
|
+
}
|
|
458
|
+
/** Emitted on mount when a session already exists — there is nothing to
|
|
459
|
+
* register. Sites route back to wherever sent the visitor here (for a
|
|
460
|
+
* model-3 tenant, typically the one-time checkout). */
|
|
461
|
+
| {
|
|
462
|
+
kind: 'already_authenticated';
|
|
463
|
+
} | {
|
|
464
|
+
kind: 'submitting';
|
|
465
|
+
}
|
|
466
|
+
/** Register response was lost mid-flight; we're checking whether the account
|
|
467
|
+
* was actually created (by logging in) before letting the user retry. */
|
|
468
|
+
| {
|
|
469
|
+
kind: 'reconciling';
|
|
470
|
+
} | {
|
|
471
|
+
kind: 'completed';
|
|
472
|
+
};
|
|
473
|
+
interface RegisterFlow {
|
|
474
|
+
step: Accessor<number>;
|
|
475
|
+
/** True only on the very last step (Confirm). */
|
|
476
|
+
isConfirmStep: Accessor<boolean>;
|
|
477
|
+
next: () => Promise<void>;
|
|
478
|
+
back: () => void;
|
|
479
|
+
error: Accessor<string | null>;
|
|
480
|
+
/** True while submitting on the Confirm step. */
|
|
481
|
+
submitting: Accessor<boolean>;
|
|
482
|
+
outcome: Accessor<RegisterOutcome>;
|
|
483
|
+
firstName: Accessor<string>;
|
|
484
|
+
setFirstName: (v: string) => void;
|
|
485
|
+
lastName: Accessor<string>;
|
|
486
|
+
setLastName: (v: string) => void;
|
|
487
|
+
email: Accessor<string>;
|
|
488
|
+
setEmail: (v: string) => void;
|
|
489
|
+
password: Accessor<string>;
|
|
490
|
+
setPassword: (v: string) => void;
|
|
491
|
+
dateOfBirth: Accessor<string>;
|
|
492
|
+
setDateOfBirth: (v: string) => void;
|
|
493
|
+
phone: Accessor<string>;
|
|
494
|
+
setPhone: (v: string) => void;
|
|
495
|
+
street: Accessor<string>;
|
|
496
|
+
setStreet: (v: string) => void;
|
|
497
|
+
city: Accessor<string>;
|
|
498
|
+
setCity: (v: string) => void;
|
|
499
|
+
state: Accessor<string>;
|
|
500
|
+
setState: (v: string) => void;
|
|
501
|
+
zip: Accessor<string>;
|
|
502
|
+
setZip: (v: string) => void;
|
|
503
|
+
/** Submit the registration at the Confirm step. */
|
|
504
|
+
submit: () => Promise<void>;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Non-subscribing signup (model-3 support): creates an account via
|
|
508
|
+
* POST /auth/register and establishes a session — no membership charge, no
|
|
509
|
+
* recurring subscription, no card collected. The subscribing signup
|
|
510
|
+
* (useSignupFlow / SignupPage) is untouched and remains the right surface for
|
|
511
|
+
* membership tenants.
|
|
512
|
+
*
|
|
513
|
+
* Backend note: POST /auth/register is functional but currently marked
|
|
514
|
+
* @deprecated server-side (its successor is the subscribing
|
|
515
|
+
* register-and-subscribe). Model-3 is exactly the use case that endpoint still
|
|
516
|
+
* serves; un-deprecating it is a tracked backend follow-up. It leaves the new
|
|
517
|
+
* user's `payment_status` as 'pending' — the one-time checkout charge does not
|
|
518
|
+
* change that today (see the "requirePaidSubscription 402" backend card).
|
|
519
|
+
*/
|
|
520
|
+
declare function useRegisterFlow(): RegisterFlow;
|
|
521
|
+
|
|
522
|
+
type SubscribeOutcome = {
|
|
523
|
+
kind: 'loading';
|
|
524
|
+
} | {
|
|
525
|
+
kind: 'needs_auth';
|
|
526
|
+
} | {
|
|
527
|
+
kind: 'needs_cart';
|
|
528
|
+
} | {
|
|
529
|
+
kind: 'already_subscribed';
|
|
530
|
+
} | {
|
|
531
|
+
kind: 'in_progress';
|
|
532
|
+
}
|
|
533
|
+
/** Submit response was lost mid-flight; re-checking server state before we
|
|
534
|
+
* let the user retry, so we never double-charge a charge that succeeded. */
|
|
535
|
+
| {
|
|
536
|
+
kind: 'reconciling';
|
|
537
|
+
} | {
|
|
538
|
+
kind: 'completed';
|
|
539
|
+
};
|
|
540
|
+
interface UseSubscribeFlowOptions {
|
|
541
|
+
/** Membership amount in cents charged on subscription start. Required. */
|
|
542
|
+
membershipAmountCents: number;
|
|
543
|
+
/** Billing interval in days. Default 30. */
|
|
544
|
+
membershipIntervalDays?: number;
|
|
545
|
+
}
|
|
546
|
+
interface SubscribeFlow {
|
|
547
|
+
outcome: Accessor<SubscribeOutcome>;
|
|
548
|
+
/** True once the card tokenizer is ready (config loaded; for AuthNet, Accept.js loaded too). Gate submission on this. */
|
|
549
|
+
tokenizerReady: Accessor<boolean>;
|
|
550
|
+
/** @deprecated alias of tokenizerReady (pre-rename name). */
|
|
551
|
+
acceptJsReady: Accessor<boolean>;
|
|
552
|
+
/** Non-null when payment setup failed to initialize — render as a banner. */
|
|
553
|
+
/** Tokenizer init failure, or null. */
|
|
554
|
+
tokenizerError: Accessor<string | null>;
|
|
555
|
+
/** @deprecated alias of tokenizerError (pre-rename name). */
|
|
556
|
+
acceptJsError: Accessor<string | null>;
|
|
557
|
+
error: Accessor<string | null>;
|
|
558
|
+
submitting: Accessor<boolean>;
|
|
559
|
+
street: Accessor<string>;
|
|
560
|
+
setStreet: (v: string) => void;
|
|
561
|
+
city: Accessor<string>;
|
|
562
|
+
setCity: (v: string) => void;
|
|
563
|
+
state: Accessor<string>;
|
|
564
|
+
setState: (v: string) => void;
|
|
565
|
+
zip: Accessor<string>;
|
|
566
|
+
setZip: (v: string) => void;
|
|
567
|
+
cardNumber: Accessor<string>;
|
|
568
|
+
setCardNumber: (v: string) => void;
|
|
569
|
+
expiry: Accessor<string>;
|
|
570
|
+
setExpiry: (v: string) => void;
|
|
571
|
+
cvv: Accessor<string>;
|
|
572
|
+
setCvv: (v: string) => void;
|
|
573
|
+
submit: () => Promise<void>;
|
|
574
|
+
}
|
|
575
|
+
declare function useSubscribeFlow(options: UseSubscribeFlowOptions): SubscribeFlow;
|
|
576
|
+
|
|
577
|
+
interface DashboardSubscription {
|
|
578
|
+
id: string;
|
|
579
|
+
status: 'active' | 'paused' | 'cancelled';
|
|
580
|
+
nextBillingDate?: string;
|
|
581
|
+
amount?: number;
|
|
582
|
+
[key: string]: unknown;
|
|
583
|
+
}
|
|
584
|
+
type RxRequestStatus = 'pending' | 'approved' | 'denied' | 'shipped' | 'new' | 'processing' | 'completed';
|
|
585
|
+
interface DashboardRxStatus {
|
|
586
|
+
status: RxRequestStatus;
|
|
587
|
+
reason?: string;
|
|
588
|
+
delivery?: DeliveryInfo | null;
|
|
589
|
+
[key: string]: unknown;
|
|
590
|
+
}
|
|
591
|
+
interface DashboardRxListItem {
|
|
592
|
+
requestId: string;
|
|
593
|
+
status: RxRequestStatus;
|
|
594
|
+
drugId?: string;
|
|
595
|
+
drugName?: string;
|
|
596
|
+
dosage?: string;
|
|
597
|
+
priceCents?: number;
|
|
598
|
+
paymentConfirmed?: boolean;
|
|
599
|
+
pharmacySent?: boolean;
|
|
600
|
+
reason?: string;
|
|
601
|
+
createdAt: string;
|
|
602
|
+
delivery?: DeliveryInfo | null;
|
|
603
|
+
renewal?: {
|
|
604
|
+
renewalId: string;
|
|
605
|
+
cycleNumber: number;
|
|
606
|
+
status: RenewalStatus;
|
|
607
|
+
pharmacyFillDate: string | null;
|
|
608
|
+
} | null;
|
|
609
|
+
}
|
|
610
|
+
interface DashboardActivityItem {
|
|
611
|
+
id: string;
|
|
612
|
+
label: string;
|
|
613
|
+
/** Relative-time string like "5m ago" or a fallback like "Next bill: May 4". */
|
|
614
|
+
time: string;
|
|
615
|
+
/** Single-character symbol or short emoji indicating the kind of event. Sites can map these to icons. */
|
|
616
|
+
icon: string;
|
|
617
|
+
}
|
|
618
|
+
interface DashboardData {
|
|
619
|
+
profile: Resource<User | null>;
|
|
620
|
+
subscription: Resource<DashboardSubscription | null>;
|
|
621
|
+
rxStatus: Resource<DashboardRxStatus | null>;
|
|
622
|
+
rxList: Resource<DashboardRxListItem[]>;
|
|
623
|
+
/** Re-fetch the prescription list (e.g. after cancelling a request). */
|
|
624
|
+
refetchRxList: () => void;
|
|
625
|
+
pendingSurveys: Resource<PendingRenewalSurvey[]>;
|
|
626
|
+
/** First name from profile or authStore, falling back to "Member". */
|
|
627
|
+
displayName: () => string;
|
|
628
|
+
/** Recent activity feed derived from profile + subscription + rxStatus. */
|
|
629
|
+
activity: () => DashboardActivityItem[];
|
|
630
|
+
/**
|
|
631
|
+
* Non-null when any dashboard read failed. A transient 500 used to render as
|
|
632
|
+
* genuine emptiness ("No prescriptions"); surface this and offer `retry()`
|
|
633
|
+
* instead of presenting a failure as truth. Individual resources also carry
|
|
634
|
+
* a real `.error` now — but their value reads stay safe (empty/null
|
|
635
|
+
* fallback), so existing consumers never crash on an errored read.
|
|
636
|
+
*/
|
|
637
|
+
error: () => string | null;
|
|
638
|
+
/** Re-fetch every dashboard resource (use from the error state's retry CTA). */
|
|
639
|
+
retry: () => void;
|
|
640
|
+
}
|
|
641
|
+
declare function formatRelativeTime(dateStr: string): string;
|
|
642
|
+
/**
|
|
643
|
+
* Loads the data needed for the patient dashboard. No JSX — sites compose
|
|
644
|
+
* their own layouts on top of this. Auth/admin guards are intentionally
|
|
645
|
+
* not bundled here; the consuming site handles routing.
|
|
646
|
+
*
|
|
647
|
+
* Pass `opts.authToken` (a reactive accessor) to load the whole dashboard AS
|
|
648
|
+
* another user — e.g. an admin "view as customer" preview using a short-lived
|
|
649
|
+
* impersonation token. When provided, every read carries that token instead of
|
|
650
|
+
* the auth store's session, so it never touches the caller's own login.
|
|
651
|
+
*/
|
|
652
|
+
declare function useDashboardData(opts?: {
|
|
653
|
+
authToken?: () => string | undefined;
|
|
654
|
+
}): DashboardData;
|
|
655
|
+
|
|
656
|
+
type TrackingUrlCarrier = 'fedex' | 'ups' | 'usps';
|
|
657
|
+
declare function buildTrackingUrl(delivery: DeliveryInfo | null | undefined): string | null;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Pure derivation logic for the member portal order tracker and refill timeline.
|
|
661
|
+
*
|
|
662
|
+
* Design intent ("Apothecary" direction): one continuous vertical thread of
|
|
663
|
+
* fulfillment "beads". The thread fills to wherever REAL backend data reaches and
|
|
664
|
+
* never fabricates a state. Today the backend reliably exposes
|
|
665
|
+
* pending/approved/denied/call_requested (+ shipped/delivery/renewal when present),
|
|
666
|
+
* so beads beyond the known state render as honest "upcoming" nodes.
|
|
667
|
+
*
|
|
668
|
+
* No JSX and no data-fetching: the `MemberPortal` page maps its dashboard
|
|
669
|
+
* resources into the small `TrackerRequest`/`TrackerSubscription` input shapes
|
|
670
|
+
* below and renders the returned view. Kept framework-light and fully testable
|
|
671
|
+
* (`now` is injected — no `Date.now()` inside the derivations).
|
|
672
|
+
*/
|
|
673
|
+
|
|
674
|
+
type TrackerRequestStatus = 'pending' | 'approved' | 'denied' | 'call_requested' | 'pharmacy' | 'shipped';
|
|
675
|
+
interface TrackerRequest {
|
|
676
|
+
status: TrackerRequestStatus;
|
|
677
|
+
createdAt: string | null;
|
|
678
|
+
updatedAt: string | null;
|
|
679
|
+
dosage?: string;
|
|
680
|
+
delivery: DeliveryInfo | null;
|
|
681
|
+
}
|
|
682
|
+
type TrackerSubscriptionStatus = 'active' | 'paused' | 'past_due' | 'cancelled' | 'suspended' | 'expired';
|
|
683
|
+
interface TrackerSubscription {
|
|
684
|
+
status: TrackerSubscriptionStatus;
|
|
685
|
+
currentPeriodEnd: string | null;
|
|
686
|
+
intervalDays?: number;
|
|
687
|
+
}
|
|
688
|
+
type StageState = 'done' | 'active' | 'upcoming' | 'consult' | 'denied';
|
|
689
|
+
interface FulfillmentStage {
|
|
690
|
+
key: string;
|
|
691
|
+
/** Small-caps "lab label" shown on every bead. */
|
|
692
|
+
label: string;
|
|
693
|
+
/** Large display word — only set on the active / branch bead. */
|
|
694
|
+
heroWord?: string;
|
|
695
|
+
/** Plain-language one-liner under the hero word. */
|
|
696
|
+
subCaption?: string;
|
|
697
|
+
state: StageState;
|
|
698
|
+
/** Absolute timestamp string we actually have (createdAt / updatedAt). */
|
|
699
|
+
timestamp?: string | null;
|
|
700
|
+
}
|
|
701
|
+
interface ShipmentInfo {
|
|
702
|
+
carrier: string | null;
|
|
703
|
+
trackingNumber: string | null;
|
|
704
|
+
trackingUrl: string | null;
|
|
705
|
+
/** Honest ETA copy — relative reassurance when no real estimate exists. */
|
|
706
|
+
etaLabel: string;
|
|
707
|
+
}
|
|
708
|
+
interface TrackerView {
|
|
709
|
+
stages: FulfillmentStage[];
|
|
710
|
+
/** Index of the active/branch bead, for the "pour" fill height. */
|
|
711
|
+
activeIndex: number;
|
|
712
|
+
shipment: ShipmentInfo | null;
|
|
713
|
+
/** True for denied/consult so the UI can pick supportive treatment. */
|
|
714
|
+
branch: 'consult' | 'denied' | null;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Build the full tracker view from a prescription request. Branches
|
|
718
|
+
* (consultation needed / not approved) stay on the same thread, reframed as a
|
|
719
|
+
* pause rather than an error.
|
|
720
|
+
*/
|
|
721
|
+
declare function buildTrackerView(rx: TrackerRequest): TrackerView;
|
|
722
|
+
interface RefillEvent {
|
|
723
|
+
key: 'fill' | 'survey' | 'shipment';
|
|
724
|
+
label: string;
|
|
725
|
+
date: Date | null;
|
|
726
|
+
/** Soft relative copy, e.g. "in 6 days". */
|
|
727
|
+
relative: string;
|
|
728
|
+
/** Nearest upcoming event gets the highlight dot. */
|
|
729
|
+
nearest: boolean;
|
|
730
|
+
}
|
|
731
|
+
interface RefillView {
|
|
732
|
+
events: RefillEvent[];
|
|
733
|
+
/** "Day 18 of 30" cycle counter. */
|
|
734
|
+
cycleDay: number;
|
|
735
|
+
cycleLength: number;
|
|
736
|
+
/** 0–1 progress through the current billing cycle. */
|
|
737
|
+
progress: number;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Derive the refill/renewal strip from a subscription. Every date is an estimate
|
|
741
|
+
* derived from `currentPeriodEnd` (the only reliable field) and is labelled
|
|
742
|
+
* softly ("around"). When the backend adds explicit nextFill / surveyDue fields,
|
|
743
|
+
* swap the derivation here.
|
|
744
|
+
*
|
|
745
|
+
* `now` is injected so this stays a pure function (testable; no Date.now()).
|
|
746
|
+
*/
|
|
747
|
+
declare function buildRefillView(sub: TrackerSubscription | null | undefined, now?: number): RefillView | null;
|
|
748
|
+
declare function formatStageDate(value?: string | null): string;
|
|
749
|
+
declare function formatEventDate(date: Date | null): string;
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Data source for the customer member portal. Headless (no JSX): the
|
|
753
|
+
* `MemberPortal` page composes its layout on top of this.
|
|
754
|
+
*
|
|
755
|
+
* Business-model-flexible by design — capabilities are inferred from the data,
|
|
756
|
+
* not hardcoded to one partner's model:
|
|
757
|
+
* - RX requests are a LIST (a member may have several in flight at once).
|
|
758
|
+
* - Subscriptions are OPTIONAL (some partners are one-time-purchase only).
|
|
759
|
+
* The page reads `hasBilling()` / `rxRequests()` to decide which tabs/sections
|
|
760
|
+
* to show, so a no-subscription, multi-RX partner and a single-RX +
|
|
761
|
+
* subscription partner both render correctly from the same component.
|
|
762
|
+
*
|
|
763
|
+
* Sources: `/members/me` (member + subscriptions) and `/members/me/requests`
|
|
764
|
+
* (the RX list — the endpoint the pre-redesign dashboard used successfully).
|
|
765
|
+
*/
|
|
766
|
+
|
|
767
|
+
/** A subscription row from `/members/me` (see `MembersMeResponse.subscriptions`). */
|
|
768
|
+
interface MemberPortalSubscription {
|
|
769
|
+
id: string;
|
|
770
|
+
productId: string;
|
|
771
|
+
/** Apex drug id (a code). */
|
|
772
|
+
medication: string;
|
|
773
|
+
/** Friendly product name resolved server-side; falls back to `medication`. */
|
|
774
|
+
medicationName?: string;
|
|
775
|
+
dosage: string;
|
|
776
|
+
status: string;
|
|
777
|
+
amountCents: number;
|
|
778
|
+
intervalDays: number;
|
|
779
|
+
currentPeriodEnd: string;
|
|
780
|
+
createdAt: string;
|
|
781
|
+
}
|
|
782
|
+
/** A prescription request, flattened for the portal. */
|
|
783
|
+
interface MemberPortalRx {
|
|
784
|
+
requestId: string;
|
|
785
|
+
status: TrackerRequestStatus;
|
|
786
|
+
drugName?: string;
|
|
787
|
+
dosage?: string;
|
|
788
|
+
createdAt: string | null;
|
|
789
|
+
updatedAt: string | null;
|
|
790
|
+
delivery: DeliveryInfo | null;
|
|
791
|
+
/** Open check-in renewal id, if any (drives the "Complete check-in" link). */
|
|
792
|
+
renewalId: string | null;
|
|
793
|
+
}
|
|
794
|
+
interface MemberPortalData {
|
|
795
|
+
/** Raw member record (`/members/me` → `member`); shape is backend-defined. */
|
|
796
|
+
member: () => Record<string, unknown> | null;
|
|
797
|
+
subscriptions: () => MemberPortalSubscription[];
|
|
798
|
+
/** The subscription the portal treats as primary (live one first, else first). */
|
|
799
|
+
primarySubscription: () => MemberPortalSubscription | null;
|
|
800
|
+
/** True when this member/partner has any subscription (gates the Plan tab). */
|
|
801
|
+
hasBilling: () => boolean;
|
|
802
|
+
/** All RX requests, newest first. */
|
|
803
|
+
rxRequests: () => MemberPortalRx[];
|
|
804
|
+
/** The RX to feature (newest in-flight, else newest overall). */
|
|
805
|
+
primaryRx: () => MemberPortalRx | null;
|
|
806
|
+
/** The remaining RX requests (everything but the primary), newest first. */
|
|
807
|
+
otherRx: () => MemberPortalRx[];
|
|
808
|
+
pendingSurveys: () => PendingRenewalSurvey[];
|
|
809
|
+
/** First name from the member record (camel or snake), else "Member". */
|
|
810
|
+
firstName: () => string;
|
|
811
|
+
loading: () => boolean;
|
|
812
|
+
/** Present when the RX list or member load failed — surfaced, not swallowed. */
|
|
813
|
+
error: () => string | null;
|
|
814
|
+
refetch: () => void;
|
|
815
|
+
/** Adapt an RX into the tracker flow's input contract. */
|
|
816
|
+
toTrackerRequest: (rx: MemberPortalRx) => TrackerRequest;
|
|
817
|
+
/** The subscription driving the refill strip (only when hasBilling). */
|
|
818
|
+
trackerSubscription: () => TrackerSubscription | null;
|
|
819
|
+
}
|
|
820
|
+
declare function useMemberPortalData(): MemberPortalData;
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Headless flow for updating a subscription's payment method (card on file).
|
|
824
|
+
* Composes the provider-aware tokenizer (useCardTokenizer) with
|
|
825
|
+
* subscriptionsApi.updatePaymentMethod: the raw PAN is tokenized client-side and
|
|
826
|
+
* only the opaque token is sent to the backend.
|
|
827
|
+
*
|
|
828
|
+
* The card-entry UI (UpdatePaymentMethod page) renders these signals; the
|
|
829
|
+
* subscription id is provided reactively so the page can resolve it (e.g. the
|
|
830
|
+
* member's primary subscription) before the card is submitted.
|
|
831
|
+
*/
|
|
832
|
+
|
|
833
|
+
interface UpdatePaymentMethodFlow {
|
|
834
|
+
cardNumber: Accessor<string>;
|
|
835
|
+
setCardNumber: (v: string) => void;
|
|
836
|
+
expiry: Accessor<string>;
|
|
837
|
+
setExpiry: (v: string) => void;
|
|
838
|
+
cvv: Accessor<string>;
|
|
839
|
+
setCvv: (v: string) => void;
|
|
840
|
+
/** True once the tenant's tokenizer is loaded. */
|
|
841
|
+
ready: Accessor<boolean>;
|
|
842
|
+
submitting: Accessor<boolean>;
|
|
843
|
+
/** User-facing error from tokenization or the update call. */
|
|
844
|
+
error: Accessor<string | null>;
|
|
845
|
+
/** Whether submit is currently allowed (ready, all fields present, idle). */
|
|
846
|
+
canSubmit: Accessor<boolean>;
|
|
847
|
+
/** Tokenize + PUT the new card. Resolves true on success, false on failure. */
|
|
848
|
+
submit: () => Promise<boolean>;
|
|
849
|
+
/**
|
|
850
|
+
* Billing address sent as the card's billTo.
|
|
851
|
+
*
|
|
852
|
+
* This screen used to send the card alone, leaving the backend to bill
|
|
853
|
+
* against the member's SHIPPING profile with nothing shown and nothing
|
|
854
|
+
* editable. The gateway validates the card live on update, so a card that
|
|
855
|
+
* bills to a different address failed AVS — surfacing as a bare "declined"
|
|
856
|
+
* that named nothing and offered no control to fix. The member could not
|
|
857
|
+
* update their card on file at all.
|
|
858
|
+
*
|
|
859
|
+
* Prefilled from `GET /payment-method` with whatever is already on file at
|
|
860
|
+
* the gateway (falling back to the profile address), so the common case is
|
|
861
|
+
* still confirm-and-save.
|
|
862
|
+
*/
|
|
863
|
+
billing: AddressPair;
|
|
864
|
+
/** True once the address on file has loaded (fields prefill on arrival). */
|
|
865
|
+
billingLoaded: Accessor<boolean>;
|
|
866
|
+
}
|
|
867
|
+
declare function useUpdatePaymentMethodFlow(subscriptionId: () => string | null): UpdatePaymentMethodFlow;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Which backend a conversation belongs to.
|
|
871
|
+
*
|
|
872
|
+
* `clinical` is Apex's patient <-> prescriber messaging, proxied by the backend.
|
|
873
|
+
* `support` is the backend's own customer <-> support threads. The member sees
|
|
874
|
+
* one merged inbox; everything below routes each operation to the right API
|
|
875
|
+
* based on this discriminator, so the two never cross.
|
|
876
|
+
*/
|
|
877
|
+
type ConversationSource = 'clinical' | 'support';
|
|
878
|
+
/** Normalised conversation. The backend passes Apex's record through verbatim
|
|
879
|
+
* (the-backend routes/messages.ts → apexMessaging.Conversation), which names
|
|
880
|
+
* three of these fields differently; `normalizeConversation` reconciles them so
|
|
881
|
+
* consumers only ever see this shape. Support threads are mapped onto the same
|
|
882
|
+
* shape by `normalizeSupportThread`. */
|
|
883
|
+
interface Conversation {
|
|
884
|
+
id: string;
|
|
885
|
+
source: ConversationSource;
|
|
886
|
+
participantName?: string;
|
|
887
|
+
participantRole?: string;
|
|
888
|
+
lastMessage?: string;
|
|
889
|
+
lastMessageAt?: string;
|
|
890
|
+
unreadCount?: number;
|
|
891
|
+
/** Support threads only — open | pending | closed. */
|
|
892
|
+
status?: string;
|
|
893
|
+
[key: string]: unknown;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* One attachment on a message, normalised across sources.
|
|
897
|
+
*
|
|
898
|
+
* `url` present means the source handed us a directly-usable link (Apex's
|
|
899
|
+
* clinical messages do this). Absent means it must be exchanged for a
|
|
900
|
+
* short-lived signed URL by id — how support attachments work, since their
|
|
901
|
+
* bucket is private.
|
|
902
|
+
*/
|
|
903
|
+
interface ThreadAttachment {
|
|
904
|
+
id: string;
|
|
905
|
+
filename: string;
|
|
906
|
+
mimeType: string;
|
|
907
|
+
sizeBytes: number;
|
|
908
|
+
url?: string;
|
|
909
|
+
}
|
|
910
|
+
interface ThreadMessage {
|
|
911
|
+
id: string;
|
|
912
|
+
senderId: string;
|
|
913
|
+
senderRole: string;
|
|
914
|
+
senderName?: string;
|
|
915
|
+
type: 'text' | 'system' | 'html';
|
|
916
|
+
text: string;
|
|
917
|
+
content?: string;
|
|
918
|
+
createdAt: string;
|
|
919
|
+
/** Empty for sources that don't carry attachments. */
|
|
920
|
+
attachments?: ThreadAttachment[];
|
|
921
|
+
[key: string]: unknown;
|
|
922
|
+
}
|
|
923
|
+
declare function formatConversationTime(iso: string | undefined): string;
|
|
924
|
+
declare function formatMessageTime(iso: string): string;
|
|
925
|
+
interface UseMessagesThreadOptions {
|
|
926
|
+
/** Override poll intervals. Defaults: conversations 30s, messages 10s. */
|
|
927
|
+
pollIntervalMs?: {
|
|
928
|
+
conversations?: number;
|
|
929
|
+
messages?: number;
|
|
930
|
+
};
|
|
931
|
+
/** When set to false, the hook does not auto-poll. Useful for tests or when the consumer wants to drive refresh manually. Default true. */
|
|
932
|
+
autoPoll?: boolean;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Outcome of opening a support thread. Two flags rather than a boolean because
|
|
936
|
+
* "the thread exists but the file didn't attach" is a real, recoverable state
|
|
937
|
+
* the UI must not report as outright failure — retrying the whole thing would
|
|
938
|
+
* open a second thread.
|
|
939
|
+
*/
|
|
940
|
+
interface StartThreadResult {
|
|
941
|
+
created: boolean;
|
|
942
|
+
attachmentFailed: boolean;
|
|
943
|
+
}
|
|
944
|
+
interface MessagesThread {
|
|
945
|
+
conversations: Accessor<Conversation[]>;
|
|
946
|
+
loadingConversations: Accessor<boolean>;
|
|
947
|
+
selectedId: Accessor<string | null>;
|
|
948
|
+
messages: Accessor<ThreadMessage[]>;
|
|
949
|
+
loadingMessages: Accessor<boolean>;
|
|
950
|
+
draft: Accessor<string>;
|
|
951
|
+
setDraft: (v: string) => void;
|
|
952
|
+
sending: Accessor<boolean>;
|
|
953
|
+
/** True while a new support thread is being opened. */
|
|
954
|
+
startingThread: Accessor<boolean>;
|
|
955
|
+
/** Source of the open conversation, or null when none is selected. */
|
|
956
|
+
selectedSource: Accessor<ConversationSource | null>;
|
|
957
|
+
/** Select a conversation. Loads messages, marks as read, starts the message-poll loop. */
|
|
958
|
+
selectConversation: (id: string) => Promise<void>;
|
|
959
|
+
/** Clear the active selection (useful for "back to list" on mobile). */
|
|
960
|
+
clearSelection: () => void;
|
|
961
|
+
/** Send the current draft as a message. Optimistically appends; rolls back if the request fails. */
|
|
962
|
+
send: () => Promise<void>;
|
|
963
|
+
/** Manually refetch the conversation list. */
|
|
964
|
+
refreshConversations: () => Promise<void>;
|
|
965
|
+
/** Open a new support thread with a subject and first message, then select it.
|
|
966
|
+
* Support-only — clinical conversations are started by the prescriber, never
|
|
967
|
+
* the member. An optional file is uploaded as a follow-up request; see
|
|
968
|
+
* StartThreadResult for the partial-success case. */
|
|
969
|
+
startSupportThread: (subject: string, body: string, file?: File) => Promise<StartThreadResult>;
|
|
970
|
+
/** Send a file to the open support thread, with optional accompanying text. */
|
|
971
|
+
sendAttachment: (file: File, text?: string) => Promise<boolean>;
|
|
972
|
+
/** Exchange an attachment id for a short-lived viewable URL, or null.
|
|
973
|
+
* Pass force to bypass the cache after an expired-URL load failure. */
|
|
974
|
+
resolveAttachmentUrl: (attachmentId: string, force?: boolean) => Promise<string | null>;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Conversation list + active-thread state with polling. Tier 2 hook —
|
|
978
|
+
* sites compose their own split-pane / mobile UI on top.
|
|
979
|
+
*/
|
|
980
|
+
declare function useMessagesThread(options?: UseMessagesThreadOptions): MessagesThread;
|
|
981
|
+
|
|
982
|
+
/** Lowest price across the product's available doses (overlay-or-base each),
|
|
983
|
+
* falling back to the product-level price. Returns null for free / unpriced products. */
|
|
984
|
+
declare function lowestPrice(product: CatalogProduct): number | null;
|
|
985
|
+
/**
|
|
986
|
+
* Lowest sale price for a tiered product, computed by re-deriving the same
|
|
987
|
+
* percent/fixed discount the backend applied at the product level. Used so
|
|
988
|
+
* the strikethrough lands on the displayed (lowest-tier) value.
|
|
989
|
+
*
|
|
990
|
+
* Returns null when no active sale, no discount, or insufficient data.
|
|
991
|
+
*/
|
|
992
|
+
declare function lowestSalePrice(product: CatalogProduct, basePrice: number | null): number | null;
|
|
993
|
+
interface CatalogFlow {
|
|
994
|
+
products: Resource<CatalogProduct[]>;
|
|
995
|
+
/** Products in the "weight-loss" category. */
|
|
996
|
+
weightLoss: Accessor<CatalogProduct[]>;
|
|
997
|
+
/** Products NOT in "weight-loss" (peptides, recovery, etc). */
|
|
998
|
+
peptides: Accessor<CatalogProduct[]>;
|
|
999
|
+
/** Filter products by an arbitrary category slug. */
|
|
1000
|
+
filterByCategory: (slug: string) => CatalogProduct[];
|
|
1001
|
+
}
|
|
1002
|
+
/** Fetches the product catalog and exposes a couple of common derivations. */
|
|
1003
|
+
declare function useCatalog(): CatalogFlow;
|
|
1004
|
+
interface ProductDetailFlow {
|
|
1005
|
+
product: Resource<CatalogProduct | null>;
|
|
1006
|
+
dosageOptions: Accessor<Array<{
|
|
1007
|
+
dosage: string;
|
|
1008
|
+
price: number;
|
|
1009
|
+
savingsPrice: number | null;
|
|
1010
|
+
}>>;
|
|
1011
|
+
selectedDosage: Accessor<string>;
|
|
1012
|
+
setSelectedDosage: (v: string) => void;
|
|
1013
|
+
/** Effective base price for the currently-selected dosage. */
|
|
1014
|
+
selectedPrice: Accessor<number | null>;
|
|
1015
|
+
/** Sale price for the selected dosage, if a sale is active. */
|
|
1016
|
+
selectedSalePrice: Accessor<number | null>;
|
|
1017
|
+
/** 'per_dose' (default) or 'flat_fee'. When 'flat_fee', `dosageOptions` is
|
|
1018
|
+
* collapsed to a single entry and consumer UI should hide the dose picker. */
|
|
1019
|
+
pricingMode: Accessor<'per_dose' | 'flat_fee'>;
|
|
1020
|
+
/** True if the product+dosage combination is already in cart. */
|
|
1021
|
+
inCart: Accessor<boolean>;
|
|
1022
|
+
addToCart: () => void;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Single-product page state. Loads the catalog and finds the product by id.
|
|
1026
|
+
* Tracks dosage selection, derives current/sale price, exposes addToCart.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function useProductDetail(productId: Accessor<string>): ProductDetailFlow;
|
|
1029
|
+
interface MedicationSelectFlow {
|
|
1030
|
+
products: Resource<CatalogProduct[]>;
|
|
1031
|
+
weightLoss: Accessor<CatalogProduct[]>;
|
|
1032
|
+
peptides: Accessor<CatalogProduct[]>;
|
|
1033
|
+
/** Pick a specific product as the patient's selected medication and proceed. The site fires the navigation in the optional `onSelected` callback. */
|
|
1034
|
+
selectMedication: (product: CatalogProduct) => void;
|
|
1035
|
+
/** Pick "general consultation" — a null drugId, indicating no pre-selected drug. */
|
|
1036
|
+
selectGeneralConsultation: () => void;
|
|
1037
|
+
}
|
|
1038
|
+
interface UseMedicationSelectOptions {
|
|
1039
|
+
/** Called after a selection is made. Sites typically navigate to their survey route. */
|
|
1040
|
+
onSelected?: () => void;
|
|
1041
|
+
/** Override the label used for the general-consultation selection. Default "General Consultation". */
|
|
1042
|
+
generalConsultationLabel?: string;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Catalog browse + select-for-survey. The selection is written to
|
|
1046
|
+
* medicationStore (legacy single-item flow); the site navigates afterward
|
|
1047
|
+
* via the onSelected callback.
|
|
1048
|
+
*/
|
|
1049
|
+
declare function useMedicationSelect(options?: UseMedicationSelectOptions): MedicationSelectFlow;
|
|
1050
|
+
|
|
1051
|
+
interface AffiliateStatsFlow {
|
|
1052
|
+
stats: Resource<AffiliateDashboardStats | null>;
|
|
1053
|
+
refetch: () => void;
|
|
1054
|
+
}
|
|
1055
|
+
interface AffiliateConversionsFlow {
|
|
1056
|
+
conversions: Resource<AffiliateConversion[]>;
|
|
1057
|
+
refetch: () => void;
|
|
1058
|
+
}
|
|
1059
|
+
interface AffiliateLinksFlow {
|
|
1060
|
+
links: Resource<AffiliateDashboardLinks | null>;
|
|
1061
|
+
refetch: () => void;
|
|
1062
|
+
}
|
|
1063
|
+
interface AffiliateDownlineFlow {
|
|
1064
|
+
downline: Resource<AffiliateDownlineMember[]>;
|
|
1065
|
+
refetch: () => void;
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Wraps GET /affiliates/dashboard/stats as a resource. Gated on the
|
|
1069
|
+
* affiliate auth store so the fetcher only fires when the affiliate is
|
|
1070
|
+
* authenticated; otherwise the resource resolves to `null`.
|
|
1071
|
+
*/
|
|
1072
|
+
declare function useAffiliateStats(): AffiliateStatsFlow;
|
|
1073
|
+
declare function useAffiliateConversions(opts?: {
|
|
1074
|
+
limit?: number;
|
|
1075
|
+
}): AffiliateConversionsFlow;
|
|
1076
|
+
declare function useAffiliateDownline(): AffiliateDownlineFlow;
|
|
1077
|
+
declare function useAffiliateLinks(): AffiliateLinksFlow;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Deterministic procedural color for product categories.
|
|
1081
|
+
*
|
|
1082
|
+
* Sites want a stable color per category id without curating maps. The hash
|
|
1083
|
+
* is stable across reloads, so the same id always picks the same slot. Sites
|
|
1084
|
+
* override the palette to brand-align — default palette works out of the box.
|
|
1085
|
+
*/
|
|
1086
|
+
/** Default palette. Reads on light or dark; sites that want brand alignment
|
|
1087
|
+
* pass their own array (e.g. CSS var refs). */
|
|
1088
|
+
declare const DEFAULT_COLOR_PALETTE: readonly string[];
|
|
1089
|
+
interface CategoryColorOpts {
|
|
1090
|
+
palette?: readonly string[];
|
|
1091
|
+
}
|
|
1092
|
+
declare function categoryColor(id: string, opts?: CategoryColorOpts): string;
|
|
1093
|
+
|
|
1094
|
+
interface SurveyResult {
|
|
1095
|
+
surveyResponseId: string;
|
|
1096
|
+
/**
|
|
1097
|
+
* v2 survey response id. When set, the Rx is linked to the Apex survey
|
|
1098
|
+
* snapshot and Apex generates the prescriber case notes from it (no local
|
|
1099
|
+
* caseNotes synthesis). Leave unset for the legacy v1 flow.
|
|
1100
|
+
*/
|
|
1101
|
+
v2SurveyResponseId?: string;
|
|
1102
|
+
caseNotes?: string;
|
|
1103
|
+
drugId: string;
|
|
1104
|
+
drugName: string;
|
|
1105
|
+
dosage: string;
|
|
1106
|
+
}
|
|
1107
|
+
interface MedicationPricing {
|
|
1108
|
+
productId: string;
|
|
1109
|
+
productName: string;
|
|
1110
|
+
priceCents: number;
|
|
1111
|
+
savingsPriceCents?: number | null;
|
|
1112
|
+
}
|
|
1113
|
+
type SubscriptionIntakeOutcome = {
|
|
1114
|
+
kind: 'in_progress';
|
|
1115
|
+
} | {
|
|
1116
|
+
kind: 'tokenizing';
|
|
1117
|
+
} | {
|
|
1118
|
+
kind: 'submitting';
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* The member already holds a live subscription, so this intake must not create
|
|
1122
|
+
* a second one. Emitted ONLY under `singleSubscription` — without that option
|
|
1123
|
+
* the flow behaves exactly as before, so existing consumers that switch on
|
|
1124
|
+
* 'completed' alone are unaffected.
|
|
1125
|
+
*
|
|
1126
|
+
* Deliberately NOT 'completed': that kind means *this* purchase succeeded, and
|
|
1127
|
+
* hosts navigate onward celebrating it. This one means the member arrived
|
|
1128
|
+
* already subscribed and needs telling, not congratulating.
|
|
1129
|
+
*/
|
|
1130
|
+
| {
|
|
1131
|
+
kind: 'already_subscribed';
|
|
1132
|
+
productId?: string;
|
|
1133
|
+
} | {
|
|
1134
|
+
kind: 'completed';
|
|
1135
|
+
};
|
|
1136
|
+
interface UseSubscriptionIntakeFlowOptions {
|
|
1137
|
+
surveyResult: SurveyResult;
|
|
1138
|
+
pricing: MedicationPricing;
|
|
1139
|
+
intervalDays?: number;
|
|
1140
|
+
/**
|
|
1141
|
+
* Whether the member is enrolled in the savings program — read reactively, so
|
|
1142
|
+
* a verification that completes mid-intake re-quotes. When true and the
|
|
1143
|
+
* product defines `savingsPriceCents`, that rate is quoted instead of list.
|
|
1144
|
+
*
|
|
1145
|
+
* Must track the same member the SERVER will resolve at charge time (the
|
|
1146
|
+
* persisted savings link), or the quote and the charge disagree.
|
|
1147
|
+
*/
|
|
1148
|
+
isSavingsMember?: () => boolean;
|
|
1149
|
+
/**
|
|
1150
|
+
* Single-subscription tenants: the site sells ONE subscription program, so a
|
|
1151
|
+
* member may hold at most one live subscription — of ANY product.
|
|
1152
|
+
*
|
|
1153
|
+
* Widens the mount reconcile below from "already subscribed to THIS product"
|
|
1154
|
+
* to "already subscribed to anything", and turns the server's
|
|
1155
|
+
* `SUBSCRIPTION_EXISTS` rejection into an `already_subscribed` outcome instead
|
|
1156
|
+
* of a raw error banner. Mirrors `features.singleSubscription` on the tenant;
|
|
1157
|
+
* setting it here without the tenant flag still guards the common paths, but
|
|
1158
|
+
* the server is what actually enforces it.
|
|
1159
|
+
*/
|
|
1160
|
+
singleSubscription?: boolean;
|
|
1161
|
+
}
|
|
1162
|
+
interface PromoPricing {
|
|
1163
|
+
baseCents: number;
|
|
1164
|
+
discountCents: number;
|
|
1165
|
+
finalCents: number;
|
|
1166
|
+
promoCode?: string;
|
|
1167
|
+
}
|
|
1168
|
+
interface SubscriptionIntakeFlow {
|
|
1169
|
+
step: Accessor<number>;
|
|
1170
|
+
stepCount: 3;
|
|
1171
|
+
next: () => Promise<void>;
|
|
1172
|
+
back: () => void;
|
|
1173
|
+
outcome: Accessor<SubscriptionIntakeOutcome>;
|
|
1174
|
+
error: Accessor<string | null>;
|
|
1175
|
+
submitting: Accessor<boolean>;
|
|
1176
|
+
tokenizing: Accessor<boolean>;
|
|
1177
|
+
/** True once the card tokenizer is ready (config loaded; for AuthNet, Accept.js loaded too). Gate submission on this. */
|
|
1178
|
+
tokenizerReady: Accessor<boolean>;
|
|
1179
|
+
/** @deprecated alias of tokenizerReady (pre-rename name). */
|
|
1180
|
+
acceptJsReady: Accessor<boolean>;
|
|
1181
|
+
/** Non-null when payment setup failed to initialize — render as a banner. */
|
|
1182
|
+
/** Tokenizer init failure, or null. */
|
|
1183
|
+
tokenizerError: Accessor<string | null>;
|
|
1184
|
+
/** @deprecated alias of tokenizerError (pre-rename name). */
|
|
1185
|
+
acceptJsError: Accessor<string | null>;
|
|
1186
|
+
firstName: Accessor<string>;
|
|
1187
|
+
setFirstName: (v: string) => void;
|
|
1188
|
+
lastName: Accessor<string>;
|
|
1189
|
+
setLastName: (v: string) => void;
|
|
1190
|
+
email: Accessor<string>;
|
|
1191
|
+
setEmail: (v: string) => void;
|
|
1192
|
+
password: Accessor<string>;
|
|
1193
|
+
setPassword: (v: string) => void;
|
|
1194
|
+
dateOfBirth: Accessor<string>;
|
|
1195
|
+
setDateOfBirth: (v: string) => void;
|
|
1196
|
+
phone: Accessor<string>;
|
|
1197
|
+
setPhone: (v: string) => void;
|
|
1198
|
+
address: AddressPair;
|
|
1199
|
+
cardNumber: Accessor<string>;
|
|
1200
|
+
setCardNumber: (v: string) => void;
|
|
1201
|
+
expiry: Accessor<string>;
|
|
1202
|
+
setExpiry: (v: string) => void;
|
|
1203
|
+
cvv: Accessor<string>;
|
|
1204
|
+
setCvv: (v: string) => void;
|
|
1205
|
+
promoCode: Accessor<string>;
|
|
1206
|
+
setPromoCode: (v: string) => void;
|
|
1207
|
+
promoValidating: Accessor<boolean>;
|
|
1208
|
+
promoError: Accessor<string | null>;
|
|
1209
|
+
promoApplied: Accessor<PromoValidationResponse | null>;
|
|
1210
|
+
applyPromo: () => Promise<void>;
|
|
1211
|
+
clearPromo: () => void;
|
|
1212
|
+
pricing: Accessor<PromoPricing>;
|
|
1213
|
+
surveyResult: SurveyResult;
|
|
1214
|
+
medication: MedicationPricing;
|
|
1215
|
+
submit: () => Promise<void>;
|
|
1216
|
+
}
|
|
1217
|
+
declare function useSubscriptionIntakeFlow(options: UseSubscriptionIntakeFlowOptions): SubscriptionIntakeFlow;
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Shared vocabulary for reading a subscription's status.
|
|
1221
|
+
*
|
|
1222
|
+
* Two DIFFERENT questions get asked about the same field, and conflating them
|
|
1223
|
+
* is how members get stuck:
|
|
1224
|
+
*
|
|
1225
|
+
* - **"Did my create land?"** (`isReconcilable`) — asked after an ambiguous
|
|
1226
|
+
* failure, when we need to know whether the server committed something. Any
|
|
1227
|
+
* non-terminal row counts, including the transient `pending` / `incomplete` /
|
|
1228
|
+
* `trialing` states a just-created subscription passes through, because
|
|
1229
|
+
* matching only `active` would report "nothing happened" and scare the member
|
|
1230
|
+
* into retrying a purchase that actually succeeded. Errs toward "it exists".
|
|
1231
|
+
*
|
|
1232
|
+
* - **"Is this member already subscribed?"** (`isLive`) — asked to BLOCK a new
|
|
1233
|
+
* subscribe on a single-subscription tenant. Must mirror the server's rule
|
|
1234
|
+
* exactly (`LIVE_SUBSCRIPTION_STATUSES` in the-backend's subscriptions route),
|
|
1235
|
+
* or the two disagree in the worst direction: an `incomplete` row from a
|
|
1236
|
+
* declined card would make this client refuse an intake the server would have
|
|
1237
|
+
* accepted, and the member could never subscribe at all. Errs toward "let them
|
|
1238
|
+
* through" — the server has the final say and cannot be bypassed.
|
|
1239
|
+
*/
|
|
1240
|
+
/** Statuses that mean NO live subscription resulted — a terminal, dead record. */
|
|
1241
|
+
declare const TERMINAL_SUBSCRIPTION_STATUSES: ReadonlySet<string>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Statuses the billing engine still acts on (or is waiting on the member to
|
|
1244
|
+
* make actable). Mirrors the-backend `LIVE_SUBSCRIPTION_STATUSES` — keep the two
|
|
1245
|
+
* lists in step.
|
|
1246
|
+
*/
|
|
1247
|
+
declare const LIVE_SUBSCRIPTION_STATUSES: ReadonlySet<string>;
|
|
1248
|
+
/** True when this row proves a create committed (see the module docstring). */
|
|
1249
|
+
declare function isReconcilable(status: string | undefined | null): boolean;
|
|
1250
|
+
/** True when this row means the member currently HOLDS a subscription. */
|
|
1251
|
+
declare function isLive(status: string | undefined | null): boolean;
|
|
1252
|
+
|
|
1253
|
+
interface FunnelTelemetry {
|
|
1254
|
+
/** Forward an engine event (no-op until config resolves; drops if disabled). */
|
|
1255
|
+
onEvent: (e: EmbedEvent) => void;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Create a telemetry forwarder. Events arriving before the tenant's funnel
|
|
1259
|
+
* config resolves are buffered (bounded) and flushed once it does; if the
|
|
1260
|
+
* tenant never enabled telemetry the buffer is discarded.
|
|
1261
|
+
*/
|
|
1262
|
+
declare function createFunnelTelemetry(): FunnelTelemetry;
|
|
1263
|
+
/**
|
|
1264
|
+
* Post the pre-survey email gate's captured address into the session.
|
|
1265
|
+
* Rides the telemetry endpoint (email:captured), so it requires
|
|
1266
|
+
* features.funnelTelemetry on the backend as well as funnelEmailGate.
|
|
1267
|
+
*/
|
|
1268
|
+
declare function captureFunnelEmail(email: string): void;
|
|
1269
|
+
/** True once the visitor has answered (or skipped) the email gate. */
|
|
1270
|
+
declare function emailGateAnswered(): boolean;
|
|
1271
|
+
declare function markEmailGateAnswered(): void;
|
|
1272
|
+
/**
|
|
1273
|
+
* Redeem the `?resume=` token in the URL — at most once per page load, no
|
|
1274
|
+
* matter how many callers ask.
|
|
1275
|
+
*
|
|
1276
|
+
* Two things need the answer and they run in the wrong order: the email gate
|
|
1277
|
+
* decides whether to render BEFORE the survey mounts, and the draft store only
|
|
1278
|
+
* loads once it has. Leaving the exchange inside the draft store meant the gate
|
|
1279
|
+
* couldn't see it, so a patient following a recovery email on a new device was
|
|
1280
|
+
* asked for the address we had already emailed — and, worse, answered it under
|
|
1281
|
+
* a freshly minted session id, forking their row and earning a second reminder
|
|
1282
|
+
* chain. Both now await this, so the session is adopted before anything can be
|
|
1283
|
+
* posted under the wrong one.
|
|
1284
|
+
*
|
|
1285
|
+
* Resolves null instantly when there is no token, so it is safe to call
|
|
1286
|
+
* unconditionally.
|
|
1287
|
+
*/
|
|
1288
|
+
declare function redeemResumeLink(): Promise<ResumedDraft | null>;
|
|
1289
|
+
/** Test seam: forget the redemption so the next call re-reads the URL. */
|
|
1290
|
+
declare function resetResumeRedemption(): void;
|
|
1291
|
+
|
|
1292
|
+
interface CartCaptureOptions {
|
|
1293
|
+
/** Debounce for snapshot writes. Quantity steppers fire fast. */
|
|
1294
|
+
debounceMs?: number;
|
|
1295
|
+
/**
|
|
1296
|
+
* Address for an anonymous shopper, if the site collected one outside the
|
|
1297
|
+
* survey's email gate (e.g. checkout step 1). Logged-in shoppers need
|
|
1298
|
+
* nothing here — the backend reads their email off the token.
|
|
1299
|
+
*/
|
|
1300
|
+
email?: () => string | null | undefined;
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Redeem a `?cart=` token if the URL carries one.
|
|
1304
|
+
*
|
|
1305
|
+
* Exported for sites that want to act on the restore — opening their cart
|
|
1306
|
+
* drawer on arrival, say, or waiting for their catalog first.
|
|
1307
|
+
*
|
|
1308
|
+
* Single-flight: `startCartCapture()` restores on its own, so a site calling
|
|
1309
|
+
* this directly would otherwise race it — both read the token before either
|
|
1310
|
+
* strips it, and the cart gets rebuilt twice. Concurrent callers share one
|
|
1311
|
+
* restore and one result.
|
|
1312
|
+
*/
|
|
1313
|
+
declare function restoreCartFromLink(): Promise<ResumedCart | null>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Start mirroring the cart. Call once at app boot; returns a disposer.
|
|
1316
|
+
*
|
|
1317
|
+
* No-ops for tenants that never opted in (`GET /config/cart`), so it is safe to
|
|
1318
|
+
* call unconditionally from shared site scaffolding.
|
|
1319
|
+
*/
|
|
1320
|
+
declare function startCartCapture(opts?: CartCaptureOptions): () => void;
|
|
1321
|
+
|
|
1322
|
+
export { type AddressErrors, type AddressPair, type AddressValue, type AffiliateConversionsFlow, type AffiliateDownlineFlow, type AffiliateLinksFlow, type AffiliateStatsFlow, type AnswerValue, type CartCaptureOptions, type CartCheckoutFlow, type CartCheckoutOutcome, type CartCheckoutPricing, type CatalogFlow, CatalogProduct, type CategoryColorOpts, type CheckoutFlow, type CheckoutOutcome, type Conversation, DEFAULT_COLOR_PALETTE, type DashboardActivityItem, type DashboardData, type DashboardRxListItem, type DashboardRxStatus, type DashboardSubscription, type DrugResult, type FlatStep, type FulfillmentStage, type FunnelTelemetry, LIVE_SUBSCRIPTION_STATUSES, type MedicationPricing, type MedicationSelectFlow, type MemberPortalData, type MemberPortalRx, type MemberPortalSubscription, type MessagesThread, type PricingBreakdown, type ProductDetailFlow, type PromoPricing, type RefillEvent, type RefillView, type RegisterFlow, type RegisterOutcome, type RequestStatus, type RxRequestStatus, type ShipmentInfo, type SignupFlow, type SignupOutcome, type StageState, type SubscribeFlow, type SubscribeOutcome, type SubscriptionIntakeFlow, type SubscriptionIntakeOutcome, type SurveyFlow, type SurveyOption, type SurveyOutcome, type SurveyQuestion, type SurveyResult, TERMINAL_SUBSCRIPTION_STATUSES, type ThreadMessage, type TrackerRequest, type TrackerRequestStatus, type TrackerSubscription, type TrackerSubscriptionStatus, type TrackerView, type TrackingUrlCarrier, US_STATES, US_STATE_OPTIONS, type UpdatePaymentMethodFlow, type UseAddressPairOptions, type UseCheckoutFlowOptions, type UseMedicationSelectOptions, type UseMessagesThreadOptions, type UseSignupFlowOptions, type UseSubscribeFlowOptions, type UseSubscriptionIntakeFlowOptions, type UseSurveyFlowOptions, type ValidateAddressOptions, type VisibilityCondition, availableStateOptions, availableStates, buildRefillView, buildTrackerView, buildTrackingUrl, captureFunnelEmail, categoryColor, createFunnelTelemetry, emailGateAnswered, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, isLive, isQuestionVisible, isReconcilable, lowestPrice, lowestSalePrice, markEmailGateAnswered, normalizeState, redeemResumeLink, resetResumeRedemption, restoreCartFromLink, startCartCapture, stateAvailabilityNote, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCartCheckoutFlow, useCatalog, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSubscriptionIntakeFlow, useSurveyFlow, useUpdatePaymentMethodFlow, validateAddress };
|