@msm-platform/customer-react 0.3.0 → 0.3.1
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 +6 -0
- package/README.md +38 -1
- package/dist/account.d.ts +28 -0
- package/dist/booking-flow.d.ts +61 -0
- package/dist/booking.d.ts +5 -1
- package/dist/client.d.ts +2 -0
- package/dist/context.d.ts +5 -0
- package/dist/i18n.d.ts +13 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1119 -619
- package/dist/layout.d.ts +8 -0
- package/dist/portal.d.ts +26 -0
- package/dist/screens/business.d.ts +71 -2
- package/dist/session.d.ts +10 -0
- package/dist/sign-in-standalone.d.ts +26 -0
- package/dist/sign-in.d.ts +4 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to `@msm-platform/customer-react`. The format follows [Keep
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.3.1] - 2026-11-15
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `MsmBooking`, `MsmAccount` and `MsmSignIn`, for your own pages and the modals or overlays you draw around them. `MsmBooking` books at one business with no tabs: the customer chooses an event type, then who provides it when two or more resources can (or anyone), then a time, or See all times to filter every time by event type and resource. A signed-out customer signs in or registers inside it and keeps the time they chose; `onBooked` gets the booking once it is confirmed, `onClose` adds a Close button to every step, and `businessId`, `eventTypeId`, `resourceId`, `all` and `time` with `onChange` let you keep the step in your URL. `MsmAccount` shows Bookings, Passes and My details, with sign-in in place when signed out. `MsmSignIn` is sign-in and registration with `onSignedIn` and `onCancel`, and never navigates. Components on the same `basePath` share one sign-in, each tells you of a sign-in or sign-out with `onSessionChange`, and each moves focus to its first field when it mounts. `MsmCustomer` is unchanged.
|
|
12
|
+
|
|
7
13
|
## [0.3.0] - 2026-11-15
|
|
8
14
|
|
|
9
15
|
### Changed
|
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
|
|
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 `MsmSignIn`, 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
|
|
|
@@ -45,6 +45,43 @@ Before sending a code, sign-in and registration show Cloudflare Turnstile and se
|
|
|
45
45
|
|
|
46
46
|
The built entry starts with `"use client"`, so a Next.js server component can import it; it touches no browser globals at import and renders on the server (as "Loading…" until mounted).
|
|
47
47
|
|
|
48
|
+
## Components for your own pages
|
|
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.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import {
|
|
54
|
+
MsmAccount,
|
|
55
|
+
MsmBooking,
|
|
56
|
+
MsmSignIn,
|
|
57
|
+
} from "@msm-platform/customer-react";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `MsmBooking`
|
|
61
|
+
|
|
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. The first step also offers See all times, every time at the business filtered by event type and by resource. A signed-out customer signs in or registers with the time kept, then holds, confirms and sees the booking with its cancel step. It has no tabs and never leaves the business.
|
|
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
|
+
| `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. |
|
|
71
|
+
| `onChange` | Called with `MsmBookingSelection`, `{ businessId, eventTypeId?, resourceId?, all?, 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. |
|
|
72
|
+
| `onBooked` | Called once with the booking, `CustomerBooking`, when the customer confirms it. |
|
|
73
|
+
| `onClose` | Adds a Close button to every step, and Done to the booked step, that call it. |
|
|
74
|
+
|
|
75
|
+
A hold cannot be read back, so mounting `MsmBooking` again on a `time` holds that time again.
|
|
76
|
+
|
|
77
|
+
### `MsmAccount`
|
|
78
|
+
|
|
79
|
+
Bookings, Passes and My details, with no Book tab, and sign-in in place when signed out. `screen` (`bookings`, the default, `passes` or `details`) and `onNavigate` follow `MsmCustomer`'s rule: leave both out and it switches tabs itself.
|
|
80
|
+
|
|
81
|
+
### `MsmSignIn`
|
|
82
|
+
|
|
83
|
+
Sign-in and registration on their own. `onSignedIn()` is called once the customer is signed in, whether they signed in or registered, and at once when they already were; `onCancel` adds a Cancel button. It never navigates: close your modal on either.
|
|
84
|
+
|
|
48
85
|
## Theming
|
|
49
86
|
|
|
50
87
|
Styles are scoped under `.msm-customer` with no global reset, in the one stylesheet above, which includes the phone input's. The screens take the height of their content, so they sit inside the partner's page. A partner themes them with these CSS custom properties on `.msm-customer` or an ancestor. They are public API: renaming one is a breaking change.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CustomerBotCheck, CustomerBrand } from "./client";
|
|
2
|
+
/** One of the account's screens. */
|
|
3
|
+
export type MsmAccountScreen = "bookings" | "passes" | "details";
|
|
4
|
+
export interface MsmAccountProps {
|
|
5
|
+
/** Where the server half is mounted, as for MsmCustomer. */
|
|
6
|
+
basePath: string;
|
|
7
|
+
/** The host's name and logo for the header and sign-in. */
|
|
8
|
+
brand?: CustomerBrand;
|
|
9
|
+
/** The bot check before a code is sent, as for MsmCustomer. */
|
|
10
|
+
botCheck: CustomerBotCheck;
|
|
11
|
+
/**
|
|
12
|
+
* `bookings` (the default), `passes` or `details`. Leave both this and
|
|
13
|
+
* `onNavigate` out to let the package switch screens itself; pass both to
|
|
14
|
+
* drive it from the host's router or URL.
|
|
15
|
+
*/
|
|
16
|
+
screen?: MsmAccountScreen;
|
|
17
|
+
onNavigate?: (screen: MsmAccountScreen) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Called when the customer signs in or out after the first session check,
|
|
20
|
+
* here or in another of the package's components on the same `basePath`.
|
|
21
|
+
*/
|
|
22
|
+
onSessionChange?: (signedIn: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The customer's account: bookings, passes and details, with no booking
|
|
26
|
+
* tab. Signed out, it shows sign-in in place, then the account.
|
|
27
|
+
*/
|
|
28
|
+
export declare function MsmAccount(props: MsmAccountProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CustomerBooking, CustomerBotCheck, CustomerBrand } from "./client";
|
|
2
|
+
export type { CustomerBooking } from "./client";
|
|
3
|
+
/**
|
|
4
|
+
* A time to book, as the host can keep it in its URL: a seat in a scheduled
|
|
5
|
+
* event (`eventId`), or an open time slot of an event type at `startsAt`,
|
|
6
|
+
* with one resource when the customer chose one.
|
|
7
|
+
*/
|
|
8
|
+
export interface MsmBookingTime {
|
|
9
|
+
startsAt: string;
|
|
10
|
+
eventTypeId: string;
|
|
11
|
+
eventId?: string;
|
|
12
|
+
resourceId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What MsmBooking shows. Without `all`, the steps: an event type to choose,
|
|
16
|
+
* then a resource when two or more provide it, then its times. With `all`,
|
|
17
|
+
* every time at the business, filtered by `eventTypeId` and `resourceId`.
|
|
18
|
+
* A `time` shows that time, to sign in for, hold and confirm.
|
|
19
|
+
*/
|
|
20
|
+
export interface MsmBookingSelection {
|
|
21
|
+
businessId: string;
|
|
22
|
+
eventTypeId?: string;
|
|
23
|
+
/** A resource's ID, or `"any"` once the customer chose anyone. */
|
|
24
|
+
resourceId?: string;
|
|
25
|
+
/** Every time, with filters, after See all times. */
|
|
26
|
+
all?: boolean;
|
|
27
|
+
time?: MsmBookingTime;
|
|
28
|
+
}
|
|
29
|
+
export interface MsmBookingProps extends MsmBookingSelection {
|
|
30
|
+
/** Where the server half is mounted, as for MsmCustomer. */
|
|
31
|
+
basePath: string;
|
|
32
|
+
/** The host's name and logo above sign-in. */
|
|
33
|
+
brand?: CustomerBrand;
|
|
34
|
+
/** The bot check before a code is sent, as for MsmCustomer. */
|
|
35
|
+
botCheck: CustomerBotCheck;
|
|
36
|
+
/**
|
|
37
|
+
* Called with the new selection at every step: an event type, a
|
|
38
|
+
* resource, See all times and its filters, a time, or a step back. Pass
|
|
39
|
+
* it to drive the selection's props from the host's URL; leave it out and
|
|
40
|
+
* the package keeps the selection itself, starting from those props.
|
|
41
|
+
*/
|
|
42
|
+
onChange?: (selection: MsmBookingSelection) => void;
|
|
43
|
+
/** Called once with the booking when the customer confirms it. */
|
|
44
|
+
onBooked?: (booking: CustomerBooking) => void;
|
|
45
|
+
/** Offers a Close button on every step that calls this. */
|
|
46
|
+
onClose?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Called when the customer signs in or out after the first session check,
|
|
49
|
+
* here or in another of the package's components on the same `basePath`.
|
|
50
|
+
*/
|
|
51
|
+
onSessionChange?: (signedIn: boolean) => void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The booking flow for one business, for a host's overlay: choose an event
|
|
55
|
+
* type, then who provides it when two or more can (or anyone), then a time,
|
|
56
|
+
* or See all times to filter every time by event type and resource. A
|
|
57
|
+
* signed-out customer signs in or registers with the time kept, then holds,
|
|
58
|
+
* confirms and sees the booking. It has no tabs and never leaves the
|
|
59
|
+
* business.
|
|
60
|
+
*/
|
|
61
|
+
export declare function MsmBooking(props: MsmBookingProps): import("react").JSX.Element;
|
package/dist/booking.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Business, Candidate } from "./client";
|
|
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;
|
|
@@ -16,4 +16,8 @@ export declare function ChoiceSummary({ choice }: {
|
|
|
16
16
|
export declare function Booking(props: {
|
|
17
17
|
choice: Choice;
|
|
18
18
|
onBack: () => void;
|
|
19
|
+
/** Called once with the booking when it is confirmed. */
|
|
20
|
+
onBooked?: ((booking: CustomerBooking) => void) | undefined;
|
|
21
|
+
/** Without account navigation, the booked step's way out. */
|
|
22
|
+
onDone?: (() => void) | undefined;
|
|
19
23
|
}): import("react").JSX.Element;
|
package/dist/client.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ type Ok<Operation> = Operation extends {
|
|
|
11
11
|
export type OwnBooking = Ok<paths["/web/me/bookings"]["get"]>["items"][number];
|
|
12
12
|
export type Membership = Ok<paths["/web/me/memberships"]["get"]>[number];
|
|
13
13
|
export type Business = Ok<paths["/web/businesses"]["get"]>["items"][number];
|
|
14
|
+
/** A confirmed booking, as the confirm route returns it. */
|
|
15
|
+
export type CustomerBooking = Ok<paths["/web/businesses/{businessId}/reservations/{reservationId}/confirm"]["post"]>;
|
|
14
16
|
export type MyDetails = Ok<paths["/web/me"]["get"]>;
|
|
15
17
|
export type EventType = Ok<paths["/web/businesses/{businessId}/event-types"]["get"]>["items"][number];
|
|
16
18
|
/** One booking candidate: a seat in a scheduled event or an open time slot. */
|
package/dist/context.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface Portal {
|
|
|
17
17
|
businessesStatus: "loading" | "ready" | "failed";
|
|
18
18
|
reloadBusinesses: () => void;
|
|
19
19
|
navigate: (screen: CustomerScreen) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the screens lead to the business list and the account, as in
|
|
22
|
+
* MsmCustomer; MsmBooking stays on its one business.
|
|
23
|
+
*/
|
|
24
|
+
accountNavigation: boolean;
|
|
20
25
|
/** Ends the session on the server and returns to sign-in with this notice. */
|
|
21
26
|
signOut: (notice?: MessageKey) => Promise<void>;
|
|
22
27
|
}
|
package/dist/i18n.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare const en: {
|
|
|
26
26
|
readonly "register.submit": "Create account";
|
|
27
27
|
readonly "signIn.wait": "Please wait…";
|
|
28
28
|
readonly "signIn.differentNumber": "Use a different number";
|
|
29
|
+
readonly "signIn.cancel": "Cancel";
|
|
29
30
|
readonly "signIn.error.tooMany": "Too many codes requested. Try again in about {wait}.";
|
|
30
31
|
readonly "signIn.error.tooManyLater": "Too many codes requested. Try again later.";
|
|
31
32
|
readonly "signIn.error.paused": "Sign-in codes are paused for now. Try again in about {wait}.";
|
|
@@ -79,6 +80,8 @@ declare const en: {
|
|
|
79
80
|
readonly "business.notFound": "This business isn't taking bookings here.";
|
|
80
81
|
readonly "business.types": "Services";
|
|
81
82
|
readonly "business.allTypes": "Everything";
|
|
83
|
+
readonly "business.resources": "With";
|
|
84
|
+
readonly "business.anyResource": "Anyone";
|
|
82
85
|
readonly "business.typeMissing": "This service can't be booked here.";
|
|
83
86
|
readonly "business.minutes": "{minutes} min";
|
|
84
87
|
readonly "business.week": "Which week";
|
|
@@ -101,6 +104,16 @@ declare const en: {
|
|
|
101
104
|
readonly "book.confirming": "Confirming…";
|
|
102
105
|
readonly "book.booked": "You're booked.";
|
|
103
106
|
readonly "book.toBookings": "See all my bookings";
|
|
107
|
+
readonly "book.done": "Done";
|
|
108
|
+
readonly "book.close": "Close";
|
|
109
|
+
readonly "book.chooseType": "What would you like to book?";
|
|
110
|
+
readonly "book.noTypes": "There is nothing to book here yet.";
|
|
111
|
+
readonly "book.seeAll": "See all times";
|
|
112
|
+
readonly "book.chooseResource": "Who would you like to book with?";
|
|
113
|
+
readonly "book.anyResource": "Anyone";
|
|
114
|
+
readonly "book.anyResourceHint": "The first free times with anyone who offers it";
|
|
115
|
+
readonly "book.toTypes": "Back to services";
|
|
116
|
+
readonly "book.otherResource": "Choose someone else";
|
|
104
117
|
readonly "book.reserveAgain": "Hold this time again";
|
|
105
118
|
readonly "book.full": "This class is full now. Choose another time.";
|
|
106
119
|
readonly "book.slotTaken": "Someone has just taken this time. Choose another.";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { CustomerBotCheck, CustomerBrand } from "./client";
|
|
3
|
+
import type { CustomerScreen } from "./context";
|
|
4
|
+
export { MsmAccount, type MsmAccountProps, type MsmAccountScreen, } from "./account";
|
|
5
|
+
export { type CustomerBooking, MsmBooking, type MsmBookingProps, type MsmBookingSelection, type MsmBookingTime, } from "./booking-flow";
|
|
4
6
|
export { cancellationState } from "./cancellation";
|
|
5
7
|
export type { CustomerBotCheck, CustomerBrand } from "./client";
|
|
6
8
|
export type { CustomerScreen } from "./context";
|
|
7
9
|
export { formatDate, formatDateTime, formatNumber, locale, type MessageKey, type Messages, t, } from "./i18n";
|
|
10
|
+
export { MsmSignIn, type MsmSignInProps } from "./sign-in-standalone";
|
|
8
11
|
export interface MsmCustomerProps {
|
|
9
12
|
/**
|
|
10
13
|
* Where the server half (`@msm-platform/customer-react/server`) is mounted,
|