@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/dist/pay.d.ts ADDED
@@ -0,0 +1,125 @@
1
+ import { type paths } from "@msm-platform/customer-sdk";
2
+ import { type ReactNode } from "react";
3
+ import { type MessageKey, type MsmLocale } from "./i18n";
4
+ /** #544: a payment method the business shows online, in its order. */
5
+ export type MsmPaymentMethod = paths["/web/businesses/{businessId}/payment-methods"]["get"]["responses"][200]["content"]["application/json"]["items"][number];
6
+ /**
7
+ * How paying for a held reservation ended: booked, the hold released
8
+ * unpaid (or lapsed), or paid after the time was taken, for the business
9
+ * to settle with the customer.
10
+ */
11
+ export type MsmPayResult = {
12
+ status: "confirmed";
13
+ bookingId: string;
14
+ } | {
15
+ status: "released";
16
+ } | {
17
+ status: "unconfirmed_paid";
18
+ };
19
+ export interface MsmPayButtonsProps {
20
+ /** Where the server half is mounted, as for MsmCustomer. */
21
+ basePath: string;
22
+ businessId: string;
23
+ /** The signed-in customer's held reservation of a priced time. */
24
+ reservationId: string;
25
+ /** Called once with how paying ended. */
26
+ onResult: (result: MsmPayResult) => void;
27
+ /**
28
+ * #228: called just before this page goes to the provider's page. Keep
29
+ * what you need to show this reservation's pay piece again: the provider
30
+ * sends the customer back to this page with `msmCheckout` in its query,
31
+ * which the piece removes, and it resumes the checkout from there.
32
+ */
33
+ onLeave?: (() => void) | undefined;
34
+ /** MsmPayButtons' language, as for MsmCustomer; `useMsmPayment` has no copy. */
35
+ locale?: MsmLocale;
36
+ }
37
+ /**
38
+ * What the pay piece shows: the methods to pay with, the wait while a
39
+ * payment is read, a payment left unfinished, a refusal, or how it ended.
40
+ * `tab` is a payment tab the provider sent back, which only says to go
41
+ * back (`pay.tabDone`).
42
+ */
43
+ export type MsmPaymentState = {
44
+ phase: "loading";
45
+ } | {
46
+ phase: "choose";
47
+ methods: MsmPaymentMethod[];
48
+ /** While a payment page is being opened. */
49
+ paying: boolean;
50
+ notice?: MessageKey | undefined;
51
+ } | {
52
+ phase: "checking";
53
+ } | {
54
+ /** #333: paying in a tab of its own while this page reads the payment. */
55
+ phase: "away";
56
+ holdUntil: string;
57
+ redirectUrl: string;
58
+ /** Whether the tab opened; else the customer opens `redirectUrl`. */
59
+ opened: boolean;
60
+ } | {
61
+ phase: "unfinished";
62
+ holdUntil: string;
63
+ redirectUrl: string | null;
64
+ /** Whether `redirectUrl` opens in a tab of its own. */
65
+ newTab: boolean;
66
+ } | {
67
+ phase: "refused";
68
+ message: MessageKey;
69
+ /** When a ban ends, as an instant: the message's `{date}`. */
70
+ until?: string;
71
+ } | {
72
+ phase: "done";
73
+ result: MsmPayResult;
74
+ message: MessageKey;
75
+ } | {
76
+ phase: "tab";
77
+ };
78
+ export interface MsmPayment {
79
+ state: MsmPaymentState;
80
+ /**
81
+ * Pays the reservation through `method`, leaving for its provider's page
82
+ * or opening it in a tab of its own; without a method, a time with no
83
+ * advance is confirmed at once.
84
+ */
85
+ pay: (method?: MsmPaymentMethod) => void;
86
+ /** Call on a click of an unfinished payment's `redirectUrl`. */
87
+ payAgain: () => void;
88
+ }
89
+ /** Whether this page came back from a provider's payment page. */
90
+ export declare function cameBackFromCheckout(): boolean;
91
+ /**
92
+ * Pays for a held reservation: lists the business's online payment methods,
93
+ * starts the checkout, and reads it until it ends, back from the provider's
94
+ * page or, with a session in this page's memory, while the customer pays in
95
+ * a tab of its own. Reports how it ended once. A new reservation starts
96
+ * over. Inside one of the package's components it uses that component's
97
+ * client; on its own, the session on `basePath`.
98
+ */
99
+ export declare function useMsmPayment(props: MsmPayButtonsProps): MsmPayment;
100
+ /**
101
+ * The pay piece inside the package's components: `useMsmPayment`'s state
102
+ * in the package's words, with the host step's `terms` above the methods,
103
+ * its `actions` beside them, and `free` for a time with no advance, which
104
+ * books with Confirm booking.
105
+ */
106
+ export declare function PayButtons(props: {
107
+ businessId: string;
108
+ reservationId: string;
109
+ onResult: (result: MsmPayResult) => void;
110
+ onLeave?: (() => void) | undefined;
111
+ /** The business's timezone, when the host step knows it. */
112
+ timeZone?: string | undefined;
113
+ free?: boolean | undefined;
114
+ terms?: ReactNode;
115
+ actions?: ReactNode;
116
+ }): import("react").JSX.Element;
117
+ /**
118
+ * The "Pay with …" buttons for a reservation the host already holds for
119
+ * the signed-in customer, such as from its own class panel: the business's
120
+ * online payment methods in its order, then the provider's page and the
121
+ * result, as MsmBooking pays. With a cookieless server half the provider's
122
+ * page opens in a tab of its own; the provider sends that tab back to this
123
+ * page with `msmTab`, where the package's components only say to go back.
124
+ */
125
+ export declare function MsmPayButtons(props: MsmPayButtonsProps): import("react").JSX.Element;
package/dist/portal.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
2
  import { type CustomerScreen, type Portal } from "./context";
3
+ import { type MsmLocale } from "./i18n";
3
4
  /**
4
5
  * What every screen component shares: the session on `basePath`, the
5
6
  * client, the partner's public businesses and sign-out, as the `Portal`
@@ -26,5 +27,6 @@ export declare function useCustomerPortal(options: {
26
27
  export declare function CustomerRoot(props: {
27
28
  portal: Portal;
28
29
  loading: boolean;
30
+ locale: MsmLocale | undefined;
29
31
  children: ReactNode;
30
32
  }): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { MessageKey } from "./i18n";
2
+ /**
3
+ * The copy for a refused hold, confirmation or checkout: a ban gives when
4
+ * it ends (`until`), for the message's `{date}`, and every other refusal is
5
+ * picked by its code.
6
+ */
7
+ export declare function refusalOf(refusal: {
8
+ code: string | undefined;
9
+ body: unknown;
10
+ } | undefined, byCode: (code: string | undefined) => MessageKey): {
11
+ message: MessageKey;
12
+ until?: string;
13
+ };
14
+ export declare function confirmRefusal(code: string | undefined): MessageKey;
@@ -1,5 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { Business as BusinessDto, Candidate, EventType } from "../client";
3
+ import { type I18n } from "../i18n";
3
4
  /** The date of `at` in `timeZone`, as YYYY-MM-DD; today by default. */
4
5
  export declare function localDate(timeZone: string, at?: Date): string;
5
6
  /** The calendar date `count` days after `date` (YYYY-MM-DD). */
@@ -37,7 +38,37 @@ export declare function useCatalog(businessId: string): {
37
38
  width: number;
38
39
  } | null;
39
40
  longitude: number | null;
41
+ person: {
42
+ displayName: string;
43
+ image: {
44
+ height: number;
45
+ small: {
46
+ height: number;
47
+ url: string;
48
+ width: number;
49
+ };
50
+ url: string;
51
+ width: number;
52
+ } | null;
53
+ resourceId: string;
54
+ } | null;
40
55
  phone: string | null;
56
+ slug: string;
57
+ teachesAt: {
58
+ displayName: string;
59
+ id: string;
60
+ logo: {
61
+ height: number;
62
+ small: {
63
+ height: number;
64
+ url: string;
65
+ width: number;
66
+ };
67
+ url: string;
68
+ width: number;
69
+ } | null;
70
+ slug: string;
71
+ }[];
41
72
  timezone: string;
42
73
  } | null | undefined;
43
74
  types: {
@@ -85,6 +116,10 @@ export declare function useCatalog(businessId: string): {
85
116
  }[];
86
117
  tags: {
87
118
  colour: "red" | "orange" | "amber" | "lime" | "green" | "teal" | "cyan" | "blue" | "indigo" | "purple" | "pink" | "slate";
119
+ group: {
120
+ name: string;
121
+ slug: string;
122
+ } | null;
88
123
  id: string;
89
124
  name: string;
90
125
  slug: string;
@@ -98,7 +133,7 @@ export declare function useCatalog(businessId: string): {
98
133
  * The screen for a catalog that has not loaded: it failed, the business is
99
134
  * not public here, or it is still loading. Undefined once it has loaded.
100
135
  */
101
- export declare function pendingCatalog(catalog: Catalog, back: ReactNode): import("react").JSX.Element | undefined;
136
+ export declare function pendingCatalog(catalog: Catalog, back: ReactNode, t: I18n["t"]): import("react").JSX.Element | undefined;
102
137
  /** The resources that provide `types`, each once, in the order they appear. */
103
138
  export declare function resourcesOf(types: EventType[]): {
104
139
  description: string | null;
@@ -1,4 +1,5 @@
1
1
  import type { CustomerBotCheck, CustomerBrand } from "./client";
2
+ import { type MsmLocale } from "./i18n";
2
3
  export interface MsmSignInProps {
3
4
  /** Where the server half is mounted, as for MsmCustomer. */
4
5
  basePath: string;
@@ -18,6 +19,8 @@ export interface MsmSignInProps {
18
19
  * here or in another of the package's components on the same `basePath`.
19
20
  */
20
21
  onSessionChange?: (signedIn: boolean) => void;
22
+ /** The screens' language, as for MsmCustomer. */
23
+ locale?: MsmLocale;
21
24
  }
22
25
  /**
23
26
  * Phone sign-in and registration on their own, for a host's modal. It
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@msm-platform/customer-react",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "MSM's customer screens for React, and their server half for a partner's server",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@msm-platform/customer-sdk": "^0.5.0",
34
+ "@msm-platform/customer-sdk": "^0.5.1",
35
35
  "libphonenumber-js": "^1.13.15"
36
36
  },
37
37
  "peerDependencies": {