@tagadapay/headless-sdk 1.7.0 → 1.8.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.
Files changed (81) hide show
  1. package/dist/core/client.d.ts +7 -0
  2. package/dist/core/client.js +2 -0
  3. package/dist/core/index.d.ts +2 -0
  4. package/dist/core/index.js +1 -0
  5. package/dist/core/modules/checkout.d.ts +11 -5
  6. package/dist/core/modules/checkout.js +17 -6
  7. package/dist/core/modules/rx.d.ts +162 -0
  8. package/dist/core/modules/rx.js +46 -0
  9. package/dist/react/hooks/useCheckout.js +11 -2
  10. package/dist/react/hooks/useRx.d.ts +64 -0
  11. package/dist/react/hooks/useRx.js +145 -0
  12. package/dist/react/index.d.ts +2 -0
  13. package/dist/react/index.js +1 -0
  14. package/package.json +4 -10
  15. package/dist/core/client.d.ts.map +0 -1
  16. package/dist/core/client.js.map +0 -1
  17. package/dist/core/errors.d.ts.map +0 -1
  18. package/dist/core/errors.js.map +0 -1
  19. package/dist/core/helpers/autocomplete.d.ts.map +0 -1
  20. package/dist/core/helpers/autocomplete.js.map +0 -1
  21. package/dist/core/helpers/countries.d.ts.map +0 -1
  22. package/dist/core/helpers/countries.js.map +0 -1
  23. package/dist/core/helpers/currency.d.ts.map +0 -1
  24. package/dist/core/helpers/currency.js.map +0 -1
  25. package/dist/core/helpers/index.d.ts.map +0 -1
  26. package/dist/core/helpers/index.js.map +0 -1
  27. package/dist/core/helpers/iso3166.d.ts.map +0 -1
  28. package/dist/core/helpers/iso3166.js.map +0 -1
  29. package/dist/core/http.d.ts.map +0 -1
  30. package/dist/core/http.js.map +0 -1
  31. package/dist/core/index.d.ts.map +0 -1
  32. package/dist/core/index.js.map +0 -1
  33. package/dist/core/modules/catalog.d.ts.map +0 -1
  34. package/dist/core/modules/catalog.js.map +0 -1
  35. package/dist/core/modules/checkout.d.ts.map +0 -1
  36. package/dist/core/modules/checkout.js.map +0 -1
  37. package/dist/core/modules/customer.d.ts.map +0 -1
  38. package/dist/core/modules/customer.js.map +0 -1
  39. package/dist/core/modules/funnel.d.ts.map +0 -1
  40. package/dist/core/modules/funnel.js.map +0 -1
  41. package/dist/core/modules/offers.d.ts.map +0 -1
  42. package/dist/core/modules/offers.js.map +0 -1
  43. package/dist/core/modules/payment.d.ts.map +0 -1
  44. package/dist/core/modules/payment.js.map +0 -1
  45. package/dist/core/types.d.ts.map +0 -1
  46. package/dist/core/types.js.map +0 -1
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/react/hooks/useCatalog.d.ts.map +0 -1
  50. package/dist/react/hooks/useCatalog.js.map +0 -1
  51. package/dist/react/hooks/useCheckout.d.ts.map +0 -1
  52. package/dist/react/hooks/useCheckout.js.map +0 -1
  53. package/dist/react/hooks/useCustomer.d.ts.map +0 -1
  54. package/dist/react/hooks/useCustomer.js.map +0 -1
  55. package/dist/react/hooks/useGoogleAutocomplete.d.ts.map +0 -1
  56. package/dist/react/hooks/useGoogleAutocomplete.js.map +0 -1
  57. package/dist/react/hooks/useISOData.d.ts.map +0 -1
  58. package/dist/react/hooks/useISOData.js.map +0 -1
  59. package/dist/react/hooks/useOffers.d.ts.map +0 -1
  60. package/dist/react/hooks/useOffers.js.map +0 -1
  61. package/dist/react/hooks/usePayment.d.ts.map +0 -1
  62. package/dist/react/hooks/usePayment.js.map +0 -1
  63. package/dist/react/index.d.ts.map +0 -1
  64. package/dist/react/index.js.map +0 -1
  65. package/dist/react/internal/redirectGuard.d.ts.map +0 -1
  66. package/dist/react/internal/redirectGuard.js.map +0 -1
  67. package/dist/react/provider.d.ts.map +0 -1
  68. package/dist/react/provider.js.map +0 -1
  69. package/dist/stripe/StripeExpressButton.d.ts.map +0 -1
  70. package/dist/stripe/StripeExpressButton.js.map +0 -1
  71. package/dist/stripe/StripeExpressCheckout.d.ts.map +0 -1
  72. package/dist/stripe/StripeExpressCheckout.js.map +0 -1
  73. package/dist/stripe/index.d.ts.map +0 -1
  74. package/dist/stripe/index.js.map +0 -1
  75. package/dist/stripe/useStripeExpress.d.ts.map +0 -1
  76. package/dist/stripe/useStripeExpress.js.map +0 -1
  77. package/dist/tagada-headless-react.min.js +0 -8
  78. package/dist/tagada-headless-react.min.js.map +0 -7
  79. package/dist/tagada-headless.js +0 -2229
  80. package/dist/tagada-headless.min.js +0 -8
  81. package/dist/tagada-headless.min.js.map +0 -7
