@msm-platform/customer-react 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to `@msm-platform/customer-react`. The format follows [Keep
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.2.0] - 2026-11-14
8
+
9
+ ### Added
10
+
11
+ - Booking screens: the partner's businesses, a business with its event types and a week of its availability (classes with the seats left and open time slots in one list, in the business's timezone), then hold, sign-in or registration when needed (the chosen time is kept and held straight after), confirm, and the booking with the same cancel step as the bookings screen. Refusals (a full class, a taken slot, the limit of 5 unconfirmed holds, a lapsed hold, a time no longer bookable, missing access) are shown in the screens' own words. Link straight to a business or one of its services with `screen={{ businessId }}` or `screen={{ businessId, eventTypeId }}`.
12
+
13
+ ### Changed
14
+
15
+ - **Breaking:** the screens open on booking. Without `screen` and `onNavigate`, the first screen is now `businesses`, the partner's businesses, instead of `bookings`; and `CustomerScreen` widens with `"businesses"`, `{ businessId }` and `{ businessId, eventTypeId }`, so a host whose `onNavigate` or `switch` covers only `bookings`, `passes` and `details` needs the new values. Pass `screen="bookings"` to keep opening on bookings.
16
+
7
17
  ## [0.1.0] - 2026-11-13
8
18
 
9
19
  ### Added
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MSM customer screens (`@msm-platform/customer-react`)
2
2
 
