kupos-ui-components-lib 10.4.21 → 10.4.24
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/components/ServiceItem/PeruServiceItemDesktop.js +11 -8
- package/dist/components/ServiceItem/types.d.ts +1 -0
- package/dist/ui/PeruOfferBanner.js +5 -4
- package/dist/ui/ServiceBadges/ServiceBadges.js +6 -6
- package/package.json +1 -1
- package/src/components/ServiceItem/PeruServiceItemDesktop.tsx +38 -35
- package/src/components/ServiceItem/types.ts +1 -0
- package/src/ui/PeruOfferBanner.tsx +5 -5
- package/src/ui/ServiceBadges/ServiceBadges.tsx +6 -10
|
@@ -387,13 +387,19 @@ function PeruServiceItemDesktop({ serviceItem, onBookButtonPress, colors, metaDa
|
|
|
387
387
|
render: (React.createElement(FlexibleBlock, { translation: translation, getAnimationIcon: getAnimationIcon, colors: colors, serviceItem: serviceItem, isSoldOut: isSoldOut })),
|
|
388
388
|
},
|
|
389
389
|
];
|
|
390
|
+
const seats = removeDuplicateSeats
|
|
391
|
+
? ((_c = serviceItem.seat_types) === null || _c === void 0 ? void 0 : _c.filter((seat, index, self) => index === self.findIndex((s) => s.label === seat.label))) || []
|
|
392
|
+
: serviceItem.seat_types || [];
|
|
393
|
+
const discountedSeats = seats.map((seat) => (Object.assign(Object.assign({}, seat), CommonService.calculateDiscountedPrice(seat.fare, serviceItem))));
|
|
394
|
+
const hasDiscount = discountedSeats.some((seat) => seat.originalPrice !== seat.discountedPrice);
|
|
390
395
|
const otherItems = items.filter((i) => i.key !== "pet" && i.key !== "flexible" && !!i.condition);
|
|
391
396
|
const isItemExpanded = serviceItem.id === isExpand || isExpand === true;
|
|
392
397
|
const grayscaleClass = isSoldOut ? "grayscale" : "";
|
|
393
398
|
const hasOfferText = Boolean(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text);
|
|
394
399
|
const offerGradient = `linear-gradient(90deg, ${colors.rightGradiantColor || "#ff5964"} 0%, ${colors.leftGradiantColor || "#ff8842"} 100%)`;
|
|
395
400
|
const offerGradientWithOpacity = `linear-gradient(90deg, ${colors.rightGradiantColor || "#ff5964"}80 0%, ${colors.leftGradiantColor || "#ff8842"}80 100%)`;
|
|
396
|
-
const serviceCardStyle = (
|
|
401
|
+
const serviceCardStyle = (hasOfferText || isNewUiEnabled || hasDpEnabled || hasDiscount) &&
|
|
402
|
+
!isSoldOut
|
|
397
403
|
? {
|
|
398
404
|
borderColor: "transparent",
|
|
399
405
|
borderStyle: "solid",
|
|
@@ -403,18 +409,15 @@ function PeruServiceItemDesktop({ serviceItem, onBookButtonPress, colors, metaDa
|
|
|
403
409
|
// zIndex: 1,
|
|
404
410
|
}
|
|
405
411
|
: {};
|
|
406
|
-
const seats = removeDuplicateSeats
|
|
407
|
-
? ((_c = serviceItem.seat_types) === null || _c === void 0 ? void 0 : _c.filter((seat, index, self) => index === self.findIndex((s) => s.label === seat.label))) || []
|
|
408
|
-
: serviceItem.seat_types || [];
|
|
409
|
-
const discountedSeats = seats.map((seat) => (Object.assign(Object.assign({}, seat), CommonService.calculateDiscountedPrice(seat.fare, serviceItem))));
|
|
410
|
-
const hasDiscount = discountedSeats.some((seat) => seat.originalPrice !== seat.discountedPrice);
|
|
411
412
|
return (React.createElement("div", { className: `relative hover:z-[150] ${(hasOfferText || hasDpEnabled || isNewUiEnabled) && !isSoldOut ? "mb-[65px]" : "mb-[20px]"} ${(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_direct_trip) ||
|
|
412
413
|
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.train_type_label) === "Tren Express (Nuevo)" ||
|
|
413
414
|
showTopLabel
|
|
414
415
|
? "mt-[30px]"
|
|
415
416
|
: "mt-[20px]"} ` },
|
|
416
|
-
((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) || hasDpEnabled
|
|
417
|
-
|
|
417
|
+
((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) || hasDpEnabled || hasDiscount) &&
|
|
418
|
+
!isSoldOut && (React.createElement(PeruOfferBanner, { offerGradient: offerGradient, isSoldOut: isSoldOut, serviceItem: serviceItem, renderIcon: renderIcon, isLoggedIn: isLoggedIn, showLoginModal: showLoginModal, viewersConfig: viewersConfig, getAnimationIcon: getAnimationIcon, showLoginOption: showLoginOption, colors: colors, coachKey: coachKey, isExpand: isExpand, isNewUiEnabled: isNewUiEnabled })),
|
|
419
|
+
React.createElement("div", { id: `service-card-${serviceItem.id}`, className: `bg-white mx-auto relative ${(hasOfferText || isNewUiEnabled || hasDiscount || hasDpEnabled) &&
|
|
420
|
+
!isSoldOut
|
|
418
421
|
? "z-[3] rounded-[18px]"
|
|
419
422
|
: "rounded-[10px] border border-[#ccc]"}`, style: serviceCardStyle },
|
|
420
423
|
React.createElement("div", { className: " pt-[20px]", style: {
|
|
@@ -60,8 +60,7 @@ const PeruOfferBanner = ({ offerGradient, isSoldOut, serviceItem, isLoggedIn, sh
|
|
|
60
60
|
const isDiscountBelow20 = (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.discount_value) > 0 &&
|
|
61
61
|
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.discount_value) < 20;
|
|
62
62
|
const offerText = isDiscountBelow20 ? "" : (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) || "";
|
|
63
|
-
const isLegacyOffer = !!offerText &&
|
|
64
|
-
!isNewUiEnabled;
|
|
63
|
+
const isLegacyOffer = !!offerText && !isNewUiEnabled;
|
|
65
64
|
// const showViewers = serviceItem?.is_dp_enabled;
|
|
66
65
|
const showViewers = isNewUiEnabled;
|
|
67
66
|
const background = isLegacyOffer ? colors === null || colors === void 0 ? void 0 : colors.bottomStripColor : offerGradient;
|
|
@@ -71,7 +70,7 @@ const PeruOfferBanner = ({ offerGradient, isSoldOut, serviceItem, isLoggedIn, sh
|
|
|
71
70
|
return React.createElement(PopularServiceBanner, { getAnimationIcon: getAnimationIcon });
|
|
72
71
|
}
|
|
73
72
|
// If new UI is enabled, show offer with registro and countdown
|
|
74
|
-
if (isNewUiEnabled
|
|
73
|
+
if (isNewUiEnabled || offerText || (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.discount_value)) {
|
|
75
74
|
return (React.createElement(OfferBannerContent, { offerText: offerText, isLoggedIn: isLoggedIn, showLoginModal: showLoginModal, showLoginOption: showLoginOption, getAnimationIcon: getAnimationIcon, hideRegister: hasDp, showLoginButton: serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.show_register_button }));
|
|
76
75
|
}
|
|
77
76
|
// If new UI is disabled, show offer text only
|
|
@@ -81,7 +80,9 @@ const PeruOfferBanner = ({ offerGradient, isSoldOut, serviceItem, isLoggedIn, sh
|
|
|
81
80
|
return null;
|
|
82
81
|
};
|
|
83
82
|
return (React.createElement("div", { className: `text-white w-full absolute ${coachKey ? "-bottom-[32px]" : isExpand ? "-bottom-[32px]" : "-bottom-[40px]"} rounded-b-[14px] text-[14px] h-[58px] flex items-end pb-[7px]`, style: {
|
|
84
|
-
background: (
|
|
83
|
+
background: (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_dp_enabled) ||
|
|
84
|
+
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dp_discount_percents) ||
|
|
85
|
+
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.discount_value)
|
|
85
86
|
? offerGradient
|
|
86
87
|
: background,
|
|
87
88
|
opacity: isSoldOut ? 0.5 : 1,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import LottiePlayer from "../../assets/LottiePlayer";
|
|
3
2
|
import CommonService from "../../utils/CommonService";
|
|
4
3
|
const ServiceBadges = ({ showTopLabel, isSoldOut, colors, renderIcon, translation, serviceItem, isAllinBus = false, boardingName, getAnimationIcon, }) => {
|
|
5
4
|
return (React.createElement("div", { className: "absolute -top-[10px] left-0 w-full flex items-center justify-end gap-[12px] pr-[22px] z-10" },
|
|
@@ -45,11 +44,12 @@ const ServiceBadges = ({ showTopLabel, isSoldOut, colors, renderIcon, translatio
|
|
|
45
44
|
backgroundColor: colors.topLabelBgColor || "#fff",
|
|
46
45
|
border: isSoldOut
|
|
47
46
|
? "1px solid #ccc"
|
|
48
|
-
: `1px solid ${colors.
|
|
49
|
-
color: isSoldOut ? "#ccc" : colors.
|
|
47
|
+
: `1px solid ${colors.boardingBorderColor}`,
|
|
48
|
+
color: isSoldOut ? "#ccc" : colors.boardingBorderColor,
|
|
50
49
|
} },
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
renderIcon("specialDeparture", "12px", {
|
|
51
|
+
filter: isSoldOut ? "grayscale(0.5)" : "",
|
|
52
|
+
}),
|
|
53
|
+
React.createElement("div", { className: isSoldOut ? "text-white" : `text-[${colors.boardingBorderColor}]` }, CommonService.capitalize(boardingName))))));
|
|
54
54
|
};
|
|
55
55
|
export default ServiceBadges;
|
package/package.json
CHANGED
|
@@ -586,6 +586,22 @@ function PeruServiceItemDesktop({
|
|
|
586
586
|
},
|
|
587
587
|
];
|
|
588
588
|
|
|
589
|
+
const seats = removeDuplicateSeats
|
|
590
|
+
? serviceItem.seat_types?.filter(
|
|
591
|
+
(seat, index, self) =>
|
|
592
|
+
index === self.findIndex((s) => s.label === seat.label),
|
|
593
|
+
) || []
|
|
594
|
+
: serviceItem.seat_types || [];
|
|
595
|
+
|
|
596
|
+
const discountedSeats = seats.map((seat) => ({
|
|
597
|
+
...seat,
|
|
598
|
+
...CommonService.calculateDiscountedPrice(seat.fare, serviceItem as any),
|
|
599
|
+
}));
|
|
600
|
+
|
|
601
|
+
const hasDiscount = discountedSeats.some(
|
|
602
|
+
(seat) => seat.originalPrice !== seat.discountedPrice,
|
|
603
|
+
);
|
|
604
|
+
|
|
589
605
|
const otherItems = items.filter(
|
|
590
606
|
(i) => i.key !== "pet" && i.key !== "flexible" && !!i.condition,
|
|
591
607
|
);
|
|
@@ -598,7 +614,8 @@ function PeruServiceItemDesktop({
|
|
|
598
614
|
const offerGradient = `linear-gradient(90deg, ${colors.rightGradiantColor || "#ff5964"} 0%, ${colors.leftGradiantColor || "#ff8842"} 100%)`;
|
|
599
615
|
const offerGradientWithOpacity = `linear-gradient(90deg, ${colors.rightGradiantColor || "#ff5964"}80 0%, ${colors.leftGradiantColor || "#ff8842"}80 100%)`;
|
|
600
616
|
const serviceCardStyle: React.CSSProperties =
|
|
601
|
-
(
|
|
617
|
+
(hasOfferText || isNewUiEnabled || hasDpEnabled || hasDiscount) &&
|
|
618
|
+
!isSoldOut
|
|
602
619
|
? {
|
|
603
620
|
borderColor: "transparent",
|
|
604
621
|
borderStyle: "solid",
|
|
@@ -609,22 +626,6 @@ function PeruServiceItemDesktop({
|
|
|
609
626
|
}
|
|
610
627
|
: {};
|
|
611
628
|
|
|
612
|
-
const seats = removeDuplicateSeats
|
|
613
|
-
? serviceItem.seat_types?.filter(
|
|
614
|
-
(seat, index, self) =>
|
|
615
|
-
index === self.findIndex((s) => s.label === seat.label),
|
|
616
|
-
) || []
|
|
617
|
-
: serviceItem.seat_types || [];
|
|
618
|
-
|
|
619
|
-
const discountedSeats = seats.map((seat) => ({
|
|
620
|
-
...seat,
|
|
621
|
-
...CommonService.calculateDiscountedPrice(seat.fare, serviceItem as any),
|
|
622
|
-
}));
|
|
623
|
-
|
|
624
|
-
const hasDiscount = discountedSeats.some(
|
|
625
|
-
(seat) => seat.originalPrice !== seat.discountedPrice,
|
|
626
|
-
);
|
|
627
|
-
|
|
628
629
|
return (
|
|
629
630
|
<div
|
|
630
631
|
className={`relative hover:z-[150] ${(hasOfferText || hasDpEnabled || isNewUiEnabled) && !isSoldOut ? "mb-[65px]" : "mb-[20px]"} ${
|
|
@@ -635,27 +636,29 @@ function PeruServiceItemDesktop({
|
|
|
635
636
|
: "mt-[20px]"
|
|
636
637
|
} `}
|
|
637
638
|
>
|
|
638
|
-
{(serviceItem?.offer_text || hasDpEnabled
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
639
|
+
{(serviceItem?.offer_text || hasDpEnabled || hasDiscount) &&
|
|
640
|
+
!isSoldOut && (
|
|
641
|
+
<PeruOfferBanner
|
|
642
|
+
offerGradient={offerGradient}
|
|
643
|
+
isSoldOut={isSoldOut}
|
|
644
|
+
serviceItem={serviceItem}
|
|
645
|
+
renderIcon={renderIcon}
|
|
646
|
+
isLoggedIn={isLoggedIn}
|
|
647
|
+
showLoginModal={showLoginModal}
|
|
648
|
+
viewersConfig={viewersConfig}
|
|
649
|
+
getAnimationIcon={getAnimationIcon}
|
|
650
|
+
showLoginOption={showLoginOption}
|
|
651
|
+
colors={colors}
|
|
652
|
+
coachKey={coachKey}
|
|
653
|
+
isExpand={isExpand}
|
|
654
|
+
isNewUiEnabled={isNewUiEnabled}
|
|
655
|
+
/>
|
|
656
|
+
)}
|
|
655
657
|
<div
|
|
656
658
|
id={`service-card-${serviceItem.id}`}
|
|
657
659
|
className={`bg-white mx-auto relative ${
|
|
658
|
-
(
|
|
660
|
+
(hasOfferText || isNewUiEnabled || hasDiscount || hasDpEnabled) &&
|
|
661
|
+
!isSoldOut
|
|
659
662
|
? "z-[3] rounded-[18px]"
|
|
660
663
|
: "rounded-[10px] border border-[#ccc]"
|
|
661
664
|
}`}
|
|
@@ -183,6 +183,7 @@ export interface ServiceItemProps {
|
|
|
183
183
|
leftGradiantColor?: string;
|
|
184
184
|
discountSeatPriceColor?: string;
|
|
185
185
|
topLabelBgColor?: string;
|
|
186
|
+
boardingBorderColor?: string;
|
|
186
187
|
};
|
|
187
188
|
cityOrigin?: { value: number; label: string };
|
|
188
189
|
cityDestination?: { value: number; label: string };
|
|
@@ -223,9 +223,7 @@ const PeruOfferBanner: React.FC<PeruOfferBannerProps> = ({
|
|
|
223
223
|
(serviceItem as any)?.discount_value < 20;
|
|
224
224
|
const offerText = isDiscountBelow20 ? "" : serviceItem?.offer_text || "";
|
|
225
225
|
|
|
226
|
-
const isLegacyOffer =
|
|
227
|
-
!!offerText &&
|
|
228
|
-
!isNewUiEnabled;
|
|
226
|
+
const isLegacyOffer = !!offerText && !isNewUiEnabled;
|
|
229
227
|
|
|
230
228
|
// const showViewers = serviceItem?.is_dp_enabled;
|
|
231
229
|
const showViewers = isNewUiEnabled;
|
|
@@ -240,7 +238,7 @@ const PeruOfferBanner: React.FC<PeruOfferBannerProps> = ({
|
|
|
240
238
|
}
|
|
241
239
|
|
|
242
240
|
// If new UI is enabled, show offer with registro and countdown
|
|
243
|
-
if (isNewUiEnabled
|
|
241
|
+
if (isNewUiEnabled || offerText || (serviceItem as any)?.discount_value) {
|
|
244
242
|
return (
|
|
245
243
|
<OfferBannerContent
|
|
246
244
|
offerText={offerText}
|
|
@@ -272,7 +270,9 @@ const PeruOfferBanner: React.FC<PeruOfferBannerProps> = ({
|
|
|
272
270
|
className={`text-white w-full absolute ${coachKey ? "-bottom-[32px]" : isExpand ? "-bottom-[32px]" : "-bottom-[40px]"} rounded-b-[14px] text-[14px] h-[58px] flex items-end pb-[7px]`}
|
|
273
271
|
style={{
|
|
274
272
|
background:
|
|
275
|
-
|
|
273
|
+
serviceItem?.is_dp_enabled ||
|
|
274
|
+
serviceItem?.dp_discount_percents ||
|
|
275
|
+
(serviceItem as any)?.discount_value
|
|
276
276
|
? offerGradient
|
|
277
277
|
: background,
|
|
278
278
|
opacity: isSoldOut ? 0.5 : 1,
|
|
@@ -104,20 +104,16 @@ const ServiceBadges: React.FC<ServiceBadgesProps> = ({
|
|
|
104
104
|
backgroundColor: colors.topLabelBgColor || "#fff",
|
|
105
105
|
border: isSoldOut
|
|
106
106
|
? "1px solid #ccc"
|
|
107
|
-
: `1px solid ${colors.
|
|
108
|
-
color: isSoldOut ? "#ccc" : colors.
|
|
107
|
+
: `1px solid ${colors.boardingBorderColor}`,
|
|
108
|
+
color: isSoldOut ? "#ccc" : colors.boardingBorderColor,
|
|
109
109
|
}}
|
|
110
110
|
>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
width="14px"
|
|
115
|
-
height="14px"
|
|
116
|
-
/>
|
|
117
|
-
</div>
|
|
111
|
+
{renderIcon("specialDeparture", "12px", {
|
|
112
|
+
filter: isSoldOut ? "grayscale(0.5)" : "",
|
|
113
|
+
})}
|
|
118
114
|
<div
|
|
119
115
|
className={
|
|
120
|
-
isSoldOut ? "text-white" : `text-[${colors.
|
|
116
|
+
isSoldOut ? "text-white" : `text-[${colors.boardingBorderColor}]`
|
|
121
117
|
}
|
|
122
118
|
>
|
|
123
119
|
{CommonService.capitalize(boardingName)}
|