@@ -4,6 +4,7 @@ import { OffersModule } from './modules/offers.js';
4
4
  import { CustomerModule } from './modules/customer.js';
5
5
  import { CatalogModule } from './modules/catalog.js';
6
6
  import { FunnelModule } from './modules/funnel.js';
7
+ import { RxModule } from './modules/rx.js';
7
8
  import type { HeadlessConfig } from './types.js';
8
9
  /**
9
10
  * Main entry point for the TagadaPay Headless SDK.
@@ -38,6 +39,12 @@ export declare class HeadlessClient {
38
39
  * Requires `config.accountId`.
39
40
  */
40
41
  readonly funnel: FunnelModule;
42
+ /**
43
+ * Tagada Rx -- clinical case submission and lookup for telehealth
44
+ * storefronts. Active only on stores whose merchant has paid the
45
+ * Tagada Rx setup fee and configured a clinical network.
46
+ */
47
+ readonly rx: RxModule;
41
48
  constructor(config: HeadlessConfig);
42
49
  /** Manually set the session token (e.g. from URL params on page load). */
43
50
  setSessionToken(token: string): void;
@@ -5,6 +5,7 @@ import { OffersModule } from './modules/offers.js';
5
5
  import { CustomerModule } from './modules/customer.js';
6
6
  import { CatalogModule } from './modules/catalog.js';
7
7
  import { FunnelModule } from './modules/funnel.js';
8
+ import { RxModule } from './modules/rx.js';
8
9
  /**
9
10
  * Main entry point for the TagadaPay Headless SDK.
10
11
  *
@@ -42,6 +43,7 @@ export class HeadlessClient {
42
43
  this.customer = new CustomerModule(this.http, this.config.storeId);
43
44
  this.catalog = new CatalogModule(this.http, this.config.storeId);
44
45
  this.funnel = new FunnelModule(this.http, this.config.storeId, this.checkout, this.config.accountId);
46
+ this.rx = new RxModule(this.http);
45
47
  }
46
48
  /** Manually set the session token (e.g. from URL params on page load). */
