@msm-platform/customer-react 0.4.3 → 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 +7 -0
- package/README.md +7 -2
- package/dist/account.d.ts +3 -0
- package/dist/booking-flow.d.ts +3 -0
- package/dist/booking.d.ts +3 -13
- package/dist/formats.d.ts +17 -0
- package/dist/i18n.d.ts +61 -22
- package/dist/i18n.is.d.ts +2 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +2115 -1462
- package/dist/pay.d.ts +125 -0
- package/dist/portal.d.ts +2 -0
- package/dist/refusals.d.ts +14 -0
- package/dist/screens/business.d.ts +36 -1
- package/dist/sign-in-standalone.d.ts +3 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ 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
|
+
|
|
7
14
|
## [0.4.3] - 2026-11-23
|
|
8
15
|
|
|
9
16
|
### 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,12 +47,13 @@ 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
|
```
|
|
@@ -84,6 +85,10 @@ Bookings, Passes and My details, with no Book tab, and sign-in in place when sig
|
|
|
84
85
|
|
|
85
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.
|
|
86
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
|
+
|
|
87
92
|
## Images
|
|
88
93
|
|
|
89
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.
|
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
|
|
@@ -66,6 +67,8 @@ export interface MsmBookingProps extends MsmBookingSelection {
|
|
|
66
67
|
* take the page's focus or scroll it; later steps still take focus.
|
|
67
68
|
*/
|
|
68
69
|
autoFocus?: boolean;
|
|
70
|
+
/** The screens' language, as for MsmCustomer. */
|
|
71
|
+
locale?: MsmLocale;
|
|
69
72
|
}
|
|
70
73
|
/**
|
|
71
74
|
* The booking flow for one business, for a host's overlay: choose an event
|
package/dist/booking.d.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Business, Candidate, CustomerBooking } from "./client";
|
|
2
2
|
/** The candidate a customer chose to book, kept through sign-in. */
|
|
3
3
|
export interface Choice {
|
|
4
4
|
business: Business;
|
|
5
5
|
candidate: Candidate;
|
|
6
6
|
}
|
|
7
|
-
/** How the customer came back from the provider's page. */
|
|
8
|
-
export type CheckoutReturn = "paid" | "back";
|
|
9
7
|
/**
|
|
10
8
|
* #228: keeps the host's selection while the customer is on the provider's
|
|
11
9
|
* page, so the flow can open the same time when they come back.
|
|
12
10
|
*/
|
|
13
11
|
export declare function rememberSelection(selection: unknown): void;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* the address bar, and the selection kept when the customer left.
|
|
17
|
-
*/
|
|
18
|
-
export declare function takeCheckoutReturn<Selection>(): {
|
|
19
|
-
outcome: CheckoutReturn;
|
|
20
|
-
selection: Selection | null;
|
|
21
|
-
} | null;
|
|
12
|
+
/** Back from the provider's page: the selection kept when the customer left. */
|
|
13
|
+
export declare function takeCheckoutSelection<Selection>(): Selection | null;
|
|
22
14
|
/** What the customer is booking: what, where, when and with whom. */
|
|
23
15
|
export declare function ChoiceSummary({ choice }: {
|
|
24
16
|
choice: Choice;
|
|
@@ -37,6 +29,4 @@ export declare function Booking(props: {
|
|
|
37
29
|
onDone?: (() => void) | undefined;
|
|
38
30
|
/** #228: called just before the customer leaves for the provider's page. */
|
|
39
31
|
onLeave?: (() => void) | undefined;
|
|
40
|
-
/** #228: how the customer came back from the provider's page, if they did. */
|
|
41
|
-
returned?: CheckoutReturn | undefined;
|
|
42
32
|
}): import("react").JSX.Element;
|
|
@@ -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
|
@@ -179,27 +179,66 @@ export type Messages = Record<MessageKey, string>;
|
|
|
179
179
|
type PluralBase = {
|
|
180
180
|
[K in MessageKey]: K extends `${infer Base}.other` ? Base : never;
|
|
181
181
|
}[MessageKey];
|
|
182
|
-
/** The
|
|
183
|
-
export
|
|
182
|
+
/** The screens' languages: English (the default) and Icelandic. */
|
|
183
|
+
export type MsmLocale = "en" | "is";
|
|
184
184
|
type Params = Record<string, string | number>;
|
|
185
|
-
/** The
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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;
|
|
205
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
|