@msm-platform/customer-react 0.4.2 → 0.4.4
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/CHANGELOG.md +26 -0
- package/README.md +32 -20
- package/dist/account.d.ts +3 -0
- package/dist/booking-flow.d.ts +20 -0
- package/dist/booking.d.ts +9 -0
- package/dist/client.d.ts +7 -3
- package/dist/context.d.ts +2 -0
- package/dist/formats.d.ts +17 -0
- package/dist/i18n.d.ts +90 -20
- package/dist/i18n.is.d.ts +2 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +2337 -1079
- package/dist/pay.d.ts +125 -0
- package/dist/payment-tab.d.ts +22 -0
- package/dist/portal.d.ts +8 -2
- package/dist/refusals.d.ts +14 -0
- package/dist/screens/business.d.ts +48 -1
- package/dist/screens/shop.d.ts +14 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/session.d.ts +24 -0
- package/dist/server.js +139 -106
- package/dist/sign-in-standalone.d.ts +3 -0
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,32 @@ All notable changes to `@msm-platform/customer-react`. The format follows [Keep
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.4.4] - 2026-11-24
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `MsmPayButtons` pays for a reservation your page already holds, such as from your own class panel: it shows a "Pay with …" button for each of the business's online payment methods in its order, sends the customer to the provider's page (or a new tab with a cookieless server half) and back, and calls `onResult` once with `{ status: "confirmed", bookingId }`, `{ status: "released" }` or `{ status: "unconfirmed_paid" }`. It takes `basePath`, `businessId`, `reservationId`, `onResult` and an optional `onLeave`, called before the page goes to the provider. Back on your page with `msmCheckout` in the query, show the same reservation's `MsmPayButtons` again and it finishes. `useMsmPayment` is the hook behind it, for drawing the buttons yourself. `MsmBooking` and `MsmCustomer` pay through the same piece.
|
|
12
|
+
- `MsmCustomer`, `MsmAccount`, `MsmBooking`, `MsmSignIn` and `MsmPayButtons` take `locale`, `"en"` (the default) or `"is"`: with `"is"` every screen, including the phone field's country picker and its messages, speaks Icelandic, and dates, times and money format in Icelandic (`12.400 kr.`, `25. nóv. 2026`). Changing the prop re-renders the open screen in the new language and keeps its state. The `MsmLocale` type names the two.
|
|
13
|
+
|
|
14
|
+
## [0.4.3] - 2026-11-23
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `MsmBooking` offers "See all times" on its resource and times steps too, opening every time filtered by the event type and the resource chosen so far (by the type only from the resource step or after Anyone), and the customer can clear either filter. "Back" returns to the step it was opened from. `MsmBookingSelection` gains an optional `allFrom`, `{ eventTypeId, resourceId? }`, which `onChange` reports with `all` and which you feed back as a prop; hosts that keep the selection in their URL should keep it too, or Back returns to the event types.
|
|
19
|
+
- `createCustomerHandler` takes `cookieless: true` for screens in a cross-site iframe, where browsers block or partition cookies: sign-in, a new customer's registration and booking work without the two `__Host-` cookies. The handler hands the screens the encrypted session and pending registration in the `X-MSM-Session` and `X-MSM-Registration` headers, the screens keep them in the page's memory only and send them back, each opens only on requests the browser marks as from the page it was issued to (`Origin`, `Sec-Fetch-Site`), and a request the browser marks as another site's, or a write without `Origin`, is refused with 403 `CrossOriginRefused`. The engine token stays on your server. Mount it as its own handler on its own `basePath`; handlers with cookies work as before.
|
|
20
|
+
- The passes screen lists the memberships and passes the partner's businesses sell online, each with its price and terms and a "Buy with …" button for each way the business takes payments. It sends the customer to the provider's page and, back on the page they left, says whether the payment was received. The provider's receipt is the customer's; the screen shows none. The return adds `msmPurchase` to your page's query, which the screen removes, and `MsmCustomer` and `MsmAccount` open the passes screen for it. It needs the engine release with product checkouts and `@msm-platform/customer-sdk` with `startProductCheckout`.
|
|
21
|
+
- Booking a service with a price shows the price and what is paid now, then a "Pay with …" button for each way the business takes payments. It sends the customer to the provider's page and, back on the page they left, shows the booking once the payment is confirmed, or says the payment didn't go through or arrived after the time was taken. A service with no advance books with "Confirm booking". `MsmBooking` comes back to the same time after the provider's page: the return adds `msmCheckout` to your page's query, which it removes, and calls `onChange` with the selection the customer left from. `MsmCustomer` comes back to the same time too and removes `msmCheckout` the same way. It needs the engine release with paid bookings and `@msm-platform/customer-sdk` with `startCheckout`.
|
|
22
|
+
- `MsmBooking` takes `autoFocus={false}` for a flow placed in a page rather than a dialog: it opens without taking the page's focus or scrolling the page to it, and later steps still take focus. Without the prop it focuses its first field as before.
|
|
23
|
+
- With a cookieless server half, whose session lives only in the page, "Pay with …" and "Buy with …" open the provider's page in a new tab, and the booking or passes screen stays signed in and shows the result as soon as the payment arrives ("Finish paying in the new tab…", with an "Open the payment page" link if the browser refused the tab). The provider sends that tab back to your page with `msmTab` in the query, where the screens only say to go back, and close the tab when the browser lets them. Screens on a server half with cookies still go to the provider's page and back as before.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- The "Pay with …" and "Buy with …" buttons are the business's payment methods, in the order it chose and with the label it gave each, such as "Pay with Card", instead of one per provider named Teya or Blikk. It needs the engine release with payment methods and `@msm-platform/customer-sdk` with `listOnlinePaymentMethods`.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Notices (such as "You're booked."), badges (such as "Cancelled"), the cancellation box, warnings and errors take their colours from the nine `--msm-customer-*` properties instead of fixed light colours, so they are readable on a dark theme. With no properties set they look almost as before.
|
|
32
|
+
|
|
7
33
|
## [0.4.2] - 2026-11-20
|
|
8
34
|
|
|
9
35
|
### Added
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ It depends on `@msm-platform/customer-sdk`, which the server half calls the engi
|
|
|
10
10
|
|
|
11
11
|
## Public API
|
|
12
12
|
|
|
13
|
-
What the changelog treats as breaking to rename or remove: the exports of `.` and `./server` and the stylesheet `./style.css`; the props below of `MsmCustomer`, `MsmBooking`, `MsmAccount` and `
|
|
13
|
+
What the changelog treats as breaking to rename or remove: the exports of `.` and `./server` and the stylesheet `./style.css`; the props below of `MsmCustomer`, `MsmBooking`, `MsmAccount`, `MsmSignIn` and `MsmPayButtons`, and the statuses `MsmPayButtons` reports, including `brand: {name, logo}`, `botCheck: {provider: "turnstile", siteKey}` and the `screen` values `businesses`, `{businessId}`, `{businessId, eventTypeId}`, `bookings`, `passes` and `details` (a new value is additive; renaming or removing one, or changing the default `businesses`, is breaking); the nine `--msm-customer-*` properties ([Theming](#theming)); the server half's options and routes, including the `botCheckToken` field; and `readCustomerSession`. Another bot-check provider would be an additive member of `botCheck`'s union; renaming `"turnstile"` or `botCheckToken` is breaking. The server half's `clientIp` is required in every environment, and `createCustomerHandler` throws without it.
|
|
14
14
|
|
|
15
15
|
## The screens
|
|
16
16
|
|
|
@@ -47,30 +47,33 @@ The built entry starts with `"use client"`, so a Next.js server component can im
|
|
|
47
47
|
|
|
48
48
|
## Components for your own pages
|
|
49
49
|
|
|
50
|
-
Besides `MsmCustomer`, three components show one part of the screens on your own pages, such as in a modal or overlay your site draws: the package ships no dialog, focus trap or scroll lock. Each takes `basePath`, `brand` and `botCheck` as `MsmCustomer` does, renders its own `.msm-customer` root, and moves focus to its first field when it mounts. Components on the same `basePath` share one sign-in: signing in or out in one shows in all of them, and each optional `onSessionChange(signedIn)` hears every sign-in and sign-out after the first session check, including a session the server half ended, so your header can refresh.
|
|
50
|
+
Besides `MsmCustomer`, three components show one part of the screens on your own pages, such as in a modal or overlay your site draws, and `MsmPayButtons` pays for a time your page holds: the package ships no dialog, focus trap or scroll lock. Each of the three takes `basePath`, `brand` and `botCheck` as `MsmCustomer` does, renders its own `.msm-customer` root, and moves focus to its first field when it mounts. Components on the same `basePath` share one sign-in: signing in or out in one shows in all of them, and each optional `onSessionChange(signedIn)` hears every sign-in and sign-out after the first session check, including a session the server half ended, so your header can refresh.
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
53
|
import {
|
|
54
54
|
MsmAccount,
|
|
55
55
|
MsmBooking,
|
|
56
|
+
MsmPayButtons,
|
|
56
57
|
MsmSignIn,
|
|
57
58
|
} from "@msm-platform/customer-react";
|
|
58
59
|
```
|
|
59
60
|
|
|
60
61
|
### `MsmBooking`
|
|
61
62
|
|
|
62
|
-
The booking flow for one business, in steps: the customer chooses an event type; then who provides it, with Anyone first, when two or more resources can; then a time.
|
|
63
|
-
|
|
64
|
-
| Prop | Meaning
|
|
65
|
-
| ------------- |
|
|
66
|
-
| `businessId` | The business.
|
|
67
|
-
| `eventTypeId` | Optional: opens past the first step on this event type, or filters See all times by it.
|
|
68
|
-
| `resourceId` | Optional: a resource that provides the event type, or `"any"` for anyone; with `all`, filters every time by it.
|
|
69
|
-
| `all` | Optional `true`: See all times.
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
63
|
+
The booking flow for one business, in steps: the customer chooses an event type; then who provides it, with Anyone first, when two or more resources can; then a time. See all times, every time at the business filtered by event type and by resource, is offered on the first step, unfiltered, and on the resource and times steps, filtered by the choice made there (none for Anyone); Back returns to the step it was opened from. A signed-out customer signs in with the time kept, and gives their name too when they are new, then holds, confirms and sees the booking with its cancel step. It has no tabs and never leaves the business.
|
|
64
|
+
|
|
65
|
+
| Prop | Meaning |
|
|
66
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
67
|
+
| `businessId` | The business. |
|
|
68
|
+
| `eventTypeId` | Optional: opens past the first step on this event type, or filters See all times by it. |
|
|
69
|
+
| `resourceId` | Optional: a resource that provides the event type, or `"any"` for anyone; with `all`, filters every time by it. |
|
|
70
|
+
| `all` | Optional `true`: See all times. |
|
|
71
|
+
| `allFrom` | Optional, with `all`: `{ eventTypeId, resourceId? }`, the resource or times step See all times was opened from (`resourceId` is a resource or `"any"` from the times step); Back returns to it. |
|
|
72
|
+
| `time` | Optional `MsmBookingTime`, `{ startsAt, eventTypeId, eventId?, resourceId? }`: opens on that time. A time that can no longer be booked shows the step it was in with a note. |
|
|
73
|
+
| `onChange` | Called with `MsmBookingSelection`, `{ businessId, eventTypeId?, resourceId?, all?, allFrom?, time? }`, at every step and every step back. Pass it to keep the selection in your URL and feed it back as props; leave it out and the component keeps the selection itself. |
|
|
74
|
+
| `onBooked` | Called once with the booking, `CustomerBooking`, when the customer confirms it. |
|
|
75
|
+
| `onClose` | Adds a Close button to every step, and Done to the booked step, that call it. |
|
|
76
|
+
| `autoFocus` | Optional, default `true`: the first field takes focus when the flow opens, as a dialog expects. Pass `false` for a flow placed in a page, so it neither takes the page's focus nor scrolls it; later steps still take focus. |
|
|
74
77
|
|
|
75
78
|
A hold cannot be read back, so mounting `MsmBooking` again on a `time` holds that time again.
|
|
76
79
|
|
|
@@ -82,6 +85,10 @@ Bookings, Passes and My details, with no Book tab, and sign-in in place when sig
|
|
|
82
85
|
|
|
83
86
|
The phone-first sign-in form on its own: phone, code, and a name only when the customer is new. `onSignedIn()` is called once the customer is signed in, whether they already had an account or just registered, and at once when they already were; `onCancel` adds a Cancel button. It never navigates: close your modal on either.
|
|
84
87
|
|
|
88
|
+
### `MsmPayButtons`
|
|
89
|
+
|
|
90
|
+
The "Pay with …" buttons for a reservation your page already holds for the signed-in customer, such as from your own class panel: one button for each of the business's online payment methods, in its order, then the provider's page, and the result. Pass `basePath`, `businessId`, the held `reservationId` and `onResult`, which is called once with `{ status: "confirmed", bookingId }`, `{ status: "released" }` (the payment didn't go through, or the hold lapsed) or `{ status: "unconfirmed_paid" }` (paid after the time was taken; the business settles with the customer). It shows no price, sign-in or booking: your page does. With a server half with cookies, the buttons send this page to the provider's page, calling the optional `onLeave` just before, and the provider sends the customer back to this page with `msmCheckout` in the query. Show the same reservation's `MsmPayButtons` again there; it removes `msmCheckout`, reads the payment and calls `onResult`. With a cookieless server half, the provider's page opens in a new tab as described under [Sessions](#sessions), and this page stays and calls `onResult` as soon as the payment arrives. `useMsmPayment` takes the same props and returns its state, `pay(method)` and `payAgain`, for drawing the buttons yourself.
|
|
91
|
+
|
|
85
92
|
## Images
|
|
86
93
|
|
|
87
94
|
The screens show the business's logo (the businesses list and the head of a business), an event type's image (its card in `MsmBooking`'s first step, and above its times) and a resource's photo (its card where the customer chooses who). A card or thumbnail loads the `small` rendition; an event type's details offer both renditions as a `srcset` with `sizes`, so a narrow screen does not fetch the original. Every image is a plain `<img>` with its `width` and `height`, `loading="lazy"` and `alt` text, so the layout does not shift as it loads; a business, event type or resource without an image looks as it did before.
|
|
@@ -109,6 +116,8 @@ Styles are scoped under `.msm-customer` with no global reset, in the one stylesh
|
|
|
109
116
|
| `--msm-customer-font` | Font family | `inherit` |
|
|
110
117
|
| `--msm-customer-radius` | Corner radius | `6px` (cards a third larger) |
|
|
111
118
|
|
|
119
|
+
Notices, badges, the cancellation box, warnings and errors take their colours from the same properties (tints of the accent and text colour on the surface, with a fixed amber and red mixed with the text colour), so a dark theme set with these nine stays readable.
|
|
120
|
+
|
|
112
121
|
```css
|
|
113
122
|
.msm-customer {
|
|
114
123
|
--msm-customer-accent: #7a2e8f;
|
|
@@ -144,12 +153,13 @@ export {
|
|
|
144
153
|
};
|
|
145
154
|
```
|
|
146
155
|
|
|
147
|
-
| Option | Meaning
|
|
148
|
-
| --------------------------------------- |
|
|
149
|
-
| `basePath` | Where the route is mounted; the screens' `basePath`.
|
|
150
|
-
| `engineUrl`, `clientId`, `clientSecret` | The engine and the partner's website application client. It calls the engine through `@msm-platform/customer-sdk` in server mode, so the secret never leaves this server.
|
|
151
|
-
| `sessionKeys` | One key or a list, each at least 32 bytes (`openssl rand -base64 32`). The first encrypts the cookie and every one decrypts, so to rotate put the new key first and keep the old one until its cookies expire.
|
|
152
|
-
| `clientIp` | Required. The visitor's address, from what your platform guarantees; the engine limits code requests by it. Return null when unknown, which refuses code requests.
|
|
156
|
+
| Option | Meaning |
|
|
157
|
+
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
158
|
+
| `basePath` | Where the route is mounted; the screens' `basePath`. |
|
|
159
|
+
| `engineUrl`, `clientId`, `clientSecret` | The engine and the partner's website application client. It calls the engine through `@msm-platform/customer-sdk` in server mode, so the secret never leaves this server. |
|
|
160
|
+
| `sessionKeys` | One key or a list, each at least 32 bytes (`openssl rand -base64 32`). The first encrypts the cookie and every one decrypts, so to rotate put the new key first and keep the old one until its cookies expire. |
|
|
161
|
+
| `clientIp` | Required. The visitor's address, from what your platform guarantees; the engine limits code requests by it. Return null when unknown, which refuses code requests. |
|
|
162
|
+
| `cookieless` | For screens in a cross-site iframe, where browsers block or partition cookies: keeps the session and a pending registration without cookies (see [Sessions](#sessions)). Mount it as its own handler on its own `basePath`. Default: cookies. |
|
|
153
163
|
|
|
154
164
|
MSM owns your website's Cloudflare Turnstile widget and keeps its secret: the engine verifies the screens' token with it and limits code requests per address and per phone, so this server needs no Redis and no Turnstile secret. MSM hands over the widget's site key, which is public, with the client credentials.
|
|
155
165
|
|
|
@@ -174,6 +184,8 @@ The session lives in no store: the cookie `__Host-msm_customer_session` (HttpOnl
|
|
|
174
184
|
|
|
175
185
|
A pending registration lives the same way: the cookie `__Host-msm_customer_registration`, with the same attributes and expiring with the engine's ticket (10 minutes), holds `{registrationTicket, expiresAt}` encrypted with the same keys. Each cookie's name is authenticated with its value, so neither opens as the other. The browser learns only that a name is needed; no response body carries the ticket.
|
|
176
186
|
|
|
187
|
+
With `cookieless: true`, for screens framed by another site, the handler sets no cookie. It hands the screens the same two encrypted values in the `X-MSM-Session` and `X-MSM-Registration` response headers instead; the screens keep them in the page's memory only and send them back in the same request headers, so a reload signs the customer out. Each value also holds the `Origin` of the request it was issued to, and opens only on a request the browser marks as from that page: one with the same `Origin`, or a same-origin read with no `Origin` and `Sec-Fetch-Site: same-origin`. Both headers are the browser's, not the page's, and need no public URL from your server. A request the browser marks as another site's (`Sec-Fetch-Site`), or a write without `Origin`, is refused with 403 `CrossOriginRefused` before the engine is called. A cookie's value never opens as a header's, nor the other way. The engine token stays on the server either way. Since the handles live only in the page, anything that navigates the frame signs the customer out. So with a session held this way, the "Pay with …" and "Buy with …" buttons open the provider's page in a new tab, opened on the click, and the screens stay and read the payment until it arrives; the provider sends that tab back to the screens' page with `msmTab` added to the query, where they only say to go back to the page the customer came from, and close the tab when the browser lets them. A browser that refuses the tab gets an "Open the payment page" link. `readCustomerSession` reads only the cookie, so it does not see a cookieless handler's sessions. (`sessionStorage` would survive a navigation, but Chrome refuses it in a cross-site frame once third-party cookies are blocked.)
|
|
188
|
+
|
|
177
189
|
`readCustomerSession(cookieValue, { sessionKeys })` reads the signed-in customer's session in the partner's own server code, such as a page that books through the customer SDK with `sessionHeaders(session.sessionToken)`, so the partner's pages and the screens share one sign-in. It returns null for a missing, undecryptable or expired cookie. It does not ask the engine, so a session revoked elsewhere reads as signed in until the engine answers 401; a caller that needs certainty calls the engine.
|
|
178
190
|
|
|
179
191
|
## Development
|
package/dist/account.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CustomerBotCheck, CustomerBrand } from "./client";
|
|
2
|
+
import type { MsmLocale } from "./i18n";
|
|
2
3
|
/** One of the account's screens. */
|
|
3
4
|
export type MsmAccountScreen = "bookings" | "passes" | "details";
|
|
4
5
|
export interface MsmAccountProps {
|
|
@@ -20,6 +21,8 @@ export interface MsmAccountProps {
|
|
|
20
21
|
* here or in another of the package's components on the same `basePath`.
|
|
21
22
|
*/
|
|
22
23
|
onSessionChange?: (signedIn: boolean) => void;
|
|
24
|
+
/** The screens' language, as for MsmCustomer. */
|
|
25
|
+
locale?: MsmLocale;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* The customer's account: bookings, passes and details, with no booking
|
package/dist/booking-flow.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CustomerBooking, CustomerBotCheck, CustomerBrand } from "./client";
|
|
2
|
+
import { type MsmLocale } from "./i18n";
|
|
2
3
|
export type { CustomerBooking } from "./client";
|
|
3
4
|
/**
|
|
4
5
|
* A time to book, as the host can keep it in its URL: a seat in a scheduled
|
|
@@ -24,6 +25,17 @@ export interface MsmBookingSelection {
|
|
|
24
25
|
resourceId?: string;
|
|
25
26
|
/** Every time, with filters, after See all times. */
|
|
26
27
|
all?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* With `all`, the step See all times was opened from, when it was the
|
|
30
|
+
* resource or times step: the event type and the choice made there
|
|
31
|
+
* (`"any"` for Anyone, none from the resource step). Back returns to
|
|
32
|
+
* it, whatever the filters are by then. Without it, back goes to the
|
|
33
|
+
* event types.
|
|
34
|
+
*/
|
|
35
|
+
allFrom?: {
|
|
36
|
+
eventTypeId: string;
|
|
37
|
+
resourceId?: string;
|
|
38
|
+
};
|
|
27
39
|
time?: MsmBookingTime;
|
|
28
40
|
}
|
|
29
41
|
export interface MsmBookingProps extends MsmBookingSelection {
|
|
@@ -49,6 +61,14 @@ export interface MsmBookingProps extends MsmBookingSelection {
|
|
|
49
61
|
* here or in another of the package's components on the same `basePath`.
|
|
50
62
|
*/
|
|
51
63
|
onSessionChange?: (signedIn: boolean) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the first field takes focus when it opens, as a dialog expects
|
|
66
|
+
* (the default). Pass false for a flow placed in a page, which should not
|
|
67
|
+
* take the page's focus or scroll it; later steps still take focus.
|
|
68
|
+
*/
|
|
69
|
+
autoFocus?: boolean;
|
|
70
|
+
/** The screens' language, as for MsmCustomer. */
|
|
71
|
+
locale?: MsmLocale;
|
|
52
72
|
}
|
|
53
73
|
/**
|
|
54
74
|
* The booking flow for one business, for a host's overlay: choose an event
|
package/dist/booking.d.ts
CHANGED
|
@@ -4,6 +4,13 @@ export interface Choice {
|
|
|
4
4
|
business: Business;
|
|
5
5
|
candidate: Candidate;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* #228: keeps the host's selection while the customer is on the provider's
|
|
9
|
+
* page, so the flow can open the same time when they come back.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rememberSelection(selection: unknown): void;
|
|
12
|
+
/** Back from the provider's page: the selection kept when the customer left. */
|
|
13
|
+
export declare function takeCheckoutSelection<Selection>(): Selection | null;
|
|
7
14
|
/** What the customer is booking: what, where, when and with whom. */
|
|
8
15
|
export declare function ChoiceSummary({ choice }: {
|
|
9
16
|
choice: Choice;
|
|
@@ -20,4 +27,6 @@ export declare function Booking(props: {
|
|
|
20
27
|
onBooked?: ((booking: CustomerBooking) => void) | undefined;
|
|
21
28
|
/** Without account navigation, the booked step's way out. */
|
|
22
29
|
onDone?: (() => void) | undefined;
|
|
30
|
+
/** #228: called just before the customer leaves for the provider's page. */
|
|
31
|
+
onLeave?: (() => void) | undefined;
|
|
23
32
|
}): import("react").JSX.Element;
|
package/dist/client.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export type CustomerImage = NonNullable<Business["logo"]>;
|
|
|
16
16
|
/** A confirmed booking, as the confirm route returns it. */
|
|
17
17
|
export type CustomerBooking = Ok<paths["/web/businesses/{businessId}/reservations/{reservationId}/confirm"]["post"]>;
|
|
18
18
|
export type MyDetails = Ok<paths["/web/me"]["get"]>;
|
|
19
|
+
/** #520: a business's product, and the customer's checkout of one. */
|
|
20
|
+
export type Product = Ok<paths["/web/businesses/{businessId}/products"]["get"]>["items"][number];
|
|
21
|
+
export type ProductCheckout = Ok<paths["/web/businesses/{businessId}/products/{productId}/checkout"]["get"]>;
|
|
19
22
|
export type EventType = Ok<paths["/web/businesses/{businessId}/event-types"]["get"]>["items"][number];
|
|
20
23
|
/** One booking candidate: a seat in a scheduled event or an open time slot. */
|
|
21
24
|
export type Candidate = Ok<paths["/web/businesses/{businessId}/availability"]["get"]>["items"][number];
|
|
@@ -34,10 +37,11 @@ export type CustomerBotCheck = {
|
|
|
34
37
|
siteKey: string;
|
|
35
38
|
};
|
|
36
39
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
40
|
+
* Whether the session on `basePath` lives only in this page's memory, as a
|
|
41
|
+
* cookieless server half's does, so that navigating the page ends it.
|
|
39
42
|
*/
|
|
40
|
-
export declare
|
|
43
|
+
export declare function sessionInMemory(basePath: string): boolean;
|
|
44
|
+
export declare function portalFetch(basePath: string, path: string, init?: RequestInit): Promise<Response>;
|
|
41
45
|
export declare function post(basePath: string, path: string, body?: unknown): Promise<Response>;
|
|
42
46
|
/**
|
|
43
47
|
* The customer SDK in proxy mode against the BFF under `basePath`, which adds the client's
|
package/dist/context.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type CustomerScreen = "businesses" | "bookings" | "passes" | "details" |
|
|
|
11
11
|
};
|
|
12
12
|
export interface Portal {
|
|
13
13
|
client: CustomerClient;
|
|
14
|
+
/** Where the server half is mounted, without a trailing slash. */
|
|
15
|
+
basePath: string;
|
|
14
16
|
/** The partner's public businesses by ID; a business missing here is not public. */
|
|
15
17
|
businesses: Map<string, Business>;
|
|
16
18
|
/** Whether `businesses` is complete, still loading or failed to load. */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** How a locale writes numbers, money, dates and times. */
|
|
2
|
+
export interface Formats {
|
|
3
|
+
number: (value: number) => string;
|
|
4
|
+
/** An amount in its currency's ISO 4217 minor unit, such as 12400 ISK. */
|
|
5
|
+
money: (minor: number, currency: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Date and time in a business's timezone, or the browser's when the
|
|
8
|
+
* business is unknown (`timeZone` undefined).
|
|
9
|
+
*/
|
|
10
|
+
dateTime: (iso: string, timeZone?: string) => string;
|
|
11
|
+
time: (iso: string, timeZone?: string) => string;
|
|
12
|
+
date: (iso: string, timeZone?: string) => string;
|
|
13
|
+
/** A day as a heading, such as "Tuesday 1 December", in `timeZone`. */
|
|
14
|
+
day: (iso: string, timeZone?: string) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare const english: Formats;
|
|
17
|
+
export declare const icelandic: Formats;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ declare const en: {
|
|
|
112
112
|
readonly "book.anyResource": "Anyone";
|
|
113
113
|
readonly "book.anyResourceHint": "The first free times with anyone who offers it";
|
|
114
114
|
readonly "book.toTypes": "Back to services";
|
|
115
|
+
readonly "book.toStep": "Back";
|
|
115
116
|
readonly "book.otherResource": "Choose someone else";
|
|
116
117
|
readonly "book.reserveAgain": "Hold this time again";
|
|
117
118
|
readonly "book.full": "This class is full now. Choose another time.";
|
|
@@ -124,6 +125,25 @@ declare const en: {
|
|
|
124
125
|
readonly "book.banned.undated": "You can't book online right now because of bookings you didn't show up to. Contact the business if you think this is a mistake.";
|
|
125
126
|
readonly "book.refused": "This business can't take your booking. Contact them.";
|
|
126
127
|
readonly "book.failed": "The booking could not be made. Try again.";
|
|
128
|
+
readonly "pay.price": "Price: {price}";
|
|
129
|
+
readonly "pay.advance": "Pay {advance} now to book. The rest, {rest}, is paid later.";
|
|
130
|
+
readonly "pay.whole": "Pay {advance} now to book.";
|
|
131
|
+
readonly "pay.later": "Nothing to pay now; you pay {price} later.";
|
|
132
|
+
readonly "pay.with": "Pay with {provider}";
|
|
133
|
+
readonly "pay.none": "This business doesn't take payments online yet. Contact them to book.";
|
|
134
|
+
readonly "pay.redirecting": "Taking you to the payment page…";
|
|
135
|
+
readonly "pay.checking": "Checking your payment…";
|
|
136
|
+
readonly "pay.away": "Finish paying in the new tab. You'll see your booking here as soon as the payment arrives.";
|
|
137
|
+
readonly "pay.awayBlocked": "Open the payment page to pay. You'll see the result here as soon as the payment arrives.";
|
|
138
|
+
readonly "pay.open": "Open the payment page";
|
|
139
|
+
readonly "pay.tabDone": "You can close this tab. The page you came from shows whether your payment went through.";
|
|
140
|
+
readonly "pay.notFinished": "You haven't finished paying. We're holding this time for you until {time}.";
|
|
141
|
+
readonly "pay.again": "Go back to payment";
|
|
142
|
+
readonly "pay.released": "Your payment didn't go through, so the time was released. Hold it again if it's still free.";
|
|
143
|
+
readonly "pay.paidUnbooked": "We received your payment, but the time was taken before it arrived, so you're not booked. The business will contact you about your payment.";
|
|
144
|
+
readonly "pay.slow": "Your payment is still being confirmed. Check your bookings in a few minutes.";
|
|
145
|
+
readonly "pay.unavailable": "The payment page couldn't be opened. Try again in a moment.";
|
|
146
|
+
readonly "pay.notOffered": "This way of paying isn't available. Choose another.";
|
|
127
147
|
readonly "passes.heading": "Memberships and passes";
|
|
128
148
|
readonly "passes.empty": "You have no memberships or passes.";
|
|
129
149
|
readonly "passes.unlimited": "Unlimited";
|
|
@@ -131,6 +151,15 @@ declare const en: {
|
|
|
131
151
|
readonly "passes.validFrom": "Valid from {date}";
|
|
132
152
|
readonly "passes.validRange": "Valid {from} – {until}";
|
|
133
153
|
readonly "passes.expired": "Expired";
|
|
154
|
+
readonly "shop.heading": "Buy a membership or pass";
|
|
155
|
+
readonly "shop.buy": "Buy with {provider}";
|
|
156
|
+
readonly "shop.paid": "Thank you, your payment is received. The receipt comes from the payment provider, and your purchase shows here once it's ready.";
|
|
157
|
+
readonly "shop.notPaid": "Your payment didn't go through, so nothing was bought.";
|
|
158
|
+
readonly "shop.notFinished": "You haven't finished paying, so nothing was bought yet.";
|
|
159
|
+
readonly "shop.away": "Finish paying in the new tab. You'll see here as soon as the payment arrives.";
|
|
160
|
+
readonly "shop.slow": "Your payment is still being confirmed. Check back here in a few minutes.";
|
|
161
|
+
readonly "shop.outside": "You can buy from {business} online once you're its customer. Book with them first, or ask them.";
|
|
162
|
+
readonly "shop.gone": "This is no longer sold. Choose something else.";
|
|
134
163
|
readonly "details.heading": "My details";
|
|
135
164
|
readonly "details.name": "Name";
|
|
136
165
|
readonly "details.phone": "Phone";
|
|
@@ -150,25 +179,66 @@ export type Messages = Record<MessageKey, string>;
|
|
|
150
179
|
type PluralBase = {
|
|
151
180
|
[K in MessageKey]: K extends `${infer Base}.other` ? Base : never;
|
|
152
181
|
}[MessageKey];
|
|
153
|
-
/** The
|
|
154
|
-
export
|
|
182
|
+
/** The screens' languages: English (the default) and Icelandic. */
|
|
183
|
+
export type MsmLocale = "en" | "is";
|
|
155
184
|
type Params = Record<string, string | number>;
|
|
156
|
-
/** The
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
185
|
+
/** The copy and formats of one locale. */
|
|
186
|
+
declare function createI18n(name: MsmLocale): {
|
|
187
|
+
locale: MsmLocale;
|
|
188
|
+
t: (key: MessageKey, params?: Params) => string;
|
|
189
|
+
tp: (base: PluralBase, count: number, params?: Params) => string;
|
|
190
|
+
formatMoney: (minor: number, currency: string) => string;
|
|
191
|
+
formatNumber: (value: number) => string;
|
|
192
|
+
formatDateTime: (iso: string, timeZone?: string) => string;
|
|
193
|
+
formatTime: (iso: string, timeZone?: string) => string;
|
|
194
|
+
formatDate: (iso: string, timeZone?: string) => string;
|
|
195
|
+
formatDay: (iso: string, timeZone?: string) => string;
|
|
196
|
+
formatRange: (start: string, end: string, timeZone?: string) => string;
|
|
197
|
+
formatWait: (seconds: number) => string;
|
|
198
|
+
};
|
|
199
|
+
export type I18n = ReturnType<typeof createI18n>;
|
|
200
|
+
/** The locale's copy and formats; anything but `"is"` is English. */
|
|
201
|
+
export declare const i18nOf: (name: MsmLocale | undefined) => {
|
|
202
|
+
locale: MsmLocale;
|
|
203
|
+
t: (key: MessageKey, params?: Params) => string;
|
|
204
|
+
tp: (base: PluralBase, count: number, params?: Params) => string;
|
|
205
|
+
formatMoney: (minor: number, currency: string) => string;
|
|
206
|
+
formatNumber: (value: number) => string;
|
|
207
|
+
formatDateTime: (iso: string, timeZone?: string) => string;
|
|
208
|
+
formatTime: (iso: string, timeZone?: string) => string;
|
|
209
|
+
formatDate: (iso: string, timeZone?: string) => string;
|
|
210
|
+
formatDay: (iso: string, timeZone?: string) => string;
|
|
211
|
+
formatRange: (start: string, end: string, timeZone?: string) => string;
|
|
212
|
+
formatWait: (seconds: number) => string;
|
|
213
|
+
};
|
|
214
|
+
/** The active locale's copy and formats, set by the screen component. */
|
|
215
|
+
export declare const I18nContext: import("react").Context<{
|
|
216
|
+
locale: MsmLocale;
|
|
217
|
+
t: (key: MessageKey, params?: Params) => string;
|
|
218
|
+
tp: (base: PluralBase, count: number, params?: Params) => string;
|
|
219
|
+
formatMoney: (minor: number, currency: string) => string;
|
|
220
|
+
formatNumber: (value: number) => string;
|
|
221
|
+
formatDateTime: (iso: string, timeZone?: string) => string;
|
|
222
|
+
formatTime: (iso: string, timeZone?: string) => string;
|
|
223
|
+
formatDate: (iso: string, timeZone?: string) => string;
|
|
224
|
+
formatDay: (iso: string, timeZone?: string) => string;
|
|
225
|
+
formatRange: (start: string, end: string, timeZone?: string) => string;
|
|
226
|
+
formatWait: (seconds: number) => string;
|
|
227
|
+
}>;
|
|
228
|
+
export declare const useI18n: () => {
|
|
229
|
+
locale: MsmLocale;
|
|
230
|
+
t: (key: MessageKey, params?: Params) => string;
|
|
231
|
+
tp: (base: PluralBase, count: number, params?: Params) => string;
|
|
232
|
+
formatMoney: (minor: number, currency: string) => string;
|
|
233
|
+
formatNumber: (value: number) => string;
|
|
234
|
+
formatDateTime: (iso: string, timeZone?: string) => string;
|
|
235
|
+
formatTime: (iso: string, timeZone?: string) => string;
|
|
236
|
+
formatDate: (iso: string, timeZone?: string) => string;
|
|
237
|
+
formatDay: (iso: string, timeZone?: string) => string;
|
|
238
|
+
formatRange: (start: string, end: string, timeZone?: string) => string;
|
|
239
|
+
formatWait: (seconds: number) => string;
|
|
240
|
+
};
|
|
241
|
+
/** The English locale's tag. Screens format in the one their `locale` names. */
|
|
242
|
+
export declare const locale = "en-GB";
|
|
243
|
+
export declare const t: (key: MessageKey, params?: Params) => string, formatDate: (iso: string, timeZone?: string) => string, formatDateTime: (iso: string, timeZone?: string) => string, formatNumber: (value: number) => string;
|
|
174
244
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
import type { CustomerBotCheck, CustomerBrand } from "./client";
|
|
3
3
|
import type { CustomerScreen } from "./context";
|
|
4
|
+
import { type MsmLocale } from "./i18n";
|
|
4
5
|
export { MsmAccount, type MsmAccountProps, type MsmAccountScreen, } from "./account";
|
|
5
6
|
export { type CustomerBooking, MsmBooking, type MsmBookingProps, type MsmBookingSelection, type MsmBookingTime, } from "./booking-flow";
|
|
6
7
|
export { cancellationState } from "./cancellation";
|
|
7
8
|
export type { CustomerBotCheck, CustomerBrand } from "./client";
|
|
8
9
|
export type { CustomerScreen } from "./context";
|
|
9
|
-
export { formatDate, formatDateTime, formatNumber, locale, type MessageKey, type Messages, t, } from "./i18n";
|
|
10
|
+
export { formatDate, formatDateTime, formatNumber, locale, type MessageKey, type Messages, type MsmLocale, t, } from "./i18n";
|
|
11
|
+
export { MsmPayButtons, type MsmPayButtonsProps, type MsmPayment, type MsmPaymentMethod, type MsmPaymentState, type MsmPayResult, useMsmPayment, } from "./pay";
|
|
10
12
|
export { MsmSignIn, type MsmSignInProps } from "./sign-in-standalone";
|
|
11
13
|
export interface MsmCustomerProps {
|
|
12
14
|
/**
|
|
@@ -31,6 +33,12 @@ export interface MsmCustomerProps {
|
|
|
31
33
|
*/
|
|
32
34
|
screen?: CustomerScreen;
|
|
33
35
|
onNavigate?: (screen: CustomerScreen) => void;
|
|
36
|
+
/**
|
|
37
|
+
* The screens' language: `"en"` (the default) or `"is"` for Icelandic,
|
|
38
|
+
* which also formats dates, times and money. Changing it re-renders the
|
|
39
|
+
* open screen in the new language.
|
|
40
|
+
*/
|
|
41
|
+
locale?: MsmLocale;
|
|
34
42
|
}
|
|
35
43
|
/**
|
|
36
44
|
* MSM's customer screens: the partner's businesses with their times to
|