47
49
  setSessionToken(token) {
@@ -5,6 +5,8 @@ export { OffersModule } from './modules/offers.js';
5
5
  export { CustomerModule } from './modules/customer.js';
6
6
  export { CatalogModule } from './modules/catalog.js';
7
7
  export { FunnelModule } from './modules/funnel.js';
8
+ export { RxModule } from './modules/rx.js';
9
+ export type { RxCaseStatus, RxRequiredForProduct, RxStorefrontPatient, RxIntakeAnswer, RxClinicalQuestion, RxQuestionsForProduct, RxSubmitCaseInput, RxSubmitCaseResult, RxCaseSummary, } from './modules/rx.js';
8
10
  export { HttpClient } from './http.js';
9
11
  export { TagadaError, TagadaAuthError, TagadaValidationError, TagadaNotFoundError, TagadaRateLimitError, TagadaPaymentError, TagadaNetworkError, } from './errors.js';
10
12
  export { GoogleAutocompleteCore, loadGoogleMapsScript, ISODataCore, AVAILABLE_LANGUAGES, CurrencyUtils, formatMoney, ensureGeoDataLoaded, getCountries, getStatesForCountry, isLanguageLoaded, } from './helpers/index.js';
@@ -5,6 +5,7 @@ export { OffersModule } from './modules/offers.js';
5
5
  export { CustomerModule } from './modules/customer.js';
6
6
  export { CatalogModule } from './modules/catalog.js';
7
7
  export { FunnelModule } from './modules/funnel.js';
8
+ export { RxModule } from './modules/rx.js';
8
9
  export { HttpClient } from './http.js';
9
10
  export { TagadaError, TagadaAuthError, TagadaValidationError, TagadaNotFoundError, TagadaRateLimitError, TagadaPaymentError, TagadaNetworkError, } from './errors.js';
10
11
  // Helpers: Google Autocomplete, ISO countries/regions, currency formatting
@@ -159,13 +159,19 @@ export declare class CheckoutModule {
159
159
  sessionToken: string;
160
160
  } | null;
161
161
  /**
162
- * Replace the cart items for an existing session.
162
+ * Add or update cart items on an existing session (upsert by product).
163
+ *
164
+ * Sends each item as `lineItems` to `POST /checkout-sessions/:id/line-items`.
165
+ * The endpoint UPSERTs by product: it adds new products and updates the
166
+ * variant/quantity of products already in the cart, but it does NOT remove
167
+ * products omitted from `items`, and an empty array is a no-op (it does not
168
+ * clear the cart). Each `quantity` must be >= 1 — removal is not supported by
169
+ * this endpoint.
163
170
  *
164
171
  * Returns a server-side mutation summary (counts of created/updated rows).
165
- * It does NOT return the updated `CheckoutSession` — the underlying
166
- * `POST /checkout-sessions/:id/line-items` endpoint never has and the
167
- * previous typing was a lie that quietly assigned `{ success, updated, ... }`
168
- * into a `CheckoutSession` slot in `useCheckout`.
172
+ * It does NOT return the updated `CheckoutSession` — the underlying endpoint
173
+ * never has and the previous typing was a lie that quietly assigned
174
+ * `{ success, updated, ... }` into a `CheckoutSession` slot in `useCheckout`.
169
175
  *
170
176
  * Call `loadSession()` after this if you need the refreshed session
171
177
  * (the React `useCheckout` hook does this for you).
@@ -186,19 +186,30 @@ export class CheckoutModule {
186
186
  return { checkoutToken, sessionToken };
187
187
  }
188
188
  /**
189
- * Replace the cart items for an existing session.
189
+ * Add or update cart items on an existing session (upsert by product).
190
+ *
191
+ * Sends each item as `lineItems` to `POST /checkout-sessions/:id/line-items`.
192
+ * The endpoint UPSERTs by product: it adds new products and updates the
193
+ * variant/quantity of products already in the cart, but it does NOT remove
194
+ * products omitted from `items`, and an empty array is a no-op (it does not
195
+ * clear the cart). Each `quantity` must be >= 1 — removal is not supported by
196
+ * this endpoint.
190
197
  *
191
198
  * Returns a server-side mutation summary (counts of created/updated rows).
192
- * It does NOT return the updated `CheckoutSession` — the underlying
193
- * `POST /checkout-sessions/:id/line-items` endpoint never has and the
194
- * previous typing was a lie that quietly assigned `{ success, updated, ... }`
195
- * into a `CheckoutSession` slot in `useCheckout`.
199
+ * It does NOT return the updated `CheckoutSession` — the underlying endpoint
200
+ * never has and the previous typing was a lie that quietly assigned
201
+ * `{ success, updated, ... }` into a `CheckoutSession` slot in `useCheckout`.
196
202
  *
197
203
  * Call `loadSession()` after this if you need the refreshed session
198
204
  * (the React `useCheckout` hook does this for you).
199
205
  */
200
206
  async updateCart(sessionId, items) {
201
- return this.http.post(`/api/v1/checkout-sessions/${sessionId}/line-items`, { items }, { token: this.sessionToken });
207
+ const lineItems = items.map((i) => ({
208
+ variantId: i.variantId,
209
+ priceId: i.priceId,
210
+ quantity: i.quantity,
211
+ }));
212
+ return this.http.post(`/api/v1/checkout-sessions/${sessionId}/line-items`, { lineItems }, { token: this.sessionToken });
202
213
  }
203
214
  /**
204
215
  * Update customer identity (email, name, phone).
@@ -0,0 +1,162 @@
1
+ import type { HttpClient } from '../http.js';
2
+ /**
3
+ * Tagada Rx — storefront module.
4
+ *
5
+ * Drives the post-checkout clinical case flow from the browser:
6
+ * 1. Ask the API whether a product needs an Rx case.
7
+ * 2. After the order is paid, submit the intake (patient + answers)
8
+ * with the `(orderId, checkoutToken)` ownership proof.
9
+ * 3. Poll the case status from the thank-you page.
10
+ *
11
+ * PHI handling: the `patient` and `intakeAnswers` payloads are sent
12
+ * straight to the Tagada API which forwards them to the clinical
13
+ * network (e.g. MDI). Tagada NEVER persists PHI in its database.
14
+ *
15
+ * Auth model: there is no API key. Each route authorizes per-resource
16
+ * (productId is public; case routes require the checkoutToken the
17
+ * storefront already received when it bootstrapped the checkout).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const { required } = await tagada.rx.isRequiredForProduct(productId);
22
+ * if (required) {
23
+ * const intake = await collectIntakeFromUser();
24
+ * const res = await tagada.rx.submitCase({
25
+ * orderId, checkoutToken, productId,
26
+ * patient, intakeAnswers: intake,
27
+ * });
28
+ * router.push(`/thank-you?rxCase=${res.rxCaseId}`);
29
+ * }
30
+ * ```
31
+ */
32
+ export type RxCaseStatus = 'requested' | 'submitted' | 'in_review' | 'approved' | 'shipped' | 'delivered' | 'declined' | 'cancelled' | 'error';
33
+ export interface RxRequiredForProduct {
34
+ required: boolean;
35
+ clinicalNetworkId: string | null;
36
+ externalOfferingId: string | null;
37
+ requiresLabs: boolean;
38
+ requiresIdVerification: boolean;
39
+ isDeaControlled: boolean;
40
+ }
41
+ export interface RxStorefrontPatient {
42
+ firstName: string;
43
+ lastName: string;
44
+ email: string;
45
+ phone?: string | null;
46
+ /** ISO date YYYY-MM-DD. */
47
+ dateOfBirth: string;
48
+ sexAtBirth: 'male' | 'female' | 'unspecified';
49
+ address: {
50
+ line1: string;
51
+ line2?: string;
52
+ city: string;
53
+ state: string;
54
+ zip: string;
55
+ /** ISO 3166-1 alpha-2 country code. */
56
+ country: string;
57
+ };
58
+ /** Patient-level clinical fields (MDI Full API / Judd). */
59
+ weight?: number | string;
60
+ height?: number | string;
61
+ allergies?: string;
62
+ pregnancy?: boolean | string;
63
+ currentMedications?: string;
64
+ medicalConditions?: string;
65
+ specialNecessities?: string;
66
+ driverLicenseId?: string;
67
+ introVideoId?: string;
68
+ }
69
+ export interface RxIntakeAnswer {
70
+ questionId: string;
71
+ value: string | number | boolean | string[];
72
+ comment?: string;
73
+ /** Exact question text shown to the patient (MDI case_questions.question). */
74
+ question?: string;
75
+ /** MDI answer type: string | number | boolean. */
76
+ type?: string;
77
+ important?: boolean;
78
+ isCritical?: boolean;
79
+ displayInPdf?: boolean;
80
+ description?: string;
81
+ label?: string;
82
+ metadata?: string;
83
+ /** Options presented for MCQ questions. */
84
+ displayedOptions?: string[];
85
+ }
86
+ export interface RxClinicalQuestion {
87
+ externalQuestionId: string;
88
+ title: string;
89
+ description: string | null;
90
+ placeholder: string | null;
91
+ type: string;
92
+ required: boolean;
93
+ order: number;
94
+ options: {
95
+ value: string;
96
+ label: string;
97
+ }[];
98
+ }
99
+ export interface RxQuestionsForProduct {
100
+ required: boolean;
101
+ externalQuestionnaireId: string | null;
102
+ questions: RxClinicalQuestion[];
103
+ }
104
+ export interface RxSubmitCaseInput {
105
+ orderId: string;
106
+ checkoutToken: string;
107
+ productId: string;
108
+ patient: RxStorefrontPatient;
109
+ intakeAnswers: RxIntakeAnswer[];
110
+ preferredPharmacyId?: string;
111
+ }
112
+ export interface RxSubmitCaseResult {
113
+ rxCaseId: string;
114
+ externalCaseId: string;
115
+ status: 'submitted' | 'error';
116
+ accrualAmountMinor: number;
117
+ accrualCurrency: string;
118
+ }
119
+ export interface RxCaseSummary {
120
+ id: string;
121
+ status: RxCaseStatus;
122
+ externalCaseId: string | null;
123
+ lastShipmentShippedAt: string | null;
124
+ createdAt: string;
125
+ }
126
+ export declare class RxModule {
127
+ private readonly http;
128
+ constructor(http: HttpClient);
129
+ /**
130
+ * Check whether a product requires an Rx case. Storefronts call this
131
+ * before rendering the intake form so they only ask the patient
132
+ * questions when really necessary.
133
+ *
134
+ * Read-only / public — does not require any ownership proof.
135
+ */
136
+ isRequiredForProduct(productId: string, opts?: {
137
+ clinicalNetworkId?: string;
138
+ }): Promise<RxRequiredForProduct>;
139
+ /**
140
+ * Look up the Rx cases attached to an order. Storefronts poll this
141
+ * on the thank-you page to render "Your prescription is being
142
+ * reviewed" → "Shipped" transitions.
143
+ */
144
+ getCasesForOrder(input: {
145
+ orderId: string;
146
+ checkoutToken: string;
147
+ }): Promise<{
148
+ cases: RxCaseSummary[];
149
+ }>;
150
+ /**
151
+ * Submit a fresh clinical case for a freshly-paid order. PHI is
152
+ * forwarded to the clinical network and never persisted on
153
+ * Tagada-side rows.
154
+ */
155
+ submitCase(input: RxSubmitCaseInput): Promise<RxSubmitCaseResult>;
156
+ /**
157
+ * Fetch the network-authored intake questions for a product.
158
+ * Empty `questions` means the storefront should use its local quiz.
159
+ */
160
+ getQuestionsForProduct(productId: string): Promise<RxQuestionsForProduct>;
161
+ }
162
+ //# sourceMappingURL=rx.d.ts.map
@@ -0,0 +1,46 @@
1
+ export class RxModule {
2
+ constructor(http) {
3
+ this.http = http;
4
+ }
5
+ /**
6
+ * Check whether a product requires an Rx case. Storefronts call this
7
+ * before rendering the intake form so they only ask the patient
8
+ * questions when really necessary.
9
+ *
10
+ * Read-only / public — does not require any ownership proof.
11
+ */
12
+ async isRequiredForProduct(productId, opts) {
13
+ return this.http.get('/api/public/v1/rx/required-for-product', {
14
+ params: {
15
+ productId,
16
+ clinicalNetworkId: opts?.clinicalNetworkId,
17
+ },
18
+ });
19
+ }
20
+ /**
21
+ * Look up the Rx cases attached to an order. Storefronts poll this
22
+ * on the thank-you page to render "Your prescription is being
23
+ * reviewed" → "Shipped" transitions.
24
+ */
25
+ async getCasesForOrder(input) {
26
+ return this.http.post('/api/public/v1/rx/cases/lookup', input);
27
+ }
28
+ /**
29
+ * Submit a fresh clinical case for a freshly-paid order. PHI is
30
+ * forwarded to the clinical network and never persisted on
31
+ * Tagada-side rows.
32
+ */
33
+ async submitCase(input) {
34
+ return this.http.post('/api/public/v1/rx/cases/submit', input);
35
+ }
36
+ /**
37
+ * Fetch the network-authored intake questions for a product.
38
+ * Empty `questions` means the storefront should use its local quiz.
39
+ */
40
+ async getQuestionsForProduct(productId) {
41
+ return this.http.get('/api/public/v1/rx/questions-for-product', {
42
+ params: { productId },
43
+ });
44
+ }
45
+ }
46
+ //# sourceMappingURL=rx.js.map
@@ -61,8 +61,17 @@ export function useCheckout(checkoutToken, sessionToken) {
61
61
  // We previously assigned that result into `setSession`, which silently
62
62
  // replaced the session with `{ success, updated, created, total }`.
63
63
  // Mirror the same pattern as `updateAddress`: mutate, then reload.
64
- await client.checkout.updateCart(session.id, items);
65
- await loadSession();
64
+ setIsLoading(true);
65
+ try {
66
+ await client.checkout.updateCart(session.id, items);
67
+ await loadSession();
68
+ }
69
+ catch (err) {
70
+ setError(err instanceof Error ? err : new Error(String(err)));
71
+ }
72
+ finally {
73
+ setIsLoading(false);
74
+ }
66
75
  }, [client, session, loadSession]);
