@wix/bookings 1.0.1754 → 1.0.1756
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/_sdk-exports/context-booking-checkout/runtime.d.ts +791 -143
- package/_sdk-exports/context-booking-checkout/runtime.js +3 -2
- package/_sdk-exports/context-categories/runtime.d.ts +164 -2
- package/_sdk-exports/context-categories/runtime.js +2 -1
- package/_sdk-exports/context-locations/runtime.d.ts +186 -2
- package/_sdk-exports/context-locations/runtime.js +2 -1
- package/_sdk-exports/context-service/runtime.d.ts +1540 -144
- package/_sdk-exports/context-service/runtime.js +3 -2
- package/_sdk-exports/context-service-addons/runtime.d.ts +215 -13
- package/_sdk-exports/context-service-addons/runtime.js +2 -1
- package/_sdk-exports/context-services/runtime.d.ts +371 -77
- package/_sdk-exports/context-services/runtime.js +3 -2
- package/_sdk-exports/context-time-slots/runtime.d.ts +854 -72
- package/_sdk-exports/context-time-slots/runtime.js +3 -2
- package/build/cjs/context-booking-checkout.d.ts +791 -143
- package/build/cjs/context-booking-checkout.js +1759 -1640
- package/build/cjs/context-booking-checkout.js.map +1 -1
- package/build/cjs/context-categories.d.ts +164 -2
- package/build/cjs/context-categories.js +116 -114
- package/build/cjs/context-categories.js.map +1 -1
- package/build/cjs/context-locations.d.ts +186 -2
- package/build/cjs/context-locations.js +126 -124
- package/build/cjs/context-locations.js.map +1 -1
- package/build/cjs/context-service-addons.d.ts +215 -13
- package/build/cjs/context-service-addons.js +323 -321
- package/build/cjs/context-service-addons.js.map +1 -1
- package/build/cjs/context-service.d.ts +1540 -144
- package/build/cjs/context-service.js +1622 -1616
- package/build/cjs/context-service.js.map +1 -1
- package/build/cjs/context-services.d.ts +371 -77
- package/build/cjs/context-services.js +460 -458
- package/build/cjs/context-services.js.map +1 -1
- package/build/cjs/context-time-slots.d.ts +854 -72
- package/build/cjs/context-time-slots.js +1033 -1000
- package/build/cjs/context-time-slots.js.map +1 -1
- package/build/es/context-booking-checkout.d.mts +791 -143
- package/build/es/context-booking-checkout.mjs +1778 -1650
- package/build/es/context-booking-checkout.mjs.map +1 -1
- package/build/es/context-categories.d.mts +164 -2
- package/build/es/context-categories.mjs +116 -114
- package/build/es/context-categories.mjs.map +1 -1
- package/build/es/context-locations.d.mts +186 -2
- package/build/es/context-locations.mjs +126 -124
- package/build/es/context-locations.mjs.map +1 -1
- package/build/es/context-service-addons.d.mts +215 -13
- package/build/es/context-service-addons.mjs +323 -321
- package/build/es/context-service-addons.mjs.map +1 -1
- package/build/es/context-service.d.mts +1540 -144
- package/build/es/context-service.mjs +1622 -1616
- package/build/es/context-service.mjs.map +1 -1
- package/build/es/context-services.d.mts +371 -77
- package/build/es/context-services.mjs +460 -458
- package/build/es/context-services.mjs.map +1 -1
- package/build/es/context-time-slots.d.mts +854 -72
- package/build/es/context-time-slots.mjs +1033 -1000
- package/build/es/context-time-slots.mjs.map +1 -1
- package/build/internal/cjs/context-booking-checkout.d.ts +791 -143
- package/build/internal/cjs/context-categories.d.ts +164 -2
- package/build/internal/cjs/context-locations.d.ts +186 -2
- package/build/internal/cjs/context-service-addons.d.ts +215 -13
- package/build/internal/cjs/context-service.d.ts +1540 -144
- package/build/internal/cjs/context-services.d.ts +371 -77
- package/build/internal/cjs/context-time-slots.d.ts +854 -72
- package/build/internal/es/context-booking-checkout.d.mts +791 -143
- package/build/internal/es/context-categories.d.mts +164 -2
- package/build/internal/es/context-locations.d.mts +186 -2
- package/build/internal/es/context-service-addons.d.mts +215 -13
- package/build/internal/es/context-service.d.mts +1540 -144
- package/build/internal/es/context-services.d.mts +371 -77
- package/build/internal/es/context-time-slots.d.mts +854 -72
- package/package.json +5 -5
|
@@ -72,7 +72,7 @@ declare global {
|
|
|
72
72
|
* You can use it to offer customers different prices for a service,
|
|
73
73
|
* depending on which choices they book.
|
|
74
74
|
*/
|
|
75
|
-
interface ServiceOptionsAndVariants
|
|
75
|
+
interface ServiceOptionsAndVariants {
|
|
76
76
|
/**
|
|
77
77
|
* ID of the `serviceOptionsAndVariants` object.
|
|
78
78
|
* @format GUID
|
|
@@ -155,6 +155,11 @@ declare enum ServiceOptionType {
|
|
|
155
155
|
* @documentationMaturity preview
|
|
156
156
|
*/
|
|
157
157
|
NUMBER_OF_PARTICIPANTS = "NUMBER_OF_PARTICIPANTS",
|
|
158
|
+
/**
|
|
159
|
+
* The price is resolved by the business location the service is booked at.
|
|
160
|
+
* @documentationMaturity preview
|
|
161
|
+
*/
|
|
162
|
+
LOCATION = "LOCATION",
|
|
158
163
|
/**
|
|
159
164
|
* The price is resolved from pricing tiers based on the booking duration range.
|
|
160
165
|
* @documentationMaturity preview
|
|
@@ -162,7 +167,7 @@ declare enum ServiceOptionType {
|
|
|
162
167
|
DURATION_RANGE = "DURATION_RANGE"
|
|
163
168
|
}
|
|
164
169
|
/** @enumType */
|
|
165
|
-
type ServiceOptionTypeWithLiterals = ServiceOptionType | 'UNKNOWN' | 'CUSTOM' | 'STAFF_MEMBER' | 'DURATION' | 'DATE_TIME' | 'NUMBER_OF_PARTICIPANTS' | 'DURATION_RANGE';
|
|
170
|
+
type ServiceOptionTypeWithLiterals = ServiceOptionType | 'UNKNOWN' | 'CUSTOM' | 'STAFF_MEMBER' | 'DURATION' | 'DATE_TIME' | 'NUMBER_OF_PARTICIPANTS' | 'LOCATION' | 'DURATION_RANGE';
|
|
166
171
|
interface CustomServiceOption {
|
|
167
172
|
/**
|
|
168
173
|
* Name of the service option. For example, `Age group`, `Location`, `Equipment`,
|
|
@@ -223,6 +228,14 @@ interface ServiceChoice$1 extends ServiceChoiceChoiceOneOf$1 {
|
|
|
223
228
|
dateTime?: DateTimeRule$1;
|
|
224
229
|
/** A rule resolving the price by the number of participants. Available only for `NUMBER_OF_PARTICIPANTS` options. */
|
|
225
230
|
participantRange?: ParticipantsRange$1;
|
|
231
|
+
/**
|
|
232
|
+
* ID of the business location the price applies to.
|
|
233
|
+
*
|
|
234
|
+
* Limited to business locations. Custom and customer locations aren't supported.
|
|
235
|
+
* Available only for `LOCATION` options.
|
|
236
|
+
* @format GUID
|
|
237
|
+
*/
|
|
238
|
+
businessLocationId?: string;
|
|
226
239
|
/**
|
|
227
240
|
* A duration range tier resolving the price by how long the booking is.
|
|
228
241
|
* Available only for `DURATION_RANGE` options.
|
|
@@ -254,6 +267,14 @@ interface ServiceChoiceChoiceOneOf$1 {
|
|
|
254
267
|
dateTime?: DateTimeRule$1;
|
|
255
268
|
/** A rule resolving the price by the number of participants. Available only for `NUMBER_OF_PARTICIPANTS` options. */
|
|
256
269
|
participantRange?: ParticipantsRange$1;
|
|
270
|
+
/**
|
|
271
|
+
* ID of the business location the price applies to.
|
|
272
|
+
*
|
|
273
|
+
* Limited to business locations. Custom and customer locations aren't supported.
|
|
274
|
+
* Available only for `LOCATION` options.
|
|
275
|
+
* @format GUID
|
|
276
|
+
*/
|
|
277
|
+
businessLocationId?: string;
|
|
257
278
|
/**
|
|
258
279
|
* A duration range tier resolving the price by how long the booking is.
|
|
259
280
|
* Available only for `DURATION_RANGE` options.
|
|
@@ -503,9 +524,9 @@ interface ExtendedFields$1 {
|
|
|
503
524
|
namespaces?: Record<string, Record<string, any>>;
|
|
504
525
|
}
|
|
505
526
|
//#endregion
|
|
506
|
-
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-
|
|
527
|
+
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-p5eQUd5f.d.mts
|
|
507
528
|
/** The `service` object represents an offering that a business provides to its customers. */
|
|
508
|
-
interface Service
|
|
529
|
+
interface Service {
|
|
509
530
|
/**
|
|
510
531
|
* Service ID.
|
|
511
532
|
* @format GUID
|
|
@@ -878,6 +899,12 @@ interface FixedPayment {
|
|
|
878
899
|
* Default: `false`.
|
|
879
900
|
*/
|
|
880
901
|
fullUpfrontPaymentAllowed?: boolean | null;
|
|
902
|
+
/**
|
|
903
|
+
* The deposit required to book the service, expressed as either a fixed amount or a percentage of the price.
|
|
904
|
+
*
|
|
905
|
+
* Used only when `paymentOptions.deposit` is `true`.
|
|
906
|
+
*/
|
|
907
|
+
depositDetails?: DepositDetails;
|
|
881
908
|
}
|
|
882
909
|
/**
|
|
883
910
|
* Money.
|
|
@@ -906,6 +933,35 @@ interface Money$1 {
|
|
|
906
933
|
* A deposit expressed as exactly one of a fixed monetary amount or a percentage of the full service price.
|
|
907
934
|
* Structurally exclusive: at most one of `amount` or `percentage` may be set.
|
|
908
935
|
*/
|
|
936
|
+
interface DepositDetails extends DepositDetailsValueOneOf {
|
|
937
|
+
/** The deposit as a fixed monetary amount. */
|
|
938
|
+
amount?: Money$1;
|
|
939
|
+
/**
|
|
940
|
+
* The deposit as a percentage of the full service price, for example `20` for 20% or `20.5` for 20.5%.
|
|
941
|
+
* Resolved to a concrete amount when the customer books.
|
|
942
|
+
*
|
|
943
|
+
* Min: `0.01` percent
|
|
944
|
+
* Max: `99.99` percent
|
|
945
|
+
* @format DECIMAL_VALUE
|
|
946
|
+
* @decimalValue options { gte:0.01, lte:99.99, maxScale:2 }
|
|
947
|
+
*/
|
|
948
|
+
percentage?: string | null;
|
|
949
|
+
}
|
|
950
|
+
/** @oneof */
|
|
951
|
+
interface DepositDetailsValueOneOf {
|
|
952
|
+
/** The deposit as a fixed monetary amount. */
|
|
953
|
+
amount?: Money$1;
|
|
954
|
+
/**
|
|
955
|
+
* The deposit as a percentage of the full service price, for example `20` for 20% or `20.5` for 20.5%.
|
|
956
|
+
* Resolved to a concrete amount when the customer books.
|
|
957
|
+
*
|
|
958
|
+
* Min: `0.01` percent
|
|
959
|
+
* Max: `99.99` percent
|
|
960
|
+
* @format DECIMAL_VALUE
|
|
961
|
+
* @decimalValue options { gte:0.01, lte:99.99, maxScale:2 }
|
|
962
|
+
*/
|
|
963
|
+
percentage?: string | null;
|
|
964
|
+
}
|
|
909
965
|
interface CustomPayment {
|
|
910
966
|
/**
|
|
911
967
|
* A custom description explaining to the customer how to pay for the service.
|
|
@@ -940,6 +996,12 @@ interface VariedPayment {
|
|
|
940
996
|
* Default: `false`.
|
|
941
997
|
*/
|
|
942
998
|
fullUpfrontPaymentAllowed?: boolean | null;
|
|
999
|
+
/**
|
|
1000
|
+
* The deposit required to book the service, expressed as either a fixed amount or a percentage of the price.
|
|
1001
|
+
*
|
|
1002
|
+
* Used only when `paymentOptions.deposit` is `true`.
|
|
1003
|
+
*/
|
|
1004
|
+
depositDetails?: DepositDetails;
|
|
943
1005
|
}
|
|
944
1006
|
interface SubscriptionPayment {
|
|
945
1007
|
/**
|
|
@@ -1549,6 +1611,7 @@ interface CancellationFeePolicy {
|
|
|
1549
1611
|
*/
|
|
1550
1612
|
autoCollectFeeEnabled?: boolean | null;
|
|
1551
1613
|
}
|
|
1614
|
+
/** What happens to the plan credit when the customer cancels a booking paid with a pricing plan. */
|
|
1552
1615
|
interface CancellationWindow extends CancellationWindowFeeOneOf {
|
|
1553
1616
|
/** Amount to be charged as a cancellation fee. */
|
|
1554
1617
|
amount?: Money$1;
|
|
@@ -1757,12 +1820,7 @@ interface DailyConfig {
|
|
|
1757
1820
|
*/
|
|
1758
1821
|
maxDurationInDays?: number;
|
|
1759
1822
|
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Controls how a service's own working hours combine with the working hours of its assigned
|
|
1762
|
-
* staff members and required resources. The hours themselves are not held here. They are the
|
|
1763
|
-
* `WORKING_HOURS` events on the service's schedule (`schedule.id`), and this message controls
|
|
1764
|
-
* only how they combine with the resources working hours.
|
|
1765
|
-
*/
|
|
1823
|
+
/** Times of day at which each bookable day of a daily service starts and ends. */
|
|
1766
1824
|
interface StaffMember {
|
|
1767
1825
|
/**
|
|
1768
1826
|
* ID of the [resource](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/introduction) associated with the staff member providing the service.
|
|
@@ -1784,6 +1842,14 @@ interface StaffMember {
|
|
|
1784
1842
|
* @readonly
|
|
1785
1843
|
*/
|
|
1786
1844
|
mainMedia?: StaffMediaItem;
|
|
1845
|
+
/**
|
|
1846
|
+
* Business locations where the staff member is available, based on their working hours.
|
|
1847
|
+
* Returned only when both `STAFF_MEMBER_DETAILS` and `STAFF_WORKING_HOURS_LOCATIONS` are passed in `conditionalFields`.
|
|
1848
|
+
* Can be omitted for a staff member who has no working hours. Treat a missing value the same as `availableAtAllLocations` set to `false` with an empty `locationIds`.
|
|
1849
|
+
* When the working hours data can't be retrieved, the entire request fails.
|
|
1850
|
+
* @readonly
|
|
1851
|
+
*/
|
|
1852
|
+
workingHoursLocationCoverage?: WorkingHoursLocationCoverage;
|
|
1787
1853
|
}
|
|
1788
1854
|
interface StaffMediaItem extends StaffMediaItemItemOneOf {
|
|
1789
1855
|
/** Details of the image associated with the staff, such as URL and size. */
|
|
@@ -1795,24 +1861,29 @@ interface StaffMediaItemItemOneOf {
|
|
|
1795
1861
|
image?: string;
|
|
1796
1862
|
}
|
|
1797
1863
|
/**
|
|
1798
|
-
*
|
|
1799
|
-
* (`NONE` and `MASTER` recurrence types). The server paginates through Calendar results
|
|
1800
|
-
* (100 events per page) until all matching events are collected.
|
|
1801
|
-
*
|
|
1802
|
-
* Coverage states when enrichment is requested:
|
|
1803
|
-
* + `available_at_all_locations = true`: Staff applies to every business location. Set when the staff
|
|
1804
|
-
* uses default business working hours, or has any WORKING_HOURS event without a location ID
|
|
1805
|
-
* (including when mixed with location-specific events).
|
|
1806
|
-
* + `available_at_all_locations = false` with non-empty `location_ids`: Staff has location-specific
|
|
1807
|
-
* WORKING_HOURS only. Show the staff member only when the selected location is in `location_ids`.
|
|
1808
|
-
* + `available_at_all_locations = false` with empty `location_ids`: Staff has working-hours schedules
|
|
1809
|
-
* but no applicable location coverage was found.
|
|
1864
|
+
* Business locations where a staff member is available, based on their current and upcoming working hours.
|
|
1810
1865
|
*
|
|
1811
|
-
*
|
|
1812
|
-
* `availableAtAllLocations
|
|
1813
|
-
*
|
|
1814
|
-
*
|
|
1866
|
+
* Coverage has 3 possible states:
|
|
1867
|
+
* + `availableAtAllLocations` is `true`: The staff member is available at every business location. This is the case when the staff member uses the business's default working hours, or when at least one of their working hours isn't limited to a specific location.
|
|
1868
|
+
* + `availableAtAllLocations` is `false` and `locationIds` isn't empty: The staff member is available at the business locations listed in `locationIds`.
|
|
1869
|
+
* + `availableAtAllLocations` is `false` and `locationIds` is empty: The staff member has no current or upcoming working hours, so they aren't available at any business location.
|
|
1870
|
+
* To check whether a staff member is available at a specific location, use `availableAtAllLocations || locationIds.includes(locationId)`.
|
|
1815
1871
|
*/
|
|
1872
|
+
interface WorkingHoursLocationCoverage {
|
|
1873
|
+
/**
|
|
1874
|
+
* Whether the staff member is available at every business location.
|
|
1875
|
+
* @readonly
|
|
1876
|
+
*/
|
|
1877
|
+
availableAtAllLocations?: boolean | null;
|
|
1878
|
+
/**
|
|
1879
|
+
* IDs of the business locations where the staff member has location-specific working hours.
|
|
1880
|
+
* Empty when `availableAtAllLocations` is `true`.
|
|
1881
|
+
* @format GUID
|
|
1882
|
+
* @readonly
|
|
1883
|
+
* @maxSize 100
|
|
1884
|
+
*/
|
|
1885
|
+
locationIds?: string[];
|
|
1886
|
+
}
|
|
1816
1887
|
interface StaffMemberDetails {
|
|
1817
1888
|
/**
|
|
1818
1889
|
* Staff members providing the service. For appointments only.
|
|
@@ -1912,73 +1983,117 @@ interface ExtendedFields {
|
|
|
1912
1983
|
namespaces?: Record<string, Record<string, any>>;
|
|
1913
1984
|
}
|
|
1914
1985
|
/**
|
|
1915
|
-
* The SEO
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1986
|
+
* The SEO data for a single page or dynamic item, in the shape stored today.
|
|
1987
|
+
*
|
|
1988
|
+
* FROZEN. Existing server code maps onto this message field by field, so its
|
|
1989
|
+
* field set must never change (see the file header). New writers use
|
|
1990
|
+
* `SeoSchemaV2`.
|
|
1991
|
+
*
|
|
1992
|
+
* These tags are rendered into the <head> of the HTML document and are not
|
|
1993
|
+
* visible on the page itself. They override every other source of tags
|
|
1994
|
+
* (site defaults, vertical presets, patterns) for this page.
|
|
1918
1995
|
*/
|
|
1919
1996
|
interface SeoSchema {
|
|
1920
|
-
/**
|
|
1997
|
+
/**
|
|
1998
|
+
* The tags rendered into <head>, in no particular order. Render order is
|
|
1999
|
+
* decided by the renderer, not by position in this list.
|
|
2000
|
+
*
|
|
2001
|
+
* No maxSize: this list is already populated by data written years ago, and
|
|
2002
|
+
* a bound added now could reject a page that is already stored.
|
|
2003
|
+
*/
|
|
1921
2004
|
tags?: Tag[];
|
|
1922
|
-
/** SEO
|
|
2005
|
+
/** Page-level SEO settings that are not themselves tags. */
|
|
1923
2006
|
settings?: Settings;
|
|
1924
2007
|
}
|
|
2008
|
+
/** A keyword term the user is targeting. */
|
|
1925
2009
|
interface Keyword {
|
|
1926
|
-
/**
|
|
2010
|
+
/**
|
|
2011
|
+
* The term itself, e.g. "trail running shoes".
|
|
2012
|
+
*
|
|
2013
|
+
* No maxLength, for the same reason as the legacy tag fields: keywords are
|
|
2014
|
+
* already stored, and a bound added now could reject a record written
|
|
2015
|
+
* before the bound existed. The flynt `missing-string-validations` warning
|
|
2016
|
+
* on this field is accepted deliberately.
|
|
2017
|
+
*/
|
|
1927
2018
|
term?: string;
|
|
1928
|
-
/** Whether
|
|
2019
|
+
/** Whether this is the page's primary focus keyword. At most one per page. */
|
|
1929
2020
|
isMain?: boolean;
|
|
1930
2021
|
/**
|
|
1931
|
-
*
|
|
2022
|
+
* Which surface added the term, e.g. a panel or a suggestion flow. Used for
|
|
2023
|
+
* attribution in BI. Opaque to the renderer.
|
|
1932
2024
|
* @maxLength 1000
|
|
1933
2025
|
*/
|
|
1934
2026
|
origin?: string | null;
|
|
1935
2027
|
}
|
|
2028
|
+
/**
|
|
2029
|
+
* One tag in the page's <head>.
|
|
2030
|
+
*
|
|
2031
|
+
* Not deprecated, and with no removal date, deliberately: stored data is
|
|
2032
|
+
* never migrated, so this shape stays valid input forever. `seo-renderer`
|
|
2033
|
+
* normalizes both shapes on READ.
|
|
2034
|
+
*/
|
|
1936
2035
|
interface Tag {
|
|
1937
2036
|
/**
|
|
1938
|
-
*
|
|
1939
|
-
*
|
|
1940
|
-
*
|
|
1941
|
-
* Supported values: `title`, `meta`, `script`, `link`.
|
|
2037
|
+
* Legacy. Was a free-form string: "title" | "meta" | "script" | "link".
|
|
2038
|
+
* The typed replacement is the `kind` oneof on `SeoSchemaV2.Tag`, which makes
|
|
2039
|
+
* the invalid combinations unrepresentable rather than merely discouraged.
|
|
1942
2040
|
*
|
|
1943
|
-
* Which of these an API actually accepts depends on where the tag is being
|
|
1944
|
-
* list is not a blanket guarantee across every API that reuses
|
|
1945
|
-
* Tags in particular accepts only `meta` (see
|
|
1946
|
-
* `title`/`script`/`link` with a validation
|
|
1947
|
-
*
|
|
1948
|
-
*
|
|
2041
|
+
* Which of these an API actually accepts depends on where the tag is being
|
|
2042
|
+
* set: this list is not a blanket guarantee across every API that reuses
|
|
2043
|
+
* this message. Site SEO Tags in particular accepts only `meta` (see
|
|
2044
|
+
* `SiteSeoTags.tags`) and rejects `title`/`script`/`link` with a validation
|
|
2045
|
+
* error even though they appear here — check the field description of the
|
|
2046
|
+
* specific `tags`-typed field you are writing to.
|
|
1949
2047
|
*
|
|
1950
2048
|
* Limitation: `title` and `script` (e.g. a `script` tag with `props.type`
|
|
1951
|
-
*
|
|
1952
|
-
* `custom` is unset or `false`. Setting `custom: true` on a `title` or
|
|
1953
|
-
* tag is rejected with `TAG_TYPE_NOT_ALLOWED`, because
|
|
1954
|
-
* write through the site's Advanced/Custom Tags
|
|
1955
|
-
* omit `custom` (or set it to `false`).
|
|
2049
|
+
* "application/ld+json" carrying structured data) are supported only when
|
|
2050
|
+
* `custom` is unset or `false`. Setting `custom: true` on a `title` or
|
|
2051
|
+
* `script` tag is rejected with `TAG_TYPE_NOT_ALLOWED`, because
|
|
2052
|
+
* `custom: true` routes the write through the site's Advanced/Custom Tags
|
|
2053
|
+
* list. To write structured data, omit `custom` (or set it to `false`).
|
|
2054
|
+
*
|
|
2055
|
+
* No length limit: this field holds data written years ago by writers we
|
|
2056
|
+
* are not migrating. A constraint here could reject a record that is
|
|
2057
|
+
* already stored, which is exactly the promise this design makes.
|
|
1956
2058
|
*/
|
|
1957
2059
|
type?: string;
|
|
1958
2060
|
/**
|
|
1959
|
-
*
|
|
1960
|
-
*
|
|
2061
|
+
* Legacy. Was an untyped bag of HTML attributes.
|
|
2062
|
+
* Typed replacement: `SeoSchemaV2.TitleTag` / `MetaTag` / `LinkTag`.
|
|
1961
2063
|
*/
|
|
1962
2064
|
props?: Record<string, any> | null;
|
|
1963
|
-
/**
|
|
2065
|
+
/**
|
|
2066
|
+
* Legacy. Was an untyped bag of 16 mixed-purpose keys. In `SeoSchemaV2`
|
|
2067
|
+
* its contents are split by purpose: per-page structured-data state moves to
|
|
2068
|
+
* StructuredDataTag, authorship to `written_by`, and render-time preset
|
|
2069
|
+
* logic (variants, enabledByExperiment, removeSchemaIf*) moved out of the
|
|
2070
|
+
* stored document entirely — it belongs to the preset definition, not to the
|
|
2071
|
+
* page. See the design log for the full key-by-key mapping.
|
|
2072
|
+
*/
|
|
1964
2073
|
meta?: Record<string, any> | null;
|
|
1965
|
-
/**
|
|
2074
|
+
/**
|
|
2075
|
+
* Legacy. Was the tag's inner content, doubling as the JSON-LD payload
|
|
2076
|
+
* for script tags. Typed replacement: `SeoSchemaV2.TitleTag.text` and
|
|
2077
|
+
* `StructuredDataTag.json_ld`.
|
|
2078
|
+
* No length limit, for the same reason as `type` above.
|
|
2079
|
+
*/
|
|
1966
2080
|
children?: string;
|
|
1967
2081
|
/**
|
|
1968
2082
|
* Whether the tag is a [custom tag](https://support.wix.com/en/article/adding-additional-meta-tags-to-your-sites-pages) —
|
|
1969
2083
|
* i.e. an entry from the site's Advanced/Custom Tags list.
|
|
1970
2084
|
*
|
|
1971
|
-
* Setting this to `true` on a write restricts which `type` values are
|
|
1972
|
-
* — the same restriction the Advanced/Custom Tags UI enforces.
|
|
1973
|
-
* `script` tags (including JSON-LD structured data) must be sent
|
|
1974
|
-
* omitted or `false`; sending them with `custom: true` is
|
|
1975
|
-
* `TAG_TYPE_NOT_ALLOWED`.
|
|
2085
|
+
* Setting this to `true` on a write restricts which `type` values are
|
|
2086
|
+
* accepted — the same restriction the Advanced/Custom Tags UI enforces.
|
|
2087
|
+
* `title` and `script` tags (including JSON-LD structured data) must be sent
|
|
2088
|
+
* with `custom` omitted or `false`; sending them with `custom: true` is
|
|
2089
|
+
* rejected with `TAG_TYPE_NOT_ALLOWED`.
|
|
1976
2090
|
*
|
|
1977
|
-
* Note this is a separate restriction from Site SEO Tags' own type
|
|
1978
|
-
* `SiteSeoTags.tags`: even with `custom` unset, Site SEO Tags
|
|
1979
|
-
* for site-wide structured data) unconditionally.
|
|
1980
|
-
* site-wide, every-page structured data
|
|
1981
|
-
* `script` tag through the Item
|
|
2091
|
+
* Note this is a separate restriction from Site SEO Tags' own type
|
|
2092
|
+
* restriction on `SiteSeoTags.tags`: even with `custom` unset, Site SEO Tags
|
|
2093
|
+
* rejects `script` (e.g. for site-wide structured data) unconditionally.
|
|
2094
|
+
* There is currently no way to set site-wide, every-page structured data
|
|
2095
|
+
* through any of these APIs — write a per-page `script` tag through the Item
|
|
2096
|
+
* SEO Tags API instead.
|
|
1982
2097
|
*
|
|
1983
2098
|
* This flag is scoped to that feature only. It is NOT an indicator of whether a standard tag
|
|
1984
2099
|
* (`title`, `description`, Open Graph, etc.) reflects a manually configured value versus a computed
|
|
@@ -1991,22 +2106,39 @@ interface Tag {
|
|
|
1991
2106
|
* or Wix Studio pages, so even genuine Advanced/Custom Tags saved on those pages are missing from the
|
|
1992
2107
|
* response entirely — there, `false` means this API could not tell, not that no custom tag exists.
|
|
1993
2108
|
* Pass `seoData` explicitly to resolve against a known set of tags.
|
|
2109
|
+
*
|
|
2110
|
+
* `SeoSchemaV2.Tag` expresses this as `written_by = USER_CUSTOM`.
|
|
1994
2111
|
*/
|
|
1995
2112
|
custom?: boolean;
|
|
1996
|
-
/**
|
|
2113
|
+
/**
|
|
2114
|
+
* Whether the tag is excluded from the rendered <head>.
|
|
2115
|
+
*
|
|
2116
|
+
* A disabled tag is still stored, so the user can re-enable it and so a
|
|
2117
|
+
* pattern-provided tag stays suppressed on this page. Default false.
|
|
2118
|
+
*/
|
|
1997
2119
|
disabled?: boolean;
|
|
1998
2120
|
}
|
|
2121
|
+
/** Page-level SEO settings that are not tags. */
|
|
1999
2122
|
interface Settings {
|
|
2000
2123
|
/**
|
|
2001
|
-
* Whether the
|
|
2002
|
-
*
|
|
2124
|
+
* Whether to suppress the automatic redirect from this page's previous URL to
|
|
2125
|
+
* its current one after a slug change.
|
|
2003
2126
|
*
|
|
2004
|
-
* Default
|
|
2127
|
+
* Default false, meaning the redirect IS created. The field is named for the
|
|
2128
|
+
* exception rather than the rule, which reads backwards; kept as-is because
|
|
2129
|
+
* renaming a stored boolean is not worth the migration.
|
|
2005
2130
|
*/
|
|
2006
2131
|
preventAutoRedirect?: boolean;
|
|
2007
2132
|
/**
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2133
|
+
* Keyword terms the user is targeting for this page. Used by the SEO
|
|
2134
|
+
* assistant and checklist; never rendered into <head>.
|
|
2135
|
+
*
|
|
2136
|
+
* 20 is a sanity bound, not the product limit. v1 declared 5 — the number
|
|
2137
|
+
* the panel happens to allow today — which is exactly the mistake we are
|
|
2138
|
+
* fixing for structured data. A product decision to allow 8 should not need
|
|
2139
|
+
* a proto release, so the panel owns that number and the proto only stops
|
|
2140
|
+
* something absurd.
|
|
2141
|
+
* @maxSize 20
|
|
2010
2142
|
*/
|
|
2011
2143
|
keywords?: Keyword[];
|
|
2012
2144
|
}
|
|
@@ -2369,7 +2501,7 @@ type AddOn = {
|
|
|
2369
2501
|
type ServicePreference = {
|
|
2370
2502
|
serviceId: NonNullable<V2Slot['serviceId']>;
|
|
2371
2503
|
slug?: NonNullable<Slug['name']>;
|
|
2372
|
-
serviceType?: Service
|
|
2504
|
+
serviceType?: Service['type']; /** ISO local datetimes — per service (services in a bundle can start at different times). */
|
|
2373
2505
|
slotStart?: V2Slot['startDate'];
|
|
2374
2506
|
slotEnd?: V2Slot['endDate'];
|
|
2375
2507
|
eventId?: V2Slot['eventId'];
|
|
@@ -2397,7 +2529,7 @@ interface BookingPreferences {
|
|
|
2397
2529
|
}
|
|
2398
2530
|
//#endregion
|
|
2399
2531
|
//#region src/api/adapters/service/service.d.ts
|
|
2400
|
-
type Service$1 = Service
|
|
2532
|
+
type Service$1 = Service;
|
|
2401
2533
|
//#endregion
|
|
2402
2534
|
//#region src/domains/payment-options/consts.d.ts
|
|
2403
2535
|
/**
|
|
@@ -2508,140 +2640,281 @@ declare enum PurchaseFlow {
|
|
|
2508
2640
|
type PurchaseFlowWithLiterals = PurchaseFlow | 'MANUAL' | 'ONLINE';
|
|
2509
2641
|
//#endregion
|
|
2510
2642
|
//#region src/domains/payment-options/from-plans.d.ts
|
|
2511
|
-
/** A plan in
|
|
2643
|
+
/** A plan in the eCommerce catalog: the plan's `options` carry the pricing variant. */
|
|
2512
2644
|
interface PlanCatalogReference {
|
|
2645
|
+
/** ID of the app that sells the plan. */
|
|
2513
2646
|
appId: string;
|
|
2647
|
+
/** ID of the plan in the app's catalog. */
|
|
2514
2648
|
catalogItemId: string;
|
|
2649
|
+
/** Plan's options, such as its pricing variant. Absent for a plan with 1 price. */
|
|
2515
2650
|
options?: Options | null;
|
|
2516
2651
|
}
|
|
2517
2652
|
interface PlanPurchase {
|
|
2653
|
+
/** Plan's item in the catalog. */
|
|
2518
2654
|
catalogReference: PlanCatalogReference;
|
|
2655
|
+
/** ID of the plan's benefit that covers the booked service. */
|
|
2519
2656
|
benefitId: string;
|
|
2657
|
+
/** Plan's price, as a number in a string. */
|
|
2520
2658
|
price: string;
|
|
2521
2659
|
/** Pricing Plans' page for a plan that needs a start date or a form before purchase. */
|
|
2522
2660
|
infoCollectionUrl?: string | null;
|
|
2523
2661
|
}
|
|
2524
|
-
/** What a
|
|
2662
|
+
/** What a plan includes for the booked service. */
|
|
2525
2663
|
interface PlanBenefit {
|
|
2526
|
-
/**
|
|
2664
|
+
/** Number of sessions or credits the plan includes. `null` when it isn't known. */
|
|
2527
2665
|
total: number | null;
|
|
2666
|
+
/** Whether `total` is a number of sessions, rather than credits. */
|
|
2528
2667
|
isSessionBased: boolean;
|
|
2529
|
-
/**
|
|
2668
|
+
/**
|
|
2669
|
+
* Number of credits 1 booking of the service uses.
|
|
2670
|
+
*
|
|
2671
|
+
* `null` for a plan that counts sessions, and when it isn't known.
|
|
2672
|
+
*/
|
|
2530
2673
|
redemptionCost: number | null;
|
|
2531
2674
|
}
|
|
2532
2675
|
//#endregion
|
|
2533
2676
|
//#region src/domains/payment-options/from-service.d.ts
|
|
2534
|
-
type Service = Service$2;
|
|
2535
2677
|
type Payment = NonNullable<Service['payment']>;
|
|
2536
2678
|
type Money = NonNullable<NonNullable<Payment['fixed']>['price']>;
|
|
2537
2679
|
interface MembershipRowData {
|
|
2680
|
+
/** ID of the membership. */
|
|
2538
2681
|
membershipId: string;
|
|
2682
|
+
/** ID of the app the membership belongs to. */
|
|
2539
2683
|
appId: string;
|
|
2684
|
+
/** Membership's name. */
|
|
2540
2685
|
label: string;
|
|
2541
|
-
/**
|
|
2686
|
+
/**
|
|
2687
|
+
* Number of credits or sessions left in the membership. `0` when none are left.
|
|
2688
|
+
*
|
|
2689
|
+
* `null` when the membership is unlimited.
|
|
2690
|
+
*/
|
|
2542
2691
|
creditRemain: number | null;
|
|
2692
|
+
/** Number of credits the booking uses from the membership. */
|
|
2543
2693
|
creditCost: number;
|
|
2694
|
+
/** Whether the membership counts sessions instead of credits. */
|
|
2544
2695
|
isSessionBased: boolean;
|
|
2696
|
+
/** Number of credits or sessions the membership includes. `null` when it has no total. */
|
|
2545
2697
|
total: number | null;
|
|
2698
|
+
/** Date the membership expires. `null` when it doesn't expire. */
|
|
2546
2699
|
expirationDate: string | null;
|
|
2547
2700
|
}
|
|
2548
2701
|
interface PaymentOption$1 {
|
|
2702
|
+
/** Option ID. For a membership option, the membership's ID. */
|
|
2549
2703
|
id: string;
|
|
2704
|
+
/**
|
|
2705
|
+
* Kind of option. Supported values:
|
|
2706
|
+
* - `'ONLINE'`: Pay online.
|
|
2707
|
+
* - `'DEPOSIT'`: Pay a deposit online now, and the rest in person.
|
|
2708
|
+
* - `'FULL_AMOUNT'`: Pay the full amount online, when a deposit is also offered.
|
|
2709
|
+
* - `'OFFLINE'`: Pay in person.
|
|
2710
|
+
* - `'FREE'`: The service is free.
|
|
2711
|
+
* - `'CUSTOM_PRICE'`: The service has a price description instead of an amount, in `priceText`.
|
|
2712
|
+
* - `'MEMBERSHIP'`: Pay with a membership the visitor has, in `membership`.
|
|
2713
|
+
* - `'BUY_PLAN'`: Buy a plan and pay with it, in `purchasablePlan`.
|
|
2714
|
+
*/
|
|
2550
2715
|
kind: PaymentOptionKind;
|
|
2716
|
+
/**
|
|
2717
|
+
* How the option is paid. Supported values:
|
|
2718
|
+
* - `'ONLINE'`: Online.
|
|
2719
|
+
* - `'OFFLINE'`: In person, or nothing to pay online, as for a free service or a custom price.
|
|
2720
|
+
*
|
|
2721
|
+
* `null` for a membership option or a plan to buy.
|
|
2722
|
+
*/
|
|
2551
2723
|
paymentMethod: PaymentMethod | null;
|
|
2552
|
-
/**
|
|
2724
|
+
/**
|
|
2725
|
+
* Amount to pay with the option, with its currency. Format it for the visitor's locale before you
|
|
2726
|
+
* show it.
|
|
2727
|
+
*
|
|
2728
|
+
* `null` for a free service, a custom price, a membership, and a plan to buy.
|
|
2729
|
+
*/
|
|
2553
2730
|
amount: Money | null;
|
|
2554
|
-
/**
|
|
2731
|
+
/**
|
|
2732
|
+
* Whether `amount` is the service's lowest price, because the price depends on the visitor's
|
|
2733
|
+
* choices. Show it as a starting price, such as "From $30".
|
|
2734
|
+
*/
|
|
2555
2735
|
isFromPrice: boolean;
|
|
2556
|
-
/**
|
|
2736
|
+
/**
|
|
2737
|
+
* Amount after the service's discount, with its currency. Show it beside `amount`, which stays
|
|
2738
|
+
* the price before the discount.
|
|
2739
|
+
*
|
|
2740
|
+
* `null` when there's no discount, the service doesn't have a fixed price, the option is a
|
|
2741
|
+
* deposit, or the option isn't a payment for the service.
|
|
2742
|
+
*/
|
|
2557
2743
|
amountAfterDiscount: Money | null;
|
|
2558
|
-
/**
|
|
2744
|
+
/**
|
|
2745
|
+
* Name of the service's discount, to show with the option. It's set even when
|
|
2746
|
+
* `amountAfterDiscount` is `null`.
|
|
2747
|
+
*
|
|
2748
|
+
* `null` when the service has no discount, for `'FREE'` and `'CUSTOM_PRICE'` options, and for
|
|
2749
|
+
* options that aren't a payment for the service.
|
|
2750
|
+
*/
|
|
2559
2751
|
discountName: string | null;
|
|
2560
|
-
/**
|
|
2752
|
+
/**
|
|
2753
|
+
* Business's description of the price, for a `'CUSTOM_PRICE'` option. `null` for other kinds of
|
|
2754
|
+
* option.
|
|
2755
|
+
*/
|
|
2561
2756
|
priceText: string | null;
|
|
2757
|
+
/** Whether the visitor can't choose the option. */
|
|
2562
2758
|
disabled: boolean;
|
|
2759
|
+
/**
|
|
2760
|
+
* Text that says why the visitor can't choose the option. `null` when there's none.
|
|
2761
|
+
*
|
|
2762
|
+
* A membership option that can't be chosen gives its reason in `membershipDisabledReason`
|
|
2763
|
+
* instead.
|
|
2764
|
+
*/
|
|
2563
2765
|
disabledReason: string | null;
|
|
2564
|
-
|
|
2766
|
+
/** Why the visitor can't choose a membership option. Absent when they can. */
|
|
2767
|
+
membershipDisabledReason?: /** The membership doesn't have enough credits or sessions left for the booking. */'INSUFFICIENT_CREDITS' /** The membership has no credit limit, and pays for 1 participant only. */ | 'MULTIPLE_PARTICIPANTS';
|
|
2768
|
+
/** Title of a plan to buy: the plan's name. `null` for other kinds of option. */
|
|
2565
2769
|
titleText: string | null;
|
|
2770
|
+
/** Description of a plan to buy. `null` for other kinds of option, or when the plan has none. */
|
|
2566
2771
|
detailText: string | null;
|
|
2772
|
+
/** Price text of a plan to buy. `null` for other kinds of option, or when the plan has none. */
|
|
2567
2773
|
suffixText: string | null;
|
|
2774
|
+
/** Membership that pays for the booking, for a membership option. `null` for other kinds of option. */
|
|
2568
2775
|
membership: MembershipRowData | null;
|
|
2776
|
+
/** Plan to buy, for a `'BUY_PLAN'` option. Absent for other kinds of option. */
|
|
2569
2777
|
purchasablePlan?: PlanPurchase;
|
|
2570
|
-
/**
|
|
2778
|
+
/**
|
|
2779
|
+
* What a plan to buy includes, for a `'BUY_PLAN'` option.
|
|
2780
|
+
*
|
|
2781
|
+
* `null` for a plan with no limit on how often it can be used. Absent for other kinds of option.
|
|
2782
|
+
*/
|
|
2571
2783
|
planBenefit?: PlanBenefit | null;
|
|
2572
2784
|
}
|
|
2573
2785
|
//#endregion
|
|
2574
2786
|
//#region src/domains/payment-options/to-booking.d.ts
|
|
2575
2787
|
interface SelectedMembership {
|
|
2788
|
+
/** ID of the visitor's membership. */
|
|
2576
2789
|
membershipId: string;
|
|
2790
|
+
/** ID of the app the membership belongs to. */
|
|
2577
2791
|
appId: string;
|
|
2578
|
-
/**
|
|
2792
|
+
/**
|
|
2793
|
+
* ID of the service the membership pays for. It doesn't pay for other services in the selection.
|
|
2794
|
+
*/
|
|
2579
2795
|
serviceId: string;
|
|
2580
2796
|
}
|
|
2581
2797
|
//#endregion
|
|
2582
2798
|
//#region src/api/adapters/pricing/preview-price.d.ts
|
|
2583
|
-
/**
|
|
2799
|
+
/** Participants to book with 1 price choice. */
|
|
2584
2800
|
interface ParticipantsServiceChoice {
|
|
2801
|
+
/** Number of participants to book with the price choice. */
|
|
2585
2802
|
numberOfParticipants?: number;
|
|
2803
|
+
/**
|
|
2804
|
+
* Price choice to book the participants with: the participant range or the date and time rule
|
|
2805
|
+
* that prices them.
|
|
2806
|
+
*/
|
|
2586
2807
|
choices: Array<{
|
|
2587
|
-
choiceId?: string;
|
|
2808
|
+
/** ID of the choice. */choiceId?: string; /** ID of the option the choice belongs to. */
|
|
2588
2809
|
optionId?: string;
|
|
2589
2810
|
}>;
|
|
2590
2811
|
}
|
|
2591
2812
|
/** The count's previewed price, in the service's currency: the response carries none. */
|
|
2592
2813
|
interface ParticipantsPrice {
|
|
2593
|
-
/**
|
|
2814
|
+
/** Total price for the participants. */
|
|
2594
2815
|
total: number;
|
|
2595
|
-
/**
|
|
2816
|
+
/** Price per participant. Absent unless a single price choice prices all the participants. */
|
|
2596
2817
|
perParticipant?: number;
|
|
2597
2818
|
}
|
|
2598
2819
|
//#endregion
|
|
2599
2820
|
//#region src/domains/booking-checkout/to-booking-entity.d.ts
|
|
2600
|
-
type ServiceOptionsAndVariants = ServiceOptionsAndVariants$1;
|
|
2601
2821
|
interface ContactDetailsInput {
|
|
2822
|
+
/** Visitor's first name. */
|
|
2602
2823
|
firstName: string;
|
|
2824
|
+
/** Visitor's last name. */
|
|
2603
2825
|
lastName: string;
|
|
2826
|
+
/** Visitor's email address. */
|
|
2604
2827
|
email: string;
|
|
2605
|
-
/**
|
|
2828
|
+
/**
|
|
2829
|
+
* Visitor's phone number. Leave it out when it isn't valid, because the cart doesn't accept it.
|
|
2830
|
+
*/
|
|
2606
2831
|
phone?: string;
|
|
2607
2832
|
}
|
|
2608
2833
|
type PaymentOption = BookingPaymentOption;
|
|
2609
2834
|
type OfferedAddOnGroup = Pick<NonNullable<Service$1['addOnGroups']>[number], '_id' | 'addOnIds'>;
|
|
2610
2835
|
interface BookingPayment {
|
|
2836
|
+
/**
|
|
2837
|
+
* How the visitor pays for the booking. Supported values:
|
|
2838
|
+
* - `'ONLINE'`: Online, at checkout.
|
|
2839
|
+
* - `'OFFLINE'`: In person.
|
|
2840
|
+
* - `'MEMBERSHIP'`: With a plan the visitor has, or buys in the same checkout. Set the plan in
|
|
2841
|
+
* `membership`, `memberships`, or `purchase`. Without one, the booking is paid online.
|
|
2842
|
+
*/
|
|
2611
2843
|
paymentOption: PaymentOption;
|
|
2612
2844
|
/** Deposit (`true`) or full amount (`false`). */
|
|
2613
2845
|
depositSelected: boolean | null;
|
|
2614
|
-
/** The plan bought in the same cart that pays this entry
|
|
2846
|
+
/** The plan bought in the same cart that pays this entry. */
|
|
2615
2847
|
purchase?: PlanPurchase | null;
|
|
2616
2848
|
}
|
|
2617
2849
|
interface CreateBookingInput {
|
|
2850
|
+
/**
|
|
2851
|
+
* Visitor's contact details, for the cart and the order.
|
|
2852
|
+
*
|
|
2853
|
+
* The booking takes them only when there's no `formSubmission`, which then holds the contact.
|
|
2854
|
+
*/
|
|
2618
2855
|
contactDetails: ContactDetailsInput;
|
|
2619
|
-
/**
|
|
2856
|
+
/**
|
|
2857
|
+
* One per entry in `selection.services`, in the same order: each booking of a multi-service
|
|
2858
|
+
* appointment pays its own way.
|
|
2859
|
+
*/
|
|
2620
2860
|
payments: BookingPayment[];
|
|
2861
|
+
/**
|
|
2862
|
+
* Plan the visitor pays with.
|
|
2863
|
+
*
|
|
2864
|
+
* Ignored when `memberships` is set, and for a service other than the plan's `serviceId`.
|
|
2865
|
+
*/
|
|
2621
2866
|
membership?: SelectedMembership | null;
|
|
2622
|
-
/**
|
|
2867
|
+
/**
|
|
2868
|
+
* One per entry in `selection.services`, in the same order, so a service selected twice can use a
|
|
2869
|
+
* different plan each time.
|
|
2870
|
+
*/
|
|
2623
2871
|
memberships?: Array<SelectedMembership | null>;
|
|
2872
|
+
/**
|
|
2873
|
+
* Visitor's answers to the service's booking form, by field key. Sent with the booking.
|
|
2874
|
+
*
|
|
2875
|
+
* When it's set, the booking takes the visitor's contact details from it instead of
|
|
2876
|
+
* `contactDetails`.
|
|
2877
|
+
*/
|
|
2624
2878
|
formSubmission?: Record<string, unknown>;
|
|
2625
|
-
/**
|
|
2879
|
+
/**
|
|
2880
|
+
* Add-on groups each service offers, by service ID. The booking includes only the selected
|
|
2881
|
+
* add-ons that one of these groups holds, so a service that isn't listed is booked with no
|
|
2882
|
+
* add-ons.
|
|
2883
|
+
*/
|
|
2626
2884
|
offeredAddOnGroups?: Record<string, OfferedAddOnGroup[]>;
|
|
2627
|
-
/**
|
|
2885
|
+
/**
|
|
2886
|
+
* Options and variants of each service, by service ID. The booking uses them to book the variant
|
|
2887
|
+
* choices selected for a service.
|
|
2888
|
+
*/
|
|
2628
2889
|
optionsAndVariantsByService?: Record<string, ServiceOptionsAndVariants>;
|
|
2629
|
-
/**
|
|
2890
|
+
/**
|
|
2891
|
+
* Number of participants for a service with no variant choices.
|
|
2892
|
+
*
|
|
2893
|
+
* The context sets it from `participants` when the visitor submits, so leave it out.
|
|
2894
|
+
*
|
|
2895
|
+
* Default: `1`
|
|
2896
|
+
*/
|
|
2630
2897
|
totalParticipants?: number;
|
|
2631
2898
|
/**
|
|
2632
|
-
*
|
|
2633
|
-
*
|
|
2634
|
-
*
|
|
2899
|
+
* Price choices to book the participants with, for a service priced by rules: the participant
|
|
2900
|
+
* range the number of participants falls in, or the date and time rule the booked time slot
|
|
2901
|
+
* matches. When it's set, the booking uses it instead of `totalParticipants`.
|
|
2902
|
+
*
|
|
2903
|
+
* The context sets it from `previewParticipants()` when the visitor submits, so leave it out.
|
|
2635
2904
|
*/
|
|
2636
2905
|
participantsChoices?: ParticipantsServiceChoice[];
|
|
2637
|
-
/**
|
|
2906
|
+
/**
|
|
2907
|
+
* Whether the visitor must go through the checkout page, because a service charges a cancellation
|
|
2908
|
+
* fee or saves the visitor's card. When it's `true`, `createBooking()` sends the visitor to the
|
|
2909
|
+
* checkout page even when there's nothing to pay now.
|
|
2910
|
+
*/
|
|
2638
2911
|
requiresCheckoutPage?: boolean;
|
|
2639
2912
|
}
|
|
2640
2913
|
//#endregion
|
|
2641
2914
|
//#region src/lib/navigation.d.ts
|
|
2642
2915
|
type OwnerLink = {
|
|
2643
|
-
href: string;
|
|
2644
|
-
target?: '_self' | '_blank';
|
|
2916
|
+
/** URL to go to. */href: string; /** Where the link opens. */
|
|
2917
|
+
target?: /** In the current tab. */'_self' /** In a new tab. The visitor stays on the page in the current tab. */ | '_blank';
|
|
2645
2918
|
};
|
|
2646
2919
|
//#endregion
|
|
2647
2920
|
//#region src/domains/plan-and-book/flow.d.ts
|
|
@@ -2659,58 +2932,112 @@ declare const PLAN_AND_BOOK_ROUTE: {
|
|
|
2659
2932
|
};
|
|
2660
2933
|
type PlanAndBookRoute = (typeof PLAN_AND_BOOK_ROUTE)[keyof typeof PLAN_AND_BOOK_ROUTE];
|
|
2661
2934
|
interface PlanAndBookFlow {
|
|
2935
|
+
/**
|
|
2936
|
+
* Call to action the submit button shows. Supported values:
|
|
2937
|
+
* - `'BOOK'`: Book the selection.
|
|
2938
|
+
* - `'BUY_PLAN_AND_BOOK'`: Buy a plan and book with it, in the same checkout.
|
|
2939
|
+
* - `'BUY_PLAN'`: Buy a plan first. The visitor comes back to book.
|
|
2940
|
+
*/
|
|
2662
2941
|
cta: PlanAndBookCta;
|
|
2942
|
+
/**
|
|
2943
|
+
* Where `createBooking()` sends the visitor. Supported values:
|
|
2944
|
+
* - `'CHECKOUT'`: The checkout page, or the Thank You page when there's nothing to pay now.
|
|
2945
|
+
* - `'INLINE_CART'`: The checkout page, with the plan and the bookings in the same cart.
|
|
2946
|
+
* - `'DETAILS_PAGE'`: A page that collects what the plan needs before purchase, such as a start
|
|
2947
|
+
* date, then the checkout page.
|
|
2948
|
+
* - `'PRICING_PLANS'`: A page to buy the plan. Nothing is booked.
|
|
2949
|
+
*/
|
|
2663
2950
|
route: PlanAndBookRoute;
|
|
2664
2951
|
}
|
|
2665
2952
|
//#endregion
|
|
2666
2953
|
//#region src/domains/booking-checkout/checkout-error.d.ts
|
|
2667
|
-
/**
|
|
2954
|
+
/** Why a `createBooking()` or `addToCart()` call failed. */
|
|
2668
2955
|
interface CheckoutError {
|
|
2669
|
-
/**
|
|
2956
|
+
/** Error code from the server, such as `'SLOT_NOT_AVAILABLE'`, or `'UNKNOWN'` without one. */
|
|
2670
2957
|
code: string;
|
|
2671
|
-
/** The first violation's text,
|
|
2958
|
+
/** The first violation's text, sent with the `'VIOLATIONS_WITH_ERROR_SEVERITY'` code. */
|
|
2672
2959
|
violation?: string;
|
|
2673
2960
|
}
|
|
2674
2961
|
//#endregion
|
|
2675
2962
|
//#region src/extensions/contexts/booking-checkout-context/use-booking-checkout.d.ts
|
|
2676
2963
|
interface BookingFormHandle {
|
|
2677
|
-
/**
|
|
2964
|
+
/**
|
|
2965
|
+
* Whether the selection overlaps an appointment with the same staff member in the visitor's cart.
|
|
2966
|
+
*/
|
|
2678
2967
|
hasCartConflict?: boolean;
|
|
2679
|
-
/**
|
|
2968
|
+
/**
|
|
2969
|
+
* Validates the form and shows any errors in it.
|
|
2970
|
+
*
|
|
2971
|
+
* The context calls it when the visitor submits, before it creates anything.
|
|
2972
|
+
*
|
|
2973
|
+
* @returns `true` when the form can be submitted.
|
|
2974
|
+
*/
|
|
2680
2975
|
validate: () => Promise<boolean>;
|
|
2976
|
+
/**
|
|
2977
|
+
* Returns the visitor's booking details: their contact details, how they pay, and their answers
|
|
2978
|
+
* to the form.
|
|
2979
|
+
*
|
|
2980
|
+
* The context calls it when the visitor submits, after `validate()` resolves `true`.
|
|
2981
|
+
*
|
|
2982
|
+
* @returns Details to create the booking with.
|
|
2983
|
+
*/
|
|
2681
2984
|
getInput: () => CreateBookingInput;
|
|
2682
2985
|
/**
|
|
2683
|
-
*
|
|
2684
|
-
*
|
|
2986
|
+
* Retrieves the price choices to book a number of participants with, for a service priced by
|
|
2987
|
+
* rules: the participant range the number falls in, or the date and time rule the booked time
|
|
2988
|
+
* slot matches. Leave it out for other services.
|
|
2989
|
+
*
|
|
2990
|
+
* The context calls it when the visitor submits a booking of 1 service.
|
|
2991
|
+
*
|
|
2992
|
+
* @param count Number of participants to price.
|
|
2993
|
+
* @returns Price choices to book the participants with, or `null` to book the number of
|
|
2994
|
+
* participants without them.
|
|
2685
2995
|
*/
|
|
2686
2996
|
previewParticipants?: (count: number) => Promise<ParticipantsServiceChoice[] | null>;
|
|
2687
|
-
/**
|
|
2997
|
+
/**
|
|
2998
|
+
* Returns the form's analytics parameters, which the context reports when the visitor submits.
|
|
2999
|
+
*
|
|
3000
|
+
* When it throws, the context reports the submit without them.
|
|
3001
|
+
*
|
|
3002
|
+
* @returns Parameters to add to the submit's analytics event, by parameter name.
|
|
3003
|
+
*/
|
|
2688
3004
|
getBiParams?: () => Record<string, unknown>;
|
|
2689
3005
|
}
|
|
2690
3006
|
/** What the Booking Form tells the widgets beside it, once it is usable and the cart is read. */
|
|
2691
3007
|
interface FormFacts {
|
|
2692
3008
|
/** How the visitor pays each booked service. */
|
|
2693
3009
|
payments: {
|
|
2694
|
-
serviceId: string | null;
|
|
2695
|
-
|
|
3010
|
+
/** ID of the booked service, or `null` when it isn't known. */serviceId: string | null;
|
|
3011
|
+
/**
|
|
3012
|
+
* How the visitor pays for the service. Supported values:
|
|
3013
|
+
* - `'ONLINE'`: Online.
|
|
3014
|
+
* - `'OFFLINE'`: In person.
|
|
3015
|
+
* - `'MEMBERSHIP'`: With a plan.
|
|
3016
|
+
*/
|
|
3017
|
+
paymentOption: BookingPaymentOption; /** Whether the service has a price above 0. */
|
|
2696
3018
|
hasPrice: boolean;
|
|
2697
3019
|
}[];
|
|
2698
|
-
/**
|
|
3020
|
+
/** Whether the visitor's cart holds bookings. Other items in the cart don't count. */
|
|
2699
3021
|
hasBookingsInCart: boolean;
|
|
2700
|
-
/**
|
|
3022
|
+
/**
|
|
3023
|
+
* Price of the selected number of participants and time slot, for a service priced by rules, such
|
|
3024
|
+
* as by the number of participants. Absent for other services.
|
|
3025
|
+
*/
|
|
2701
3026
|
participantsPrice?: PreviewedParticipantsPrice;
|
|
2702
3027
|
}
|
|
2703
3028
|
/** `failed` too when the preview has no price; `count` is the count it prices. */
|
|
2704
3029
|
type PreviewedParticipantsPrice = {
|
|
2705
|
-
status: 'loading';
|
|
3030
|
+
/** The price is loading. */status: 'loading';
|
|
2706
3031
|
} | {
|
|
2707
|
-
status: 'failed';
|
|
3032
|
+
/** The preview failed or returned no price. */status: 'failed';
|
|
2708
3033
|
} | ({
|
|
2709
|
-
status: 'loaded';
|
|
3034
|
+
/** The price is loaded. */status: 'loaded'; /** Number of participants the price is for. */
|
|
2710
3035
|
count: number;
|
|
2711
3036
|
} & ParticipantsPrice);
|
|
2712
3037
|
interface BookingCheckoutResult {
|
|
3038
|
+
/** IDs of the bookings created. */
|
|
2713
3039
|
bookingIds: string[];
|
|
3040
|
+
/** ID of the cart that holds the bookings. */
|
|
2714
3041
|
cartId: string;
|
|
2715
3042
|
}
|
|
2716
3043
|
/** Where addToCart() sends the visitor once the items are in the cart. `stay` leaves them on the page. */
|
|
@@ -2720,56 +3047,364 @@ type AddToCartDestination = 'cart' | 'home' | 'stay' | OwnerLink;
|
|
|
2720
3047
|
* form is invalid, a run is in flight or the selection changed before it failed.
|
|
2721
3048
|
*/
|
|
2722
3049
|
type AddToCartOutcome = {
|
|
2723
|
-
error: CheckoutError;
|
|
3050
|
+
/** Why adding the bookings to the cart failed. */error: CheckoutError;
|
|
2724
3051
|
} | {
|
|
2725
|
-
bookingIds: string[];
|
|
3052
|
+
/** IDs of the bookings added to the cart. */bookingIds: string[];
|
|
3053
|
+
/**
|
|
3054
|
+
* Whether the visitor is being sent to another page. `false` when they stay on this page,
|
|
3055
|
+
* such as with `'stay'`, a link that opens in a new tab, or the side cart.
|
|
3056
|
+
*/
|
|
2726
3057
|
leavesPage: boolean;
|
|
2727
3058
|
} | null;
|
|
2728
3059
|
/** The failure, for the clicked button to show; null when nothing failed, nothing ran or the selection changed before it failed. */
|
|
2729
3060
|
type CreateBookingOutcome = {
|
|
2730
|
-
error: CheckoutError;
|
|
3061
|
+
/** Why creating the booking failed. */error: CheckoutError;
|
|
2731
3062
|
} | null;
|
|
2732
3063
|
interface BookingCheckoutState {
|
|
2733
|
-
/**
|
|
3064
|
+
/**
|
|
3065
|
+
* Booking preferences from the page URL's `b` query parameter: the services the visitor selected,
|
|
3066
|
+
* with their time slots and choices.
|
|
3067
|
+
*
|
|
3068
|
+
* `null` when the URL has no booking preferences, or they hold no service.
|
|
3069
|
+
*/
|
|
2734
3070
|
selection: BookingPreferences | null;
|
|
2735
|
-
/**
|
|
3071
|
+
/** Whether every service in the selection can be booked and a booking form is registered. */
|
|
2736
3072
|
canBook: boolean;
|
|
2737
|
-
/**
|
|
3073
|
+
/**
|
|
3074
|
+
* What the submit button offers and where `createBooking()` sends the visitor, based on the
|
|
3075
|
+
* payment options in `selectedPaymentOptions`.
|
|
3076
|
+
*/
|
|
2738
3077
|
planAndBookFlow: PlanAndBookFlow;
|
|
2739
|
-
/**
|
|
3078
|
+
/**
|
|
3079
|
+
* Payment option the visitor chose for each booked service, as the booking form published them
|
|
3080
|
+
* with `registerPaymentOptions()`.
|
|
3081
|
+
*
|
|
3082
|
+
* `null` until the form publishes them for the current selection, and while they load.
|
|
3083
|
+
*/
|
|
2740
3084
|
selectedPaymentOptions: Array<PaymentOption$1 | null> | null;
|
|
3085
|
+
/**
|
|
3086
|
+
* Whether the booking form is loading the payment options for the current selection.
|
|
3087
|
+
*
|
|
3088
|
+
* While it's `true`, `selectedPaymentOptions` is `null`.
|
|
3089
|
+
*/
|
|
2741
3090
|
isLoadingPaymentOptions: boolean;
|
|
2742
|
-
/**
|
|
3091
|
+
/**
|
|
3092
|
+
* Publishes the payment option the visitor chose for each booked service. It doesn't wait for
|
|
3093
|
+
* the form to be valid.
|
|
3094
|
+
*
|
|
3095
|
+
* It sets `selectedPaymentOptions` and `planAndBookFlow`. Options published for an earlier
|
|
3096
|
+
* selection don't apply: when the selection changes, `selectedPaymentOptions` is `null` until
|
|
3097
|
+
* the form publishes again.
|
|
3098
|
+
*
|
|
3099
|
+
* @param options Payment option the visitor chose for each booked service, with `null` for a
|
|
3100
|
+
* service with none chosen. Pass `null` while the options are loading, which sets
|
|
3101
|
+
* `isLoadingPaymentOptions` to `true`.
|
|
3102
|
+
* @param isPlanAndBookBlocked Whether a plan the visitor buys must be bought before booking,
|
|
3103
|
+
* instead of in the same checkout as the booking. When it's `true` and an option buys a plan,
|
|
3104
|
+
* `planAndBookFlow` sends the visitor to buy the plan first. Set it to `true` when a service
|
|
3105
|
+
* charges a cancellation fee or saves the visitor's card, or when more than 1 participant is
|
|
3106
|
+
* booked.
|
|
3107
|
+
* @returns Function that clears these payment options, unless a later call replaced them. Call it
|
|
3108
|
+
* when your component unmounts.
|
|
3109
|
+
* @example Publish the visitor's payment choices
|
|
3110
|
+
* ```tsx
|
|
3111
|
+
* import { useEffect } from 'react';
|
|
3112
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3113
|
+
*
|
|
3114
|
+
* // useMyPaymentChoices() and MyPaymentChoices are your own hook and component.
|
|
3115
|
+
* // isPlanAndBookBlocked is true when a service charges a cancellation fee or saves the
|
|
3116
|
+
* // visitor's card, or when more than 1 participant is booked.
|
|
3117
|
+
* function PaymentChoices() {
|
|
3118
|
+
* const { registerPaymentOptions } = useBookingCheckoutContext();
|
|
3119
|
+
* const { chosenOptions, isLoading, isPlanAndBookBlocked } = useMyPaymentChoices();
|
|
3120
|
+
*
|
|
3121
|
+
* useEffect(
|
|
3122
|
+
* () => registerPaymentOptions(isLoading ? null : chosenOptions, isPlanAndBookBlocked),
|
|
3123
|
+
* [registerPaymentOptions, chosenOptions, isLoading, isPlanAndBookBlocked],
|
|
3124
|
+
* );
|
|
3125
|
+
*
|
|
3126
|
+
* return <MyPaymentChoices />;
|
|
3127
|
+
* }
|
|
3128
|
+
* ```
|
|
3129
|
+
*/
|
|
2743
3130
|
registerPaymentOptions: (options: Array<PaymentOption$1 | null> | null, isPlanAndBookBlocked: boolean) => () => void;
|
|
2744
|
-
/**
|
|
3131
|
+
/**
|
|
3132
|
+
* Whether the selection overlaps an appointment with the same staff member in the visitor's cart,
|
|
3133
|
+
* as the registered form reports it. While it's `true`, `addToCart()` does nothing.
|
|
3134
|
+
*
|
|
3135
|
+
* `false` while no form is registered.
|
|
3136
|
+
*/
|
|
2745
3137
|
hasCartConflict: boolean;
|
|
2746
|
-
/**
|
|
3138
|
+
/**
|
|
3139
|
+
* Registers the booking form that `createBooking()` and `addToCart()` submit. Register the form
|
|
3140
|
+
* when it mounts, and pass `null` when it unmounts.
|
|
3141
|
+
*
|
|
3142
|
+
* `createBooking()` and `addToCart()` validate the registered form and read the visitor's
|
|
3143
|
+
* details from it. While no form is registered, `canBook` is `false` and both do nothing.
|
|
3144
|
+
* Registering a form replaces the one registered before.
|
|
3145
|
+
*
|
|
3146
|
+
* `hasCartConflict` is read from the form when it's registered, so register the form again when
|
|
3147
|
+
* its `hasCartConflict` changes.
|
|
3148
|
+
*
|
|
3149
|
+
* @param form Form to register, or `null` to remove the registered form.
|
|
3150
|
+
* @example Register a contact form
|
|
3151
|
+
* ```tsx
|
|
3152
|
+
* import { useEffect, useRef, useState } from 'react';
|
|
3153
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3154
|
+
*
|
|
3155
|
+
* // MyContactFields is your own component for the contact fields.
|
|
3156
|
+
* function ContactForm() {
|
|
3157
|
+
* const { selection, registerForm } = useBookingCheckoutContext();
|
|
3158
|
+
* const [contact, setContact] = useState({ firstName: '', lastName: '', email: '' });
|
|
3159
|
+
* const latest = useRef({ contact, selection });
|
|
3160
|
+
* latest.current = { contact, selection };
|
|
3161
|
+
*
|
|
3162
|
+
* useEffect(() => {
|
|
3163
|
+
* registerForm({
|
|
3164
|
+
* validate: async () => latest.current.contact.email.includes('@'),
|
|
3165
|
+
* getInput: () => ({
|
|
3166
|
+
* contactDetails: latest.current.contact,
|
|
3167
|
+
* payments: (latest.current.selection?.services ?? []).map(() => ({
|
|
3168
|
+
* paymentOption: 'OFFLINE',
|
|
3169
|
+
* depositSelected: null,
|
|
3170
|
+
* })),
|
|
3171
|
+
* }),
|
|
3172
|
+
* });
|
|
3173
|
+
* return () => registerForm(null);
|
|
3174
|
+
* }, [registerForm]);
|
|
3175
|
+
*
|
|
3176
|
+
* return <MyContactFields value={contact} onChange={setContact} />;
|
|
3177
|
+
* }
|
|
3178
|
+
* ```
|
|
3179
|
+
*/
|
|
2747
3180
|
registerForm: (form: BookingFormHandle | null) => void;
|
|
2748
|
-
/**
|
|
3181
|
+
/**
|
|
3182
|
+
* Facts the booking form published with `publishFormFacts()` for the widgets beside it, such as
|
|
3183
|
+
* how the visitor pays for each booked service.
|
|
3184
|
+
*
|
|
3185
|
+
* `null` until the form publishes them, and after it clears them.
|
|
3186
|
+
*/
|
|
2749
3187
|
formFacts: FormFacts | null;
|
|
2750
|
-
/**
|
|
3188
|
+
/**
|
|
3189
|
+
* Publishes the booking form's facts for the widgets beside it, such as a booking summary. Pass
|
|
3190
|
+
* `null` when the form unmounts.
|
|
3191
|
+
*
|
|
3192
|
+
* It sets `formFacts`. Facts equal to the current ones leave `formFacts` unchanged, so the form
|
|
3193
|
+
* can publish on every render.
|
|
3194
|
+
*
|
|
3195
|
+
* `createBooking()` reads the published payments to decide whether a visitor who wants to enter
|
|
3196
|
+
* a promo code goes through the checkout page.
|
|
3197
|
+
*
|
|
3198
|
+
* @param facts Facts to publish, or `null` to clear `formFacts`.
|
|
3199
|
+
* @example Publish the form's facts once it's ready
|
|
3200
|
+
* ```tsx
|
|
3201
|
+
* import { useEffect } from 'react';
|
|
3202
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3203
|
+
*
|
|
3204
|
+
* // useMyFormState() and MyFormFields are your own hook and form fields.
|
|
3205
|
+
* function MyBookingForm() {
|
|
3206
|
+
* const { publishFormFacts } = useBookingCheckoutContext();
|
|
3207
|
+
* const { isReady, payments, hasBookingsInCart } = useMyFormState();
|
|
3208
|
+
*
|
|
3209
|
+
* useEffect(() => {
|
|
3210
|
+
* publishFormFacts(isReady ? { payments, hasBookingsInCart } : null);
|
|
3211
|
+
* }, [publishFormFacts, isReady, payments, hasBookingsInCart]);
|
|
3212
|
+
* useEffect(() => () => publishFormFacts(null), [publishFormFacts]);
|
|
3213
|
+
*
|
|
3214
|
+
* return <MyFormFields />;
|
|
3215
|
+
* }
|
|
3216
|
+
* ```
|
|
3217
|
+
*/
|
|
2751
3218
|
publishFormFacts: (facts: FormFacts | null) => void;
|
|
2752
|
-
/**
|
|
3219
|
+
/** Whether the booking form shows an empty state instead of its fields. Hide Book and Add to Cart buttons while it's `true`. */
|
|
2753
3220
|
isFormEmptyState: boolean;
|
|
2754
|
-
/**
|
|
3221
|
+
/**
|
|
3222
|
+
* Publishes whether the booking form shows its empty state instead of its fields. Pass `false`
|
|
3223
|
+
* when the form unmounts.
|
|
3224
|
+
*
|
|
3225
|
+
* It sets `isFormEmptyState`.
|
|
3226
|
+
*
|
|
3227
|
+
* @param isEmptyState Whether the form shows its empty state instead of its fields.
|
|
3228
|
+
* @example Show an empty state when nothing is selected
|
|
3229
|
+
* ```tsx
|
|
3230
|
+
* import { useEffect } from 'react';
|
|
3231
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3232
|
+
*
|
|
3233
|
+
* // MyBookingFields is your own form component.
|
|
3234
|
+
* function BookingDetailsForm() {
|
|
3235
|
+
* const { selection, publishFormEmptyState } = useBookingCheckoutContext();
|
|
3236
|
+
* const isEmpty = selection === null;
|
|
3237
|
+
*
|
|
3238
|
+
* useEffect(() => {
|
|
3239
|
+
* publishFormEmptyState(isEmpty);
|
|
3240
|
+
* return () => publishFormEmptyState(false);
|
|
3241
|
+
* }, [isEmpty, publishFormEmptyState]);
|
|
3242
|
+
*
|
|
3243
|
+
* return isEmpty ? <p>Choose a service to book.</p> : <MyBookingFields />;
|
|
3244
|
+
* }
|
|
3245
|
+
* ```
|
|
3246
|
+
*/
|
|
2755
3247
|
publishFormEmptyState: (isEmptyState: boolean) => void;
|
|
2756
|
-
/**
|
|
3248
|
+
/**
|
|
3249
|
+
* Validates the registered form, creates the bookings and a cart for them, and then either places
|
|
3250
|
+
* the order or sends the visitor to the checkout page.
|
|
3251
|
+
*
|
|
3252
|
+
* When a plan has to be bought first, as `planAndBookFlow` says, it sends the visitor to buy the
|
|
3253
|
+
* plan instead. Only 1 `createBooking()` or `addToCart()` call runs at a time.
|
|
3254
|
+
*
|
|
3255
|
+
* @returns An object with the failure in `error` when creating the booking fails. The same
|
|
3256
|
+
* failure is in `createError`.
|
|
3257
|
+
*
|
|
3258
|
+
* `null` in all other cases:
|
|
3259
|
+
* - The visitor is sent to the next page: the checkout page, the Thank You page, a page that
|
|
3260
|
+
* collects a plan's details, or a page to buy a plan.
|
|
3261
|
+
* - Nothing runs, because `canBook` is `false`, the form isn't valid, or another
|
|
3262
|
+
* `createBooking()` or `addToCart()` call is in progress.
|
|
3263
|
+
* - The selection or the participant count changed before the call failed.
|
|
3264
|
+
* @example Add a Book button that shows failures
|
|
3265
|
+
* ```tsx
|
|
3266
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3267
|
+
*
|
|
3268
|
+
* function BookButton() {
|
|
3269
|
+
* const { canBook, isCreating, createBooking, createError } = useBookingCheckoutContext();
|
|
3270
|
+
*
|
|
3271
|
+
* return (
|
|
3272
|
+
* <div>
|
|
3273
|
+
* <button disabled={!canBook || isCreating} onClick={() => createBooking()}>
|
|
3274
|
+
* {isCreating ? 'Booking...' : 'Book now'}
|
|
3275
|
+
* </button>
|
|
3276
|
+
* {createError && <p role="alert">We couldn't book this. Try again.</p>}
|
|
3277
|
+
* </div>
|
|
3278
|
+
* );
|
|
3279
|
+
* }
|
|
3280
|
+
* ```
|
|
3281
|
+
*/
|
|
2757
3282
|
createBooking: () => Promise<CreateBookingOutcome>;
|
|
2758
|
-
/**
|
|
3283
|
+
/**
|
|
3284
|
+
* Whether a `createBooking()` call is creating the booking. It turns `true` once the form is
|
|
3285
|
+
* valid, and stays `true` after a successful call while the next page loads.
|
|
3286
|
+
*
|
|
3287
|
+
* When the visitor goes to a page to buy a plan, it turns `false` again after the call starts
|
|
3288
|
+
* the navigation, before that page loads.
|
|
3289
|
+
*/
|
|
2759
3290
|
isCreating: boolean;
|
|
2760
|
-
/**
|
|
3291
|
+
/**
|
|
3292
|
+
* Why the last `createBooking()` call failed.
|
|
3293
|
+
*
|
|
3294
|
+
* `null` when it didn't fail. The next `createBooking()` or `addToCart()` call clears it, and so
|
|
3295
|
+
* does a change to the selection or to the number of participants.
|
|
3296
|
+
*/
|
|
2761
3297
|
createError: CheckoutError | null;
|
|
2762
|
-
/**
|
|
3298
|
+
/**
|
|
3299
|
+
* Validates the registered form, creates the bookings, adds them to the visitor's current cart,
|
|
3300
|
+
* and sends the visitor to `destination`.
|
|
3301
|
+
*
|
|
3302
|
+
* Only 1 `addToCart()` or `createBooking()` call runs at a time.
|
|
3303
|
+
*
|
|
3304
|
+
* @param destination Where to send the visitor once the bookings are in the cart. Supported
|
|
3305
|
+
* values:
|
|
3306
|
+
* - `'cart'`: The site's Cart page. When the site has no Cart page, the side cart opens over this
|
|
3307
|
+
* page if the site has one, and the visitor stays on this page.
|
|
3308
|
+
* - `'home'`: The site's home page.
|
|
3309
|
+
* - `'stay'`: The visitor stays on this page.
|
|
3310
|
+
* - A link object: The link's `href`, in a new tab when its `target` is `'_blank'`.
|
|
3311
|
+
*
|
|
3312
|
+
* Default: `'cart'`
|
|
3313
|
+
* @returns An object with the IDs of the bookings added to the cart and `leavesPage`, when the
|
|
3314
|
+
* bookings are added. An object with the failure in `error` when adding them fails, with the same
|
|
3315
|
+
* failure in `addToCartError`. When the cart already holds bookings at a different business
|
|
3316
|
+
* location, the failure's `code` is `'CART_IS_ALREADY_ASSOCIATED_WITH_DIFFERENT_LOCATION'` and
|
|
3317
|
+
* nothing is booked.
|
|
3318
|
+
*
|
|
3319
|
+
* `null` when nothing runs because `canBook` is `false`, the form has a cart conflict,
|
|
3320
|
+
* `planAndBookFlow.cta` isn't `'BOOK'`, the form isn't valid, or another `createBooking()` or
|
|
3321
|
+
* `addToCart()` call is in progress. Also `null` when the selection or the participant count
|
|
3322
|
+
* changed before the call failed.
|
|
3323
|
+
* @example Add the booking to the cart and keep the visitor on the page
|
|
3324
|
+
* ```tsx
|
|
3325
|
+
* import { useState } from 'react';
|
|
3326
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3327
|
+
*
|
|
3328
|
+
* function AddToCartButton() {
|
|
3329
|
+
* const { canBook, hasCartConflict, isAddingToCart, addToCart } = useBookingCheckoutContext();
|
|
3330
|
+
* const [isAdded, setIsAdded] = useState(false);
|
|
3331
|
+
*
|
|
3332
|
+
* const handleClick = async () => {
|
|
3333
|
+
* const outcome = await addToCart('stay');
|
|
3334
|
+
* setIsAdded(outcome !== null && 'bookingIds' in outcome);
|
|
3335
|
+
* };
|
|
3336
|
+
*
|
|
3337
|
+
* return (
|
|
3338
|
+
* <div>
|
|
3339
|
+
* <button disabled={!canBook || hasCartConflict || isAddingToCart} onClick={handleClick}>
|
|
3340
|
+
* Add to cart
|
|
3341
|
+
* </button>
|
|
3342
|
+
* {isAdded && <p>Added to your cart.</p>}
|
|
3343
|
+
* </div>
|
|
3344
|
+
* );
|
|
3345
|
+
* }
|
|
3346
|
+
* ```
|
|
3347
|
+
*/
|
|
2763
3348
|
addToCart: (destination?: AddToCartDestination) => Promise<AddToCartOutcome>;
|
|
2764
|
-
/**
|
|
3349
|
+
/**
|
|
3350
|
+
* Whether an `addToCart()` call is adding the bookings to the cart. It turns `true` once the form
|
|
3351
|
+
* is valid, and stays `true` after a successful call while the visitor goes to another page.
|
|
3352
|
+
*
|
|
3353
|
+
* `false` again after a failure, and after a successful call that leaves the visitor on this
|
|
3354
|
+
* page, such as with the `'stay'` destination.
|
|
3355
|
+
*/
|
|
2765
3356
|
isAddingToCart: boolean;
|
|
2766
|
-
/**
|
|
3357
|
+
/**
|
|
3358
|
+
* Why the last `addToCart()` call failed.
|
|
3359
|
+
*
|
|
3360
|
+
* `null` when it didn't fail. The next `createBooking()` or `addToCart()` call clears it, and so
|
|
3361
|
+
* does a change to the selection or to the number of participants.
|
|
3362
|
+
*/
|
|
2767
3363
|
addToCartError: CheckoutError | null;
|
|
2768
|
-
/**
|
|
3364
|
+
/**
|
|
3365
|
+
* Number of participants to book when the selected service's variants don't set the count, such
|
|
3366
|
+
* as a single service with no variants.
|
|
3367
|
+
*
|
|
3368
|
+
* Default: `1`
|
|
3369
|
+
*/
|
|
2769
3370
|
participants: number;
|
|
2770
|
-
/**
|
|
3371
|
+
/**
|
|
3372
|
+
* Sets the number of participants to book, in `participants`.
|
|
3373
|
+
*
|
|
3374
|
+
* A count that isn't a number of at least 1 sets 1, and a fraction is rounded down. The count
|
|
3375
|
+
* isn't capped, and it stays as set when a limit, such as the slot's open spots, drops later.
|
|
3376
|
+
*
|
|
3377
|
+
* Changing the count clears `createError` and `addToCartError`.
|
|
3378
|
+
*
|
|
3379
|
+
* @param count Number of participants.
|
|
3380
|
+
* @example Add a participants field
|
|
3381
|
+
* ```tsx
|
|
3382
|
+
* import { useBookingCheckoutContext } from '@wix/bookings/context/booking-checkout';
|
|
3383
|
+
*
|
|
3384
|
+
* function ParticipantsField() {
|
|
3385
|
+
* const { participants, setParticipants } = useBookingCheckoutContext();
|
|
3386
|
+
*
|
|
3387
|
+
* return (
|
|
3388
|
+
* <label>
|
|
3389
|
+
* Participants
|
|
3390
|
+
* <input
|
|
3391
|
+
* type="number"
|
|
3392
|
+
* min={1}
|
|
3393
|
+
* value={participants}
|
|
3394
|
+
* onChange={(event) => setParticipants(Number(event.target.value))}
|
|
3395
|
+
* />
|
|
3396
|
+
* </label>
|
|
3397
|
+
* );
|
|
3398
|
+
* }
|
|
3399
|
+
* ```
|
|
3400
|
+
*/
|
|
2771
3401
|
setParticipants: (count: number) => void;
|
|
2772
|
-
/**
|
|
3402
|
+
/**
|
|
3403
|
+
* IDs of the bookings and the cart from the last `createBooking()` or `addToCart()` call that put
|
|
3404
|
+
* the bookings in a cart.
|
|
3405
|
+
*
|
|
3406
|
+
* `null` before such a call.
|
|
3407
|
+
*/
|
|
2773
3408
|
lastResult: BookingCheckoutResult | null;
|
|
2774
3409
|
}
|
|
2775
3410
|
declare function canBookSelection(selection: BookingPreferences | null): boolean;
|
|
@@ -2779,9 +3414,22 @@ declare function canBookSelection(selection: BookingPreferences | null): boolean
|
|
|
2779
3414
|
type BookingCheckoutContextValue = BookingCheckoutState;
|
|
2780
3415
|
declare const bookingCheckoutContext: React.Context<BookingCheckoutState | null>;
|
|
2781
3416
|
declare const BOOKING_CHECKOUT_CONTEXT_MISSING_PROVIDER_ERROR = "useBookingCheckoutContext must be used within BookingCheckoutContextProvider";
|
|
2782
|
-
/**
|
|
3417
|
+
/**
|
|
3418
|
+
* The `useBookingCheckoutContext()` hook provides access to the booking a visitor is about to make,
|
|
3419
|
+
* including the services and times they selected, how they pay, and the number of participants. Use
|
|
3420
|
+
* it to send the booking to checkout, add it to the visitor's cart, and connect a booking form to
|
|
3421
|
+
* the buttons and summary beside it. When you pass `true` to the hook, it returns `null` where the
|
|
3422
|
+
* context isn't available.
|
|
3423
|
+
*/
|
|
2783
3424
|
declare function useBookingCheckoutContext(optional: true): BookingCheckoutContextValue | null;
|
|
2784
|
-
/**
|
|
3425
|
+
/**
|
|
3426
|
+
* The `useBookingCheckoutContext()` hook provides access to the booking a visitor is about to make,
|
|
3427
|
+
* including the services and times they selected, how they pay, and the number of participants. Use
|
|
3428
|
+
* it to send the booking to checkout, add it to the visitor's cart, and connect a booking form to
|
|
3429
|
+
* the buttons and summary beside it.
|
|
3430
|
+
*
|
|
3431
|
+
* It throws an error where the context isn't available.
|
|
3432
|
+
*/
|
|
2785
3433
|
declare function useBookingCheckoutContext(optional?: false): BookingCheckoutContextValue;
|
|
2786
3434
|
/** Props accepted by {@link BookingCheckoutContextProvider}. */
|
|
2787
3435
|
interface BookingCheckoutContextProviderProps {
|