3
- MSM's customer screens as a React library, and their server half for the partner's own server. The screens cover phone sign-in and registration, bookings with cancellation, memberships and passes, and details (only the name is editable), with sign out and sign out everywhere. React and React DOM are peers; it does not use React Router. [`examples/customer-nextjs`](https://github.com/Sveittur/msm-platform/tree/main/examples/customer-nextjs) is the starter that mounts both halves, and the screens' dev host in this repository.
3
+ MSM's customer screens as a React library, and their server half for the partner's own server. The screens cover booking (the partner's businesses, a business's event types and a week of its availability, then hold, sign in if needed, confirm and cancel), phone sign-in and registration, bookings with cancellation, memberships and passes, and details (only the name is editable), with sign out and sign out everywhere. React and React DOM are peers; it does not use React Router. [`examples/customer-nextjs`](https://github.com/Sveittur/msm-platform/tree/main/examples/customer-nextjs) is the starter that mounts both halves, and the screens' dev host in this repository.
4
4
 
5
5
  ```sh
6
6
  npm install @msm-platform/customer-react
@@ -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, including `brand: {name, logo}` and `botCheck: {provider: "turnstile", siteKey}`; 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 `limiter`, `botCheck` and `clientIp` are required in every environment, and `createCustomerHandler` throws when one is missing.
13
+ What the changelog treats as breaking to rename or remove: the exports of `.` and `./server` and the stylesheet `./style.css`; the props below, 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 `limiter`, `botCheck` and `clientIp` are required in every environment, and `createCustomerHandler` throws when one is missing.
14
14
 
15
15
  ## The screens
16
16
 
@@ -28,15 +28,19 @@ import { MsmCustomer } from "@msm-platform/customer-react";
28
28
  />;
29
29
  ```
30
30
 
31
- | Prop | Meaning |
32
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
33
- | `basePath` | Where the server half is mounted, such as `/msm`. The screens call only `${basePath}/auth/*` and `${basePath}/engine/web/*`, with `X-MSM-BFF: 1`. |
34
- | `brand` | Optional `{name, logo}` for the header and sign-in. Loading it is the host's job. Colours come from CSS ([Theming](#theming)). |
35
- | `botCheck` | Required: `{ provider: "turnstile", siteKey }`, the partner's Cloudflare Turnstile site key. A plain object, so a server component can pass it. |
36
- | `screen`, `onNavigate` | `bookings`, `passes` or `details`. Leave both out and the package switches screens itself; pass both to drive it from the host's URL or router. |
31
+ | Prop | Meaning |
32
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33
+ | `basePath` | Where the server half is mounted, such as `/msm`. The screens call only `${basePath}/auth/*` and `${basePath}/engine/web/*`, with `X-MSM-BFF: 1`. |
34
+ | `brand` | Optional `{name, logo}` for the header and sign-in. Loading it is the host's job. Colours come from CSS ([Theming](#theming)). |
35
+ | `botCheck` | Required: `{ provider: "turnstile", siteKey }`, the partner's Cloudflare Turnstile site key. A plain object, so a server component can pass it. |
36
+ | `screen`, `onNavigate` | `businesses` (the default), `{ businessId }`, `{ businessId, eventTypeId }`, `bookings`, `passes` or `details`. Leave both out and the package switches screens itself; pass both to drive it from the host's URL or router, which also lets the partner's own pages link straight to a business or one of its event types. |
37
37
 
38
38
  The browser holds no credentials: the server half adds the client's and keeps the session in an encrypted HttpOnly cookie.
39
39
 
40
+ ### Booking
41
+
42
+ Browsing needs no session: the business list, a business and its availability are public reads. Availability shows a week at a time from today in the business's timezone, events with the seats left and open time slots in one list, narrowed to one event type when the screen names one. Choosing a time holds it; a customer who is signed out signs in or registers first, and the time they chose is held straight after. The hold lasts 10 minutes, the engine's hold, and confirming turns it into a booking, shown with the same cancel step and late-cancellation wording as the bookings screen. The engine's refusals are shown in the screens' own words, picked by their code: a full event, a taken slot, the limit of 5 unconfirmed holds, a hold that lapsed before confirming (with an offer to hold it again), a time that can no longer be booked, and an event type that needs a membership or pass. Payment is not part of booking yet.
43
+
40
44
  Before sending a code, sign-in and registration show Cloudflare Turnstile and send its token as `botCheckToken`. The widget's script (`https://challenges.cloudflare.com/turnstile/v0/api.js`) loads only in the phone step, so a Content Security Policy needs `https://challenges.cloudflare.com` in `script-src` and `frame-src`. Without a `botCheck` prop, sign-in says it isn't set up and sends nothing. In development, Cloudflare's test site key `1x00000000000000000000AA` always passes.
41
45
 
42
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).
@@ -0,0 +1,19 @@
1
+ import type { Business, Candidate } from "./client";
2
+ /** The candidate a customer chose to book, kept through sign-in. */
3
+ export interface Choice {
4
+ business: Business;
5
+ candidate: Candidate;
6
+ }
7
+ /** What the customer is booking: what, where, when and with whom. */
8
+ export declare function ChoiceSummary({ choice }: {
9
+ choice: Choice;
10
+ }): import("react").JSX.Element;
11
+ /**
12
+ * Books the chosen candidate for the signed-in customer: holds it at once,
13
+ * confirms it on the customer's word, then shows the booking with the same
14
+ * cancel step as the bookings screen. Refusals are in the package's words.
15
+ */
16
+ export declare function Booking(props: {
17
+ choice: Choice;
18
+ onBack: () => void;
19
+ }): import("react").JSX.Element;
package/dist/client.d.ts CHANGED
@@ -12,6 +12,9 @@ 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
14
  export type MyDetails = Ok<paths["/web/me"]["get"]>;
15
+ export type EventType = Ok<paths["/web/businesses/{businessId}/event-types"]["get"]>["items"][number];
16
+ /** One booking candidate: a seat in a scheduled event or an open time slot. */
17
+ export type Candidate = Ok<paths["/web/businesses/{businessId}/availability"]["get"]>["items"][number];
15
18
  /** The host's name and logo, which the host loads and passes in. */
16
19
  export interface CustomerBrand {
17
20
  name: string;
package/dist/context.d.ts CHANGED
@@ -1,12 +1,22 @@
1
1
  import type { CustomerClient } from "@msm-platform/customer-sdk";
2
2
  import type { Business } from "./client";
3
3
  import type { MessageKey } from "./i18n";
4
- /** The account screens; MVP-177 adds business and event-type pages beside them. */
5
- export type CustomerScreen = "bookings" | "passes" | "details";
4
+ /**
5
+ * The screen to show: the partner's businesses, one business (optionally
6
+ * narrowed to one event type), or one of the customer's account screens.
7
+ */
8
+ export type CustomerScreen = "businesses" | "bookings" | "passes" | "details" | {
9
+ businessId: string;
10
+ eventTypeId?: string;
11
+ };
6
12
  export interface Portal {
7
13
  client: CustomerClient;
8
14
  /** The partner's public businesses by ID; a business missing here is not public. */
9
15
  businesses: Map<string, Business>;
16
+ /** Whether `businesses` is complete, still loading or failed to load. */
17
+ businessesStatus: "loading" | "ready" | "failed";
18
+ reloadBusinesses: () => void;
19
+ navigate: (screen: CustomerScreen) => void;
10
20
  /** Ends the session on the server and returns to sign-in with this notice. */
11
21
  signOut: (notice?: MessageKey) => Promise<void>;
12
22
  }
package/dist/i18n.d.ts CHANGED
@@ -4,7 +4,9 @@ declare const en: {
4
4
  readonly "app.retry": "Try again";
5
5
  readonly "app.signedOut": "You were signed out because your session ended. Sign in again.";
6
6
  readonly "app.signedOutEverywhere": "You were signed out on every device.";
7
- readonly "nav.label": "My account";
7
+ readonly "nav.label": "Booking and my account";
8
+ readonly "nav.book": "Book";
9
+ readonly "nav.signIn": "Sign in";
8
10
  readonly "nav.bookings": "Bookings";
9
11
  readonly "nav.passes": "Passes";
10
12
  readonly "nav.details": "My details";
@@ -69,6 +71,45 @@ declare const en: {
69
71
  readonly "bookings.doneLate": "Your booking is cancelled. It counts as a late cancellation.";
70
72
  readonly "bookings.cancelFailed": "The booking could not be cancelled. Try again.";
71
73
  readonly "bookings.gone": "This booking no longer exists.";
74
+ readonly "businesses.heading": "Book";
75
+ readonly "businesses.intro": "Choose where you'd like to book.";
76
+ readonly "businesses.empty": "No businesses take bookings here yet.";
77
+ readonly "businesses.open": "See times";
78
+ readonly "business.all": "All businesses";
79
+ readonly "business.notFound": "This business isn't taking bookings here.";
80
+ readonly "business.types": "Services";
81
+ readonly "business.allTypes": "Everything";
82
+ readonly "business.typeMissing": "This service can't be booked here.";
83
+ readonly "business.minutes": "{minutes} min";
84
+ readonly "business.week": "Which week";
85
+ readonly "business.previousWeek": "Previous week";
86
+ readonly "business.nextWeek": "Next week";
87
+ readonly "business.weekOf": "{from} – {to}";
88
+ readonly "business.empty": "Nothing is open in these days.";
89
+ readonly "business.seatsLeft.one": "{count} seat left";
90
+ readonly "business.seatsLeft.other": "{count} seats left";
91
+ readonly "business.full": "Full";
92
+ readonly "business.openTime": "Open time";
93
+ readonly "business.with": "With {resource}";
94
+ readonly "business.book": "Book";
95
+ readonly "book.heading": "Your booking";
96
+ readonly "book.signInFirst": "Sign in or create an account to book this time.";
97
+ readonly "book.back": "Choose another time";
98
+ readonly "book.reserving": "Holding this time for you…";
99
+ readonly "book.heldUntil": "We're holding this time for you until {time}.";
100
+ readonly "book.confirm": "Confirm booking";
101
+ readonly "book.confirming": "Confirming…";
102
+ readonly "book.booked": "You're booked.";
103
+ readonly "book.toBookings": "See all my bookings";
104
+ readonly "book.reserveAgain": "Hold this time again";
105
+ readonly "book.full": "This class is full now. Choose another time.";
106
+ readonly "book.slotTaken": "Someone has just taken this time. Choose another.";
107
+ readonly "book.limit": "You already hold the most unconfirmed bookings allowed. Confirm one, or wait a few minutes for an unconfirmed one to lapse, then try again.";
108
+ readonly "book.expired": "We held this time for as long as we could, and it has lapsed. Hold it again if it's still free.";
109
+ readonly "book.notAllowed": "Booking this needs a membership or pass that covers it. Ask the business.";
110
+ readonly "book.unavailable": "This time can no longer be booked. Choose another.";
111
+ readonly "book.refused": "This business can't take your booking. Contact them.";
112
+ readonly "book.failed": "The booking could not be made. Try again.";
72
113
  readonly "passes.heading": "Memberships and passes";
73
114
  readonly "passes.empty": "You have no memberships or passes.";
74
115
  readonly "passes.unlimited": "Unlimited";
@@ -110,6 +151,8 @@ export declare function formatNumber(value: number): string;
110
151
  export declare function formatDateTime(iso: string, timeZone?: string): string;
111
152
  export declare function formatTime(iso: string, timeZone?: string): string;
112
153
  export declare function formatDate(iso: string, timeZone?: string): string;
154
+ /** A day as a heading, such as "Tuesday 1 December", in `timeZone`. */
155
+ export declare function formatDay(iso: string, timeZone?: string): string;
113
156
  /** A start and end, with the end's date left out when both fall on one day. */
114
157
  export declare function formatRange(start: string, end: string, timeZone?: string): string;
115
158
  /** Seconds under a minute, minutes under an hour, hours beyond that. */
package/dist/index.d.ts CHANGED
@@ -20,17 +20,21 @@ export interface MsmCustomerProps {
20
20
  */
21
21
  botCheck: CustomerBotCheck;
22
22
  /**
23
- * The screen to show. Leave both this and `onNavigate` out to let the
24
- * package switch screens itself; pass both to drive it from the host's
25
- * router or URL.
23
+ * The screen to show: `businesses` (the default), a business as
24
+ * `{ businessId }` or one of its event types as `{ businessId, eventTypeId }`,
25
+ * or `bookings`, `passes` or `details`. Leave both this and `onNavigate`
26
+ * out to let the package switch screens itself; pass both to drive it from
27
+ * the host's router or URL.
26
28
  */
27
29
  screen?: CustomerScreen;
28
30
  onNavigate?: (screen: CustomerScreen) => void;
29
31
  }
30
32
  /**
31
- * MSM's customer screens: phone sign-in and registration, then the
32
- * customer's bookings, passes and details. The server half keeps the session
33
- * in an encrypted HttpOnly cookie; the browser holds no credentials. Nothing here runs
34
- * before mount, so it renders on a server and imports without a browser.
33
+ * MSM's customer screens: the partner's businesses with their times to
34
+ * book, phone sign-in and registration when a booking or account screen
35
+ * needs it, then the customer's bookings, passes and details. The server
36
+ * half keeps the session in an encrypted HttpOnly cookie; the browser holds
37
+ * no credentials. Nothing here runs before mount, so it renders on a server
38
+ * and imports without a browser.
35
39
  */
36
40
  export declare function MsmCustomer(props: MsmCustomerProps): import("react").JSX.Element;