67
76
  const updateCustomer = useCallback(async (customer) => {
68
77
  if (!session)
@@ -0,0 +1,64 @@
1
+ import type { RxCaseSummary, RxQuestionsForProduct, RxRequiredForProduct, RxSubmitCaseInput, RxSubmitCaseResult } from '../../core/modules/rx.js';
2
+ export interface UseRxReturn {
3
+ /** Cases attached to the current order (populated by `pollOrder`). */
4
+ cases: RxCaseSummary[];
5
+ /** Result of the last `submitCase` call, kept for the thank-you page. */
6
+ lastSubmission: RxSubmitCaseResult | null;
7
+ /** True while ANY rx call is in flight. */
8
+ isLoading: boolean;
9
+ error: Error | null;
10
+ /**
11
+ * Ask whether a product needs an Rx case before submitting payment.
12
+ * Storefronts call this at product-page load to decide whether to
13
+ * render the intake step.
14
+ */
15
+ isRequiredForProduct: (productId: string, opts?: {
16
+ clinicalNetworkId?: string;
17
+ }) => Promise<RxRequiredForProduct>;
18
+ /** Fetch network-authored intake questions for a product. */
19
+ getQuestionsForProduct: (productId: string) => Promise<RxQuestionsForProduct>;
20
+ /**
21
+ * Submit a fresh case after the order is paid. The result is also
22
+ * stored in `lastSubmission` so the thank-you page can read it.
23
+ */
24
+ submitCase: (input: RxSubmitCaseInput) => Promise<RxSubmitCaseResult>;
25
+ /**
26
+ * Fetch the public summary of every case attached to a paid order.
27
+ * Useful for the thank-you page or order history.
28
+ */
29
+ fetchCasesForOrder: (input: {
30
+ orderId: string;
31
+ checkoutToken: string;
32
+ }) => Promise<RxCaseSummary[]>;
33
+ /**
34
+ * Auto-poll the cases for an order until they all reach a terminal
35
+ * status (approved / shipped / delivered / declined / cancelled /
36
+ * error). Returns a `stop()` function to cancel the polling.
37
+ */
38
+ pollOrder: (input: {
39
+ orderId: string;
40
+ checkoutToken: string;
41
+ }, opts?: {
42
+ intervalMs?: number;
43
+ onUpdate?: (cases: RxCaseSummary[]) => void;
44
+ }) => () => void;
45
+ }
46
+ /**
47
+ * React hook for Tagada Rx storefronts.
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * const { isRequiredForProduct, submitCase, lastSubmission, pollOrder } = useRx();
52
+ *
53
+ * useEffect(() => {
54
+ * if (orderId && checkoutToken) {
55
+ * const stop = pollOrder({ orderId, checkoutToken }, {
56
+ * onUpdate: (cases) => setCases(cases),
57
+ * });
58
+ * return stop;
59
+ * }
60
+ * }, [orderId, checkoutToken, pollOrder]);
61
+ * ```
62
+ */
63
+ export declare function useRx(): UseRxReturn;
64
+ //# sourceMappingURL=useRx.d.ts.map
@@ -0,0 +1,145 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { useHeadlessClient } from '../provider.js';
3
+ const TERMINAL_STATUSES = new Set([
4
+ 'approved',
5
+ 'shipped',
6
+ 'delivered',
7
+ 'declined',
8
+ 'cancelled',
9
+ 'error',
10
+ ]);
11
+ /**
12
+ * React hook for Tagada Rx storefronts.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const { isRequiredForProduct, submitCase, lastSubmission, pollOrder } = useRx();
17
+ *
18
+ * useEffect(() => {
19
+ * if (orderId && checkoutToken) {
20
+ * const stop = pollOrder({ orderId, checkoutToken }, {
21
+ * onUpdate: (cases) => setCases(cases),
22
+ * });
23
+ * return stop;
24
+ * }
25
+ * }, [orderId, checkoutToken, pollOrder]);
26
+ * ```
27
+ */
28
+ export function useRx() {
29
+ const client = useHeadlessClient();
30
+ const [cases, setCases] = useState([]);
31
+ const [lastSubmission, setLastSubmission] = useState(null);
32
+ const [isLoading, setIsLoading] = useState(false);
33
+ const [error, setError] = useState(null);
34
+ const pollTimerRef = useRef(null);
35
+ useEffect(() => {
36
+ return () => {
37
+ if (pollTimerRef.current)
38
+ clearInterval(pollTimerRef.current);
39
+ };
40
+ }, []);
41
+ const isRequiredForProduct = useCallback(async (productId, opts) => {
42
+ setIsLoading(true);
43
+ setError(null);
44
+ try {
45
+ return await client.rx.isRequiredForProduct(productId, opts);
46
+ }
47
+ catch (err) {
48
+ const e = err instanceof Error ? err : new Error(String(err));
49
+ setError(e);
50
+ throw e;
51
+ }
52
+ finally {
53
+ setIsLoading(false);
54
+ }
55
+ }, [client]);
56
+ const getQuestionsForProduct = useCallback(async (productId) => {
57
+ setIsLoading(true);
58
+ setError(null);
59
+ try {
60
+ return await client.rx.getQuestionsForProduct(productId);
61
+ }
62
+ catch (err) {
63
+ const e = err instanceof Error ? err : new Error(String(err));
64
+ setError(e);
65
+ throw e;
66
+ }
67
+ finally {
68
+ setIsLoading(false);
69
+ }
70
+ }, [client]);
71
+ const submitCase = useCallback(async (input) => {
72
+ setIsLoading(true);
73
+ setError(null);
74
+ try {
75
+ const res = await client.rx.submitCase(input);
76
+ setLastSubmission(res);
77
+ return res;
78
+ }
79
+ catch (err) {
80
+ const e = err instanceof Error ? err : new Error(String(err));
81
+ setError(e);
82
+ throw e;
83
+ }
84
+ finally {
85
+ setIsLoading(false);
86
+ }
87
+ }, [client]);
88
+ const fetchCasesForOrder = useCallback(async (input) => {
89
+ setIsLoading(true);
90
+ setError(null);
91
+ try {
92
+ const res = await client.rx.getCasesForOrder(input);
93
+ setCases(res.cases);
94
+ return res.cases;
95
+ }
96
+ catch (err) {
97
+ const e = err instanceof Error ? err : new Error(String(err));
98
+ setError(e);
99
+ throw e;
100
+ }
101
+ finally {
102
+ setIsLoading(false);
103
+ }
104
+ }, [client]);
105
+ const pollOrder = useCallback(({ orderId, checkoutToken }, opts) => {
106
+ if (pollTimerRef.current)
107
+ clearInterval(pollTimerRef.current);
108
+ const intervalMs = opts?.intervalMs ?? 5000;
109
+ const tick = async () => {
110
+ try {
111
+ const res = await client.rx.getCasesForOrder({ orderId, checkoutToken });
112
+ setCases(res.cases);
113
+ opts?.onUpdate?.(res.cases);
114
+ if (res.cases.length > 0 && res.cases.every((c) => TERMINAL_STATUSES.has(c.status))) {
115
+ if (pollTimerRef.current)
116
+ clearInterval(pollTimerRef.current);
117
+ pollTimerRef.current = null;
118
+ }
119
+ }
120
+ catch (err) {
121
+ const e = err instanceof Error ? err : new Error(String(err));
122
+ setError(e);
123
+ }
124
+ };
125
+ void tick();
126
+ pollTimerRef.current = setInterval(tick, intervalMs);
127
+ return () => {
128
+ if (pollTimerRef.current)
129
+ clearInterval(pollTimerRef.current);
130
+ pollTimerRef.current = null;
131
+ };
132
+ }, [client]);
133
+ return {
134
+ cases,
135
+ lastSubmission,
136
+ isLoading,
137
+ error,
138
+ isRequiredForProduct,
139
+ getQuestionsForProduct,
140
+ submitCase,
141
+ fetchCasesForOrder,
142
+ pollOrder,
143
+ };
144
+ }
145
+ //# sourceMappingURL=useRx.js.map
@@ -10,6 +10,8 @@ export { useCustomer } from './hooks/useCustomer.js';
10
10
  export type { UseCustomerReturn } from './hooks/useCustomer.js';
11
11
  export { useCatalog } from './hooks/useCatalog.js';
12
12
  export type { UseCatalogReturn } from './hooks/useCatalog.js';
13
+ export { useRx } from './hooks/useRx.js';
14
+ export type { UseRxReturn } from './hooks/useRx.js';
13
15
  export { useGoogleAutocomplete } from './hooks/useGoogleAutocomplete.js';
14
16
  export type { UseGoogleAutocompleteOptions, UseGoogleAutocompleteReturn } from './hooks/useGoogleAutocomplete.js';
15
17
  export { useISOData, useCountryOptions, useRegionOptions } from './hooks/useISOData.js';
@@ -4,6 +4,7 @@ export { usePayment } from './hooks/usePayment.js';
4
4
  export { useOffers } from './hooks/useOffers.js';
5
5
  export { useCustomer } from './hooks/useCustomer.js';
6
6
  export { useCatalog } from './hooks/useCatalog.js';
7
+ export { useRx } from './hooks/useRx.js';
7
8
  // Helpers hooks
8
9
  export { useGoogleAutocomplete } from './hooks/useGoogleAutocomplete.js';
9
10
  export { useISOData, useCountryOptions, useRegionOptions } from './hooks/useISOData.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/headless-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Headless SDK for using TagadaPay as a checkout, offers, and CRM backend from any external website",
5
5
  "type": "module",
6
6
  "main": "dist/core/index.js",
@@ -18,14 +18,7 @@
18
18
  }
19
19
  },
