@wix/headless-bookings 1.0.3 → 1.0.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.
@@ -109,7 +109,13 @@ async function getPreviewedPrice(service, localStartDate, localEndDate, timeZone
109
109
  ...(timeZone ? { timeZone } : {}),
110
110
  };
111
111
  const result = await (0, auto_sdk_bookings_pricing_1.previewPrice)([lineItemInput]);
112
- return result.priceInfo?.calculatedPrice ?? null;
112
+ const price = result.priceInfo?.calculatedPrice;
113
+ if (price == null)
114
+ return null;
115
+ return {
116
+ price,
117
+ deposit: result.priceInfo?.deposit ?? null,
118
+ };
113
119
  }
114
120
  async function buildLineItemWithPreview(item, totalParticipants) {
115
121
  if (item.localStartDate &&
@@ -118,9 +124,14 @@ async function buildLineItemWithPreview(item, totalParticipants) {
118
124
  const previewedPrice = await getPreviewedPrice(item.service, item.localStartDate, item.localEndDate, item.timeZone, totalParticipants).catch(() => null);
119
125
  if (previewedPrice != null) {
120
126
  const depositValue = item.service.payment?.fixed?.deposit?.value;
121
- const hasDeposit = !!depositValue && Number(depositValue) > 0;
127
+ const previewedDeposit = previewedPrice.deposit;
128
+ const hasDeposit = previewedDeposit != null
129
+ ? previewedDeposit > 0
130
+ : !!depositValue && Number(depositValue) > 0;
122
131
  const deposit = hasDeposit
123
- ? Number(depositValue) * totalParticipants
132
+ ? previewedDeposit != null
133
+ ? previewedDeposit
134
+ : Number(depositValue) * totalParticipants
124
135
  : undefined;
125
136
  return {
126
137
  _id: item.lineItemId,
@@ -128,7 +139,7 @@ async function buildLineItemWithPreview(item, totalParticipants) {
128
139
  catalogItemId: item.service._id || '',
129
140
  appId: constants_js_1.BOOKING_APP_ID,
130
141
  },
131
- price: String(previewedPrice),
142
+ price: String(previewedPrice.price),
132
143
  ...(deposit ? { depositAmount: String(deposit) } : {}),
133
144
  quantity: 1,
134
145
  paymentOption: getPaymentOption(item.service, hasDeposit),
@@ -104,7 +104,13 @@ async function getPreviewedPrice(service, localStartDate, localEndDate, timeZone
104
104
  ...(timeZone ? { timeZone } : {}),
105
105
  };
106
106
  const result = await previewPrice([lineItemInput]);
107
- return result.priceInfo?.calculatedPrice ?? null;
107
+ const price = result.priceInfo?.calculatedPrice;
108
+ if (price == null)
109
+ return null;
110
+ return {
111
+ price,
112
+ deposit: result.priceInfo?.deposit ?? null,
113
+ };
108
114
  }
109
115
  async function buildLineItemWithPreview(item, totalParticipants) {
110
116
  if (item.localStartDate &&
@@ -113,9 +119,14 @@ async function buildLineItemWithPreview(item, totalParticipants) {
113
119
  const previewedPrice = await getPreviewedPrice(item.service, item.localStartDate, item.localEndDate, item.timeZone, totalParticipants).catch(() => null);
114
120
  if (previewedPrice != null) {
115
121
  const depositValue = item.service.payment?.fixed?.deposit?.value;
116
- const hasDeposit = !!depositValue && Number(depositValue) > 0;
122
+ const previewedDeposit = previewedPrice.deposit;
123
+ const hasDeposit = previewedDeposit != null
124
+ ? previewedDeposit > 0
125
+ : !!depositValue && Number(depositValue) > 0;
117
126
  const deposit = hasDeposit
118
- ? Number(depositValue) * totalParticipants
127
+ ? previewedDeposit != null
128
+ ? previewedDeposit
129
+ : Number(depositValue) * totalParticipants
119
130
  : undefined;
120
131
  return {
121
132
  _id: item.lineItemId,
@@ -123,7 +134,7 @@ async function buildLineItemWithPreview(item, totalParticipants) {
123
134
  catalogItemId: item.service._id || '',
124
135
  appId: BOOKING_APP_ID,
125
136
  },
126
- price: String(previewedPrice),
137
+ price: String(previewedPrice.price),
127
138
  ...(deposit ? { depositAmount: String(deposit) } : {}),
128
139
  quantity: 1,
129
140
  paymentOption: getPaymentOption(item.service, hasDeposit),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -75,5 +75,5 @@
75
75
  "groupId": "com.wixpress.headless-components"
76
76
  }
77
77
  },
78
- "falconPackageHash": "60d159ffa08e430dd4c999859e909d281cd9262b93a577989e8de015"
78
+ "falconPackageHash": "dec47e7070b4b0988f6a3174a24135c58fd38c13c4a9d098bd0e9d99"
79
79
  }