@resira/ui 0.4.13 → 0.4.15
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/index.cjs +33 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -19
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2029,10 +2029,17 @@ function groupProductsByCategory(products, resources) {
|
|
|
2029
2029
|
let groupId;
|
|
2030
2030
|
let label;
|
|
2031
2031
|
let catImage;
|
|
2032
|
+
let catGalleryImages;
|
|
2032
2033
|
if (productCategory) {
|
|
2033
2034
|
groupId = productCategory.toLowerCase();
|
|
2034
2035
|
label = product.categoryName?.trim() ? product.categoryName.trim() : formatCategoryLabel(productCategory);
|
|
2036
|
+
catGalleryImages = Array.isArray(product.categoryGalleryImages) ? product.categoryGalleryImages.filter(
|
|
2037
|
+
(url) => typeof url === "string" && url.trim().length > 0
|
|
2038
|
+
) : void 0;
|
|
2035
2039
|
catImage = product.categoryImage ?? void 0;
|
|
2040
|
+
if (!catImage && catGalleryImages && catGalleryImages.length > 0) {
|
|
2041
|
+
catImage = catGalleryImages[0];
|
|
2042
|
+
}
|
|
2036
2043
|
} else {
|
|
2037
2044
|
let categoryResource;
|
|
2038
2045
|
const categoryType = product.equipmentIds.map((equipmentId) => {
|
|
@@ -2051,6 +2058,7 @@ function groupProductsByCategory(products, resources) {
|
|
|
2051
2058
|
id: groupId,
|
|
2052
2059
|
label,
|
|
2053
2060
|
imageUrl: catImage,
|
|
2061
|
+
galleryImages: catGalleryImages,
|
|
2054
2062
|
products: []
|
|
2055
2063
|
});
|
|
2056
2064
|
}
|
|
@@ -2059,14 +2067,11 @@ function groupProductsByCategory(products, resources) {
|
|
|
2059
2067
|
if (!group.imageUrl) {
|
|
2060
2068
|
if (catImage) {
|
|
2061
2069
|
group.imageUrl = catImage;
|
|
2062
|
-
} else {
|
|
2063
|
-
const coverImage = product.images?.[0];
|
|
2064
|
-
const firstImage = (coverImage?.showInCategoryHeader !== false ? coverImage?.url : void 0) ?? product.imageUrl;
|
|
2065
|
-
if (firstImage) {
|
|
2066
|
-
group.imageUrl = firstImage;
|
|
2067
|
-
}
|
|
2068
2070
|
}
|
|
2069
2071
|
}
|
|
2072
|
+
if ((!group.galleryImages || group.galleryImages.length === 0) && catGalleryImages && catGalleryImages.length > 0) {
|
|
2073
|
+
group.galleryImages = catGalleryImages;
|
|
2074
|
+
}
|
|
2070
2075
|
});
|
|
2071
2076
|
return Array.from(groups.values());
|
|
2072
2077
|
}
|
|
@@ -3090,6 +3095,14 @@ function formatPrice5(cents, currency) {
|
|
|
3090
3095
|
currency
|
|
3091
3096
|
}).format(cents / 100);
|
|
3092
3097
|
}
|
|
3098
|
+
function normalizeDurationMinutes(value) {
|
|
3099
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
3100
|
+
if (typeof value === "string" && value.trim()) {
|
|
3101
|
+
const parsed = Number(value);
|
|
3102
|
+
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
3103
|
+
}
|
|
3104
|
+
return void 0;
|
|
3105
|
+
}
|
|
3093
3106
|
function buildSteps(domain, hasPayment, catalogMode) {
|
|
3094
3107
|
const steps = [];
|
|
3095
3108
|
if (domain === "watersport" || domain === "service" || catalogMode && domain !== "restaurant") {
|
|
@@ -3207,6 +3220,7 @@ function ResiraBookingWidget() {
|
|
|
3207
3220
|
setPromoValidation(result);
|
|
3208
3221
|
}, []);
|
|
3209
3222
|
const [slotDate, setSlotDate] = useState(todayStr());
|
|
3223
|
+
const activeDurationMinutes = normalizeDurationMinutes(selection.duration);
|
|
3210
3224
|
const availabilityParams = useMemo(() => {
|
|
3211
3225
|
if (isDateBased) {
|
|
3212
3226
|
if (selection.startDate && selection.endDate) {
|
|
@@ -3217,9 +3231,9 @@ function ResiraBookingWidget() {
|
|
|
3217
3231
|
return {
|
|
3218
3232
|
date: slotDate,
|
|
3219
3233
|
partySize: selection.partySize,
|
|
3220
|
-
durationMinutes:
|
|
3234
|
+
durationMinutes: activeDurationMinutes
|
|
3221
3235
|
};
|
|
3222
|
-
}, [isDateBased, selection.startDate, selection.endDate, slotDate, selection.partySize,
|
|
3236
|
+
}, [isDateBased, selection.startDate, selection.endDate, slotDate, selection.partySize, activeDurationMinutes]);
|
|
3223
3237
|
const availabilityProductId = isServiceBased ? selectedProduct?.id : void 0;
|
|
3224
3238
|
const { data: availability, loading, error, refetch } = useAvailability(
|
|
3225
3239
|
availabilityParams,
|
|
@@ -3263,7 +3277,7 @@ function ResiraBookingWidget() {
|
|
|
3263
3277
|
productId: selectedProduct?.id ?? "",
|
|
3264
3278
|
resourceId,
|
|
3265
3279
|
partySize: selection.partySize,
|
|
3266
|
-
durationMinutes:
|
|
3280
|
+
durationMinutes: activeDurationMinutes,
|
|
3267
3281
|
startDate: selection.startDate,
|
|
3268
3282
|
startTime: selection.startTime,
|
|
3269
3283
|
endTime: selection.endTime,
|
|
@@ -3275,7 +3289,7 @@ function ResiraBookingWidget() {
|
|
|
3275
3289
|
termsAccepted: termsAccepted || void 0,
|
|
3276
3290
|
waiverAccepted: waiverAccepted || void 0
|
|
3277
3291
|
};
|
|
3278
|
-
}, [activeResourceId, selectedProduct, selection, guest, discountCode, termsAccepted, waiverAccepted, isCheckoutMode, checkoutSession, checkoutSessionToken]);
|
|
3292
|
+
}, [activeResourceId, selectedProduct, selection, guest, discountCode, termsAccepted, waiverAccepted, isCheckoutMode, checkoutSession, checkoutSessionToken, activeDurationMinutes]);
|
|
3279
3293
|
const blockedDates = useMemo(() => {
|
|
3280
3294
|
const dates = calendarData?.dates?.blockedDates ?? availability?.dates?.blockedDates ?? [];
|
|
3281
3295
|
return new Set(dates);
|
|
@@ -3295,11 +3309,11 @@ function ResiraBookingWidget() {
|
|
|
3295
3309
|
if (selectedProduct) {
|
|
3296
3310
|
let base = selectedProduct.priceCents;
|
|
3297
3311
|
if (selectedProduct.pricingModel === "per_rider" && activeRiderDurationPricing?.length) {
|
|
3298
|
-
const match =
|
|
3312
|
+
const match = activeDurationMinutes ? activeRiderDurationPricing.find((dp) => dp.durationMinutes === activeDurationMinutes) : activeRiderDurationPricing[0];
|
|
3299
3313
|
if (match) base = match.priceCents;
|
|
3300
|
-
} else if (selectedProduct.durationPricing?.length &&
|
|
3314
|
+
} else if (selectedProduct.durationPricing?.length && activeDurationMinutes) {
|
|
3301
3315
|
const match = selectedProduct.durationPricing.find(
|
|
3302
|
-
(dp) => dp.durationMinutes ===
|
|
3316
|
+
(dp) => dp.durationMinutes === activeDurationMinutes
|
|
3303
3317
|
);
|
|
3304
3318
|
if (match) base = match.priceCents;
|
|
3305
3319
|
}
|
|
@@ -3317,7 +3331,7 @@ function ResiraBookingWidget() {
|
|
|
3317
3331
|
return { total, amountNow, amountAtVenue };
|
|
3318
3332
|
}
|
|
3319
3333
|
return null;
|
|
3320
|
-
}, [selectedProduct, availability, selection.partySize,
|
|
3334
|
+
}, [selectedProduct, availability, selection.partySize, activeDurationMinutes, depositPercent, activeRiderDurationPricing]);
|
|
3321
3335
|
const stepTitle = useMemo(() => {
|
|
3322
3336
|
switch (step) {
|
|
3323
3337
|
case "resource":
|
|
@@ -3761,7 +3775,7 @@ function ResiraBookingWidget() {
|
|
|
3761
3775
|
onPartySizeChange: handlePartySizeChange,
|
|
3762
3776
|
showPartySize: true,
|
|
3763
3777
|
showDuration: domain === "watersport" || domain === "service",
|
|
3764
|
-
selectedDuration:
|
|
3778
|
+
selectedDuration: activeDurationMinutes,
|
|
3765
3779
|
onDurationChange: handleDurationChange,
|
|
3766
3780
|
maxPartySizeOverride: selectedProduct?.maxPartySize,
|
|
3767
3781
|
durationPricing: activeRiderDurationPricing ?? selectedProduct?.durationPricing,
|
|
@@ -3773,19 +3787,19 @@ function ResiraBookingWidget() {
|
|
|
3773
3787
|
/* @__PURE__ */ jsxs("div", { className: "resira-price-preview-row", children: [
|
|
3774
3788
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
3775
3789
|
selectedProduct.name,
|
|
3776
|
-
|
|
3790
|
+
activeDurationMinutes && selectedProduct.durationPricing && selectedProduct.durationPricing.length > 1 && /* @__PURE__ */ jsxs("span", { className: "resira-price-preview-label", children: [
|
|
3777
3791
|
" ",
|
|
3778
3792
|
"(",
|
|
3779
|
-
|
|
3793
|
+
activeDurationMinutes < 60 ? `${activeDurationMinutes} min` : `${Math.floor(activeDurationMinutes / 60)}h${activeDurationMinutes % 60 ? activeDurationMinutes % 60 : ""}`,
|
|
3780
3794
|
")"
|
|
3781
3795
|
] })
|
|
3782
3796
|
] }),
|
|
3783
3797
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
3784
3798
|
(() => {
|
|
3785
3799
|
let unitPrice = selectedProduct.priceCents;
|
|
3786
|
-
if (selectedProduct.durationPricing?.length &&
|
|
3800
|
+
if (selectedProduct.durationPricing?.length && activeDurationMinutes) {
|
|
3787
3801
|
const match = selectedProduct.durationPricing.find(
|
|
3788
|
-
(dp) => dp.durationMinutes ===
|
|
3802
|
+
(dp) => dp.durationMinutes === activeDurationMinutes
|
|
3789
3803
|
);
|
|
3790
3804
|
if (match) unitPrice = match.priceCents;
|
|
3791
3805
|
}
|