20
20
  "scripts": {
21
- "build": "tsc && node build-cdn.js",
22
- "build:types": "tsc",
23
- "build:cdn": "node build-cdn.js",
24
- "clean": "rm -rf dist",
25
- "dev": "tsc --watch",
26
- "lint": "echo \"No linting configured\"",
27
- "test": "echo \"No tests yet\" && exit 0",
28
- "prepublishOnly": "npm run clean && npm run build"
21
+ "prepublishOnly": "echo skip"
29
22
  },
30
23
  "keywords": [
31
24
  "tagadapay",
@@ -45,7 +38,8 @@
45
38
  "@types/node": "^18.0.0",
46
39
  "@types/react": "^19",
47
40
  "esbuild": "^0.20.0",
48
- "typescript": "^5.0.0"
41
+ "typescript": "^5.0.0",
42
+ "vitest": "^3.2.4"
49
43
  },
50
44
  "peerDependencies": {
51
45
  "@stripe/stripe-js": "^7.0.0 || ^8.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,aAAa,CAAC,CAAC,GAAG,cAAc,CAAC;IAE5F,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAElC,4EAA4E;IAC5E,OAAO,CAAC,aAAa,CAAqB;IAE1C,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAElC,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAEhC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAElC,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAEhC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,cAAc;IAmClC,0EAA0E;IAC1E,eAAe,CAAC,KAAK,EAAE,MAAM;CAG9B;AAED;;;;;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