@domnia/shop-sdk-react 0.0.0-stage → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -2
- package/dist/index.d.ts +2459 -0
- package/dist/index.js +39113 -0
- package/dist/styles.css +2 -0
- package/package.json +69 -3
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @domnia/shop-sdk-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components to embed Domnia's booking, checkout and purchase flows.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @domnia/shop-sdk-react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
`react` and `react-dom` ≥ 19 are peer dependencies; everything else (i18n, state, notifications) is
|
|
10
|
+
bundled. Import the compiled stylesheet once — no Tailwind needed on your side:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import '@domnia/shop-sdk-react/styles.css';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { useState } from 'react';
|
|
20
|
+
import { DomniaSdkProvider, CalendarAvailabilityFlowSdk, CheckoutFlowSdk } from '@domnia/shop-sdk-react';
|
|
21
|
+
|
|
22
|
+
export default function BookingPage() {
|
|
23
|
+
const [orderId, setOrderId] = useState<string | null>(null);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<DomniaSdkProvider apiKey={process.env.NEXT_PUBLIC_DOMNIA_SDK_KEY!}>
|
|
27
|
+
{orderId ? (
|
|
28
|
+
<CheckoutFlowSdk orderId={orderId} locale="it" onGoHome={() => setOrderId(null)} />
|
|
29
|
+
) : (
|
|
30
|
+
<CalendarAvailabilityFlowSdk productIds={[2620, 2621]} locale="it" onNavigateToCheckout={setOrderId} />
|
|
31
|
+
)}
|
|
32
|
+
</DomniaSdkProvider>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
| Export | What it is |
|
|
38
|
+
| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
39
|
+
| `DomniaSdkProvider` | Resolves the API key and holds the SDK's state; every component goes under it |
|
|
40
|
+
| `CalendarAvailabilityFlowSdk` | Availability and selection; hands back an `orderId` |
|
|
41
|
+
| `CheckoutFlowSdk` | Checkout of an existing order |
|
|
42
|
+
| `PurchaseFlowSdk` | Selection **and** checkout in one container, no page navigation |
|
|
43
|
+
| `confirmOrder` / `downloadTickets` | For the payment return page, where no component is mounted |
|
|
44
|
+
| `createLocalStorageSdkStore` / `createNoopSdkStore`, `SdkStoreAdapter` | Control or replace the persisted state |
|
|
45
|
+
|
|
46
|
+
The components are marked `'use client'`, so they can be imported from a Next.js Server Component.
|
|
47
|
+
|
|
48
|
+
Full documentation — props, the payment-return page, state persistence — is in the SDK docs of
|
|
49
|
+
your Domnia portal. Not using React? See [`@domnia/shop-sdk`](https://www.npmjs.com/package/@domnia/shop-sdk)
|
|
50
|
+
(script tag / custom elements) and [`@domnia/shop-sdk-vue`](https://www.npmjs.com/package/@domnia/shop-sdk-vue).
|