@resira/ui 0.4.8 → 0.4.10
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/README.md +238 -238
- package/dist/index.cjs +47 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -19
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2972 -2972
- package/package.json +59 -59
package/dist/index.js
CHANGED
|
@@ -379,7 +379,7 @@ function useReservation() {
|
|
|
379
379
|
const [error, setError] = useState(null);
|
|
380
380
|
const submit = useCallback(
|
|
381
381
|
async (data) => {
|
|
382
|
-
if (!data.resourceId) {
|
|
382
|
+
if (!data.resourceId && !data.checkoutSessionToken) {
|
|
383
383
|
setError("No resource selected");
|
|
384
384
|
return null;
|
|
385
385
|
}
|
|
@@ -1894,18 +1894,28 @@ function groupProductsByCategory(products, resources) {
|
|
|
1894
1894
|
);
|
|
1895
1895
|
const groups = /* @__PURE__ */ new Map();
|
|
1896
1896
|
products.forEach((product) => {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1897
|
+
const productCategory = product.category?.trim();
|
|
1898
|
+
let groupId;
|
|
1899
|
+
let label;
|
|
1900
|
+
let catImage;
|
|
1901
|
+
if (productCategory) {
|
|
1902
|
+
groupId = productCategory.toLowerCase();
|
|
1903
|
+
label = product.categoryName?.trim() ? product.categoryName.trim() : formatCategoryLabel(productCategory);
|
|
1904
|
+
catImage = product.categoryImage ?? void 0;
|
|
1905
|
+
} else {
|
|
1906
|
+
let categoryResource;
|
|
1907
|
+
const categoryType = product.equipmentIds.map((equipmentId) => {
|
|
1908
|
+
const res = resourceById.get(equipmentId);
|
|
1909
|
+
if (res?.resourceType?.trim() && !categoryResource) {
|
|
1910
|
+
categoryResource = res;
|
|
1911
|
+
}
|
|
1912
|
+
return res?.resourceType?.trim();
|
|
1913
|
+
}).find((resourceType) => Boolean(resourceType));
|
|
1914
|
+
groupId = categoryType?.toLowerCase() ?? UNCATEGORIZED_CATEGORY_KEY;
|
|
1915
|
+
label = categoryType ? formatCategoryLabel(categoryType) : UNCATEGORIZED_CATEGORY_LABEL;
|
|
1916
|
+
catImage = categoryResource?.images?.[0]?.url ?? categoryResource?.imageUrl ?? void 0;
|
|
1917
|
+
}
|
|
1907
1918
|
if (!groups.has(groupId)) {
|
|
1908
|
-
const catImage = categoryResource?.images?.[0]?.url ?? categoryResource?.imageUrl ?? void 0;
|
|
1909
1919
|
groups.set(groupId, {
|
|
1910
1920
|
id: groupId,
|
|
1911
1921
|
label,
|
|
@@ -1915,8 +1925,16 @@ function groupProductsByCategory(products, resources) {
|
|
|
1915
1925
|
}
|
|
1916
1926
|
const group = groups.get(groupId);
|
|
1917
1927
|
group.products.push(product);
|
|
1918
|
-
if (!group.imageUrl
|
|
1919
|
-
|
|
1928
|
+
if (!group.imageUrl) {
|
|
1929
|
+
if (catImage) {
|
|
1930
|
+
group.imageUrl = catImage;
|
|
1931
|
+
} else {
|
|
1932
|
+
const coverImage = product.images?.[0];
|
|
1933
|
+
const firstImage = (coverImage?.showInCategoryHeader !== false ? coverImage?.url : void 0) ?? product.imageUrl;
|
|
1934
|
+
if (firstImage) {
|
|
1935
|
+
group.imageUrl = firstImage;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1920
1938
|
}
|
|
1921
1939
|
});
|
|
1922
1940
|
return Array.from(groups.values());
|
|
@@ -3079,9 +3097,10 @@ function ResiraBookingWidget() {
|
|
|
3079
3097
|
guestPhone: guest.guestPhone.trim() || void 0,
|
|
3080
3098
|
notes: guest.notes.trim() || void 0,
|
|
3081
3099
|
promoCode: discountCode.trim() || void 0,
|
|
3082
|
-
termsAccepted: termsAccepted || void 0
|
|
3100
|
+
termsAccepted: termsAccepted || void 0,
|
|
3101
|
+
waiverAccepted: waiverAccepted || void 0
|
|
3083
3102
|
};
|
|
3084
|
-
}, [activeResourceId, selectedProduct, selection, guest, discountCode, termsAccepted, isCheckoutMode, checkoutSession, checkoutSessionToken]);
|
|
3103
|
+
}, [activeResourceId, selectedProduct, selection, guest, discountCode, termsAccepted, waiverAccepted, isCheckoutMode, checkoutSession, checkoutSessionToken]);
|
|
3085
3104
|
const blockedDates = useMemo(() => {
|
|
3086
3105
|
const dates = calendarData?.dates?.blockedDates ?? availability?.dates?.blockedDates ?? [];
|
|
3087
3106
|
return new Set(dates);
|
|
@@ -3312,7 +3331,9 @@ function ResiraBookingWidget() {
|
|
|
3312
3331
|
startTime: selection.startTime,
|
|
3313
3332
|
endTime: selection.endTime,
|
|
3314
3333
|
partySize: selection.partySize,
|
|
3315
|
-
notes: guest.notes.trim() || void 0
|
|
3334
|
+
notes: guest.notes.trim() || void 0,
|
|
3335
|
+
termsAccepted: termsAccepted || void 0,
|
|
3336
|
+
waiverAccepted: waiverAccepted || void 0
|
|
3316
3337
|
};
|
|
3317
3338
|
const result = await submit(payload);
|
|
3318
3339
|
if (result) {
|
|
@@ -3362,6 +3383,10 @@ function ResiraBookingWidget() {
|
|
|
3362
3383
|
setTermsError(locale.termsRequired);
|
|
3363
3384
|
return;
|
|
3364
3385
|
}
|
|
3386
|
+
if (showWaiver && !waiverAccepted) {
|
|
3387
|
+
setTermsError(locale.termsRequired);
|
|
3388
|
+
return;
|
|
3389
|
+
}
|
|
3365
3390
|
setTermsError(null);
|
|
3366
3391
|
const result = await createPayment(paymentPayload);
|
|
3367
3392
|
if (!result) return;
|
|
@@ -3386,7 +3411,8 @@ function ResiraBookingWidget() {
|
|
|
3386
3411
|
}
|
|
3387
3412
|
const resourceId = activeResourceId ?? selectedProduct?.equipmentIds?.[0] ?? "";
|
|
3388
3413
|
const payload = {
|
|
3389
|
-
resourceId,
|
|
3414
|
+
resourceId: isCheckoutMode ? void 0 : resourceId,
|
|
3415
|
+
checkoutSessionToken: isCheckoutMode ? checkoutSessionToken : void 0,
|
|
3390
3416
|
guestName: guest.guestName.trim(),
|
|
3391
3417
|
guestEmail: guest.guestEmail.trim() || void 0,
|
|
3392
3418
|
guestPhone: guest.guestPhone.trim() || void 0,
|
|
@@ -3395,7 +3421,9 @@ function ResiraBookingWidget() {
|
|
|
3395
3421
|
startTime: selection.startTime,
|
|
3396
3422
|
endTime: selection.endTime,
|
|
3397
3423
|
partySize: selection.partySize,
|
|
3398
|
-
notes: guest.notes.trim() || void 0
|
|
3424
|
+
notes: guest.notes.trim() || void 0,
|
|
3425
|
+
termsAccepted: termsAccepted || void 0,
|
|
3426
|
+
waiverAccepted: waiverAccepted || void 0
|
|
3399
3427
|
};
|
|
3400
3428
|
const result = await submit(payload);
|
|
3401
3429
|
if (result) {
|