kupos-ui-components-lib 10.4.22 → 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.
@@ -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 = ((hasOfferText && isNewUiEnabled) || hasDpEnabled) && !isSoldOut
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) && !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 })),
417
- React.createElement("div", { id: `service-card-${serviceItem.id}`, className: `bg-white mx-auto relative ${((hasOfferText && isNewUiEnabled) || hasDpEnabled) && !isSoldOut
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 && offerText) {
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: ((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_dp_enabled) && (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dp_discount_percents))
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "10.4.22",
3
+ "version": "10.4.24",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -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
- ((hasOfferText && isNewUiEnabled) || hasDpEnabled) && !isSoldOut
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) && !isSoldOut && (
639
- <PeruOfferBanner
640
- offerGradient={offerGradient}
641
- isSoldOut={isSoldOut}
642
- serviceItem={serviceItem}
643
- renderIcon={renderIcon}
644
- isLoggedIn={isLoggedIn}
645
- showLoginModal={showLoginModal}
646
- viewersConfig={viewersConfig}
647
- getAnimationIcon={getAnimationIcon}
648
- showLoginOption={showLoginOption}
649
- colors={colors}
650
- coachKey={coachKey}
651
- isExpand={isExpand}
652
- isNewUiEnabled={isNewUiEnabled}
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
- ((hasOfferText && isNewUiEnabled) || hasDpEnabled) && !isSoldOut
660
+ (hasOfferText || isNewUiEnabled || hasDiscount || hasDpEnabled) &&
661
+ !isSoldOut
659
662
  ? "z-[3] rounded-[18px]"
660
663
  : "rounded-[10px] border border-[#ccc]"
661
664
  }`}
@@ -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 && offerText) {
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
- (serviceItem?.is_dp_enabled && serviceItem?.dp_discount_percents)
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,