@asksable/site-connector 0.1.5 → 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.
@@ -1,9 +1,83 @@
1
1
  import { type ReactNode } from 'react';
2
+ /**
3
+ * Pre-existing context required by reschedule mode. The host (or the
4
+ * customer arriving via magic link) is moving an existing booking, so
5
+ * the widget needs to know what booking is being moved and any data
6
+ * that should pre-fill or lock down the form.
7
+ */
8
+ export type BookingRescheduleContext = {
9
+ appointmentId: string;
10
+ /** Original startTime (ms epoch) of the booking being moved. Shown
11
+ * as crossed-out in the sidebar so the user knows what they're
12
+ * giving up. */
13
+ formerStartTime: number;
14
+ formerEndTime: number;
15
+ /** Locked service for the reschedule — cannot be changed without
16
+ * cancelling and re-booking. */
17
+ serviceId: string;
18
+ /** Optional staff lock. When set, the staff picker is pre-filled
19
+ * to this member; when omitted the widget falls back to "any
20
+ * available". */
21
+ staffMemberId?: string;
22
+ /** Pre-fill values for the contact form, sourced from the original
23
+ * appointment's customer record. */
24
+ customerName?: string;
25
+ customerEmail?: string;
26
+ customerPhone?: string;
27
+ /** Display label for the sidebar's "Reschedule by" line, sourced
28
+ * from the original appointment record (host display name). */
29
+ rescheduledByName?: string;
30
+ };
2
31
  type BookingWidgetProps = {
3
32
  title?: string;
4
33
  description?: string;
5
34
  mobileHeader?: ReactNode;
35
+ /**
36
+ * Widget mode. 'create' (default) is the original behavior. In
37
+ * 'reschedule' mode the widget pre-fills service/staff/customer
38
+ * from `rescheduleContext`, swaps the CTA copy, and routes the
39
+ * submit through `onRescheduleSubmit` instead of the public-create
40
+ * mutation. Adding this as an opt-in prop keeps the npm package
41
+ * fully backward compatible — every existing consumer that omits
42
+ * `mode` continues to behave exactly as before.
43
+ */
44
+ mode?: 'create' | 'reschedule';
45
+ rescheduleContext?: BookingRescheduleContext;
46
+ /**
47
+ * Submit handler for reschedule mode. Receives the new slot the
48
+ * user picked. The host pages this through `api.appointments
49
+ * .rescheduleAppointment` (admin path) or a magic-link-protected
50
+ * public mutation (customer path). Required when `mode` is
51
+ * 'reschedule'.
52
+ */
53
+ onRescheduleSubmit?: (args: {
54
+ newStartTime: number;
55
+ newEndTime: number;
56
+ }) => Promise<void>;
57
+ /**
58
+ * Destination for the success-state CTA after a new booking is submitted.
59
+ * Defaults to the host site's home page so embedded sites don't trap the
60
+ * customer back on `/booking` after the thank-you state.
61
+ */
62
+ successRedirectHref?: string;
63
+ /**
64
+ * Dev-only: forces the widget into a terminal state without
65
+ * calling any backend mutation. Used by the dev preview page to
66
+ * iterate on success/cancel visuals without spinning through the
67
+ * form each time. Strip from prod surfaces — these never call any
68
+ * backend.
69
+ *
70
+ * - `'success'`: renders the "You're All Set!" view (or the
71
+ * reschedule variant when `mode === 'reschedule'`).
72
+ * - `'cancelled'`: renders the "Booking cancelled" view (preview
73
+ * only — the customer-side cancel mutation isn't built yet).
74
+ *
75
+ * The legacy `__devForceSuccess` boolean is still accepted for
76
+ * back-compat with surfaces that use the old prop.
77
+ */
78
+ __devForceState?: 'success' | 'cancelled' | 'payment-full' | 'payment-deposit';
79
+ __devForceSuccess?: boolean;
6
80
  };
7
- export declare function BookingWidgetPanel({ title, description, mobileHeader, }: BookingWidgetProps): import("react/jsx-runtime").JSX.Element;
81
+ export declare function BookingWidgetPanel({ title, description, mobileHeader, mode, rescheduleContext, onRescheduleSubmit, successRedirectHref, __devForceState, __devForceSuccess, }: BookingWidgetProps): import("react/jsx-runtime").JSX.Element;
8
82
  export {};
9
83
  //# sourceMappingURL=booking-widget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"booking-widget.d.ts","sourceRoot":"","sources":["../src/booking-widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAOnG,KAAK,kBAAkB,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,S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