kupos-ui-components-lib 10.4.73 → 10.4.75

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.
@@ -147,7 +147,6 @@ class DiscountBannersDesktop extends React.Component {
147
147
  }
148
148
  render() {
149
149
  const { services = [], wowDealData, backgroundImages = [], artIncludesChipPill, accentColors = [], label = DEFAULT_LABEL, currencySign = "$", size = "default", selectedKey, className = "", style, } = this.props;
150
- console.log("🚀 ~ DiscountBannersDesktop ~ render ~ services:", services);
151
150
  // Compute cards directly — no useMemo
152
151
  const cards = deriveDiscountCards(services, wowDealData, currencySign);
153
152
  if (!cards.length)
@@ -498,7 +498,7 @@ function PeruServiceItemDesktop({ serviceItem, onBookButtonPress, colors, metaDa
498
498
  (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats) > 0 && (React.createElement("div", { className: "text-[11px] mt-1 text-center whitespace-nowrap", style: {
499
499
  color: colors.seatPriceColor,
500
500
  } }, "\u00A1\u00DAltimos Asientos!")))) : null)),
501
- React.createElement(BottomAmenities, { otherItems: otherItems, serviceItem: serviceItem, grayscaleClass: grayscaleClass, isSoldOut: isSoldOut, isItemExpanded: isItemExpanded, colors: colors, translation: translation, getAnimationIcon: getAnimationIcon, downArrowIcon: renderIcon("downArrow", "10px"), onToggleExpand: () => setIsExpand && setIsExpand(isItemExpanded ? null : serviceItem.id), isPeru: isPeru }))),
501
+ React.createElement(BottomAmenities, { otherItems: otherItems, serviceItem: serviceItem, grayscaleClass: grayscaleClass, isSoldOut: isSoldOut, isItemExpanded: isItemExpanded, colors: colors, translation: translation, getAnimationIcon: getAnimationIcon, downArrowIcon: renderIcon("downArrow", "10px"), onToggleExpand: () => setIsExpand && setIsExpand(isItemExpanded ? null : serviceItem.id), isPeru: isPeru, availableSeats: showAvailableSeats ? serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats : undefined }))),
502
502
  children,
503
503
  React.createElement(ServiceBadges, { showTopLabel: showTopLabel || undefined, isSoldOut: isSoldOut, colors: colors, renderIcon: renderIcon, translation: translation, serviceItem: serviceItem, isAllinBus: isAllinBus, boardingName: boardingName, getAnimationIcon: getAnimationIcon })));
504
504
  }
@@ -378,7 +378,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
378
378
  color: colors.seatPriceColor,
379
379
  } }, "\u00A1\u00DAltimos Asientos!")))) : null)),
380
380
  React.createElement(BottomAmenities, { otherItems: otherItems, serviceItem: serviceItem, grayscaleClass: grayscaleClass, isSoldOut: isSoldOut, isItemExpanded: isItemExpanded, colors: colors, translation: translation, getAnimationIcon: getAnimationIcon, downArrowIcon: renderIcon("downArrow", "10px"), onToggleExpand: () => setIsExpand &&
381
- setIsExpand(isItemExpanded ? null : serviceItem.id), isPeru: isPeru, isTrain: isTrain, isDpEnabled: serviceItem.is_dp_enabled, serviceType: showServiceTypeUnderLogo ? undefined : serviceItem.service_type, renderIcon: renderIcon }))),
381
+ setIsExpand(isItemExpanded ? null : serviceItem.id), isPeru: isPeru, isTrain: isTrain, isDpEnabled: serviceItem.is_dp_enabled, serviceType: showServiceTypeUnderLogo ? undefined : serviceItem.service_type, renderIcon: renderIcon, availableSeats: showAvailableSeats ? serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats : undefined }))),
382
382
  isPeru ? null : (React.createElement("div", { style: {
383
383
  display: "grid",
384
384
  gridTemplateRows: isItemExpanded ? "1fr" : "0fr",
package/dist/styles.css CHANGED
@@ -552,9 +552,6 @@
552
552
  .w-\[120px\] {
553
553
  width: 120px;
554
554
  }
555
- .w-\[150px\] {
556
- width: 150px;
557
- }
558
555
  .w-\[170px\] {
559
556
  width: 170px;
560
557
  }
@@ -623,6 +620,9 @@
623
620
  .min-w-\[75px\] {
624
621
  min-width: 75px;
625
622
  }
623
+ .min-w-\[150px\] {
624
+ min-width: 150px;
625
+ }
626
626
  .flex-1 {
627
627
  flex: 1;
628
628
  }
@@ -28,6 +28,7 @@ interface BottomAmenitiesProps {
28
28
  isDpEnabled?: boolean;
29
29
  serviceType?: string;
30
30
  renderIcon?: (iconKey: string, size?: string) => React.ReactNode;
31
+ availableSeats?: number;
31
32
  }
32
- declare function BottomAmenities({ otherItems, serviceItem, grayscaleClass, isSoldOut, isItemExpanded, colors, translation, getAnimationIcon, downArrowIcon, onToggleExpand, isPeru, isTrain, isDpEnabled, serviceType, renderIcon, }: BottomAmenitiesProps): React.ReactElement;
33
+ declare function BottomAmenities({ otherItems, serviceItem, grayscaleClass, isSoldOut, isItemExpanded, colors, translation, getAnimationIcon, downArrowIcon, onToggleExpand, isPeru, isTrain, isDpEnabled, serviceType, renderIcon, availableSeats, }: BottomAmenitiesProps): React.ReactElement;
33
34
  export default BottomAmenities;
@@ -4,7 +4,7 @@ import FlexibleBlock from "../FlexibleBlock";
4
4
  import PetBlock from "../PetBlock";
5
5
  import FemaleBlock from "../FemaleBlock";
6
6
  import CommonService from "../../utils/CommonService";
7
- function BottomAmenities({ otherItems, serviceItem, grayscaleClass, isSoldOut, isItemExpanded, colors, translation, getAnimationIcon, downArrowIcon, onToggleExpand, isPeru, isTrain, isDpEnabled, serviceType, renderIcon, }) {
7
+ function BottomAmenities({ otherItems, serviceItem, grayscaleClass, isSoldOut, isItemExpanded, colors, translation, getAnimationIcon, downArrowIcon, onToggleExpand, isPeru, isTrain, isDpEnabled, serviceType, renderIcon, availableSeats, }) {
8
8
  const hasPetInfo = serviceItem.pet_seat_info &&
9
9
  Object.keys(serviceItem.pet_seat_info).length > 0;
10
10
  const showDownArrow = ((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_change_ticket) && serviceItem.pet_seat_info) ||
@@ -20,7 +20,11 @@ function BottomAmenities({ otherItems, serviceItem, grayscaleClass, isSoldOut, i
20
20
  serviceType && (React.createElement("div", { className: `flex items-center gap-[3px] text-[13.33px] whitespace-nowrap ${isSoldOut ? "text-[#c0c0c0]" : "text-[#464647]"}`, style: { gridColumn: 4 } }, renderIcon === null || renderIcon === void 0 ? void 0 :
21
21
  renderIcon("serviceTypeIcon", "15px"),
22
22
  React.createElement("span", { className: "bold-text" }, CommonService.capitalizeFirstLetter(serviceType))))),
23
- React.createElement("div", { className: "flex items-center justify-end shrink-0 ml-[5px] w-[150px]" },
23
+ React.createElement("div", { className: "flex items-center justify-end shrink-0 ml-[5px] min-w-[150px]" },
24
+ availableSeats !== undefined && availableSeats > 0 && !isSoldOut && (React.createElement("div", { className: "text-[13.33px] whitespace-nowrap mr-[10px]", style: { color: "#464647" } },
25
+ availableSeats,
26
+ " ",
27
+ availableSeats === 1 ? "asiento restante" : "asientos restantes")),
24
28
  (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_tracking_enabled) && (React.createElement("div", { className: grayscaleClass + " mr-[10px]" },
25
29
  React.createElement(LottiePlayer, { animationData: getAnimationIcon("locationAnim"), width: "20px", height: "20px" }))),
26
30
  serviceItem.is_change_ticket && !isDpEnabled && !isPeru && (React.createElement(FlexibleBlock, { translation: translation, getAnimationIcon: getAnimationIcon, colors: colors, serviceItem: serviceItem, isSoldOut: isSoldOut })),
@@ -91,31 +91,13 @@ const FeatureServiceUiMobile = ({ serviceItem, showTopLabel, colors, isSoldOut,
91
91
  selectedSlotService.original_price) *
92
92
  100)
93
93
  : savingsPercent;
94
- // Convert "HH:MM" (24h) → "H:MM AM/PM"
95
- const formatTimeAmPm = (time) => {
96
- const match = time.match(/(\d{1,2}):(\d{2})/);
97
- if (!match)
98
- return time;
99
- let h = parseInt(match[1], 10);
100
- const m = match[2];
101
- const period = h >= 12 ? "PM" : "AM";
102
- h = h % 12 || 12;
103
- return `${h}:${m} ${period}`;
104
- };
105
- // Convert all HH:MM occurrences in a label string to AM/PM
106
- const formatLabelAmPm = (label) => label.replace(/(\d{1,2}):(\d{2})/g, (_, hh, mm) => {
107
- let h = parseInt(hh, 10);
108
- const period = h >= 12 ? "PM" : "AM";
109
- h = h % 12 || 12;
110
- return `${h}:${mm} ${period}`;
111
- });
112
- // The label shown on the dropdown button
113
- const departureRange = formatLabelAmPm((activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label) || `Entre ${dealWindowFrom} y ${dealWindowTo}`);
114
- const currentWindowFrom = (activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label)
115
- ? activeSlot.label.split(" - ")[0]
94
+ // The label shown on the dropdown button (24h format, e.g. "Entre 16:00 y 20:00")
95
+ const departureRange = (activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label) || `Entre ${dealWindowFrom} y ${dealWindowTo}`;
96
+ const currentWindowFrom = activeSlot
97
+ ? commonService.minutesToTime(activeSlot.start)
116
98
  : dealWindowFrom;
117
- const currentWindowTo = (activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label)
118
- ? activeSlot.label.split(" - ")[1]
99
+ const currentWindowTo = activeSlot
100
+ ? commonService.minutesToTime(activeSlot.end === 1440 ? 1439 : activeSlot.end)
119
101
  : dealWindowTo;
120
102
  const isItemExpanded = serviceItem.id === isFeatureDropDownExpand ||
121
103
  isFeatureDropDownExpand === true;
@@ -105,11 +105,11 @@ const FeatureServiceUi = ({ serviceItem, showTopLabel, getAnimationIcon, cityOri
105
105
  // The label shown on the dropdown button
106
106
  const departureRange = (activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label) || `${dealWindowFrom} y ${dealWindowTo}`;
107
107
  // activeSlot?.label || `Entre ${dealWindowFrom} y ${dealWindowTo}`;
108
- const currentWindowFrom = (activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label)
109
- ? activeSlot.label.split(" - ")[0]
108
+ const currentWindowFrom = activeSlot
109
+ ? commonService.minutesToTime(activeSlot.start)
110
110
  : dealWindowFrom;
111
- const currentWindowTo = (activeSlot === null || activeSlot === void 0 ? void 0 : activeSlot.label)
112
- ? activeSlot.label.split(" - ")[1]
111
+ const currentWindowTo = activeSlot
112
+ ? commonService.minutesToTime(activeSlot.end === 1440 ? 1439 : activeSlot.end)
113
113
  : dealWindowTo;
114
114
  if (expandedStateMap[serviceItem.id] === undefined) {
115
115
  expandedStateMap[serviceItem.id] = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "10.4.73",
3
+ "version": "10.4.75",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -197,7 +197,6 @@ class DiscountBannersDesktop extends React.Component<
197
197
  className = "",
198
198
  style,
199
199
  } = this.props;
200
- console.log("🚀 ~ DiscountBannersDesktop ~ render ~ services:", services)
201
200
 
202
201
  // Compute cards directly — no useMemo
203
202
  const cards = deriveDiscountCards(services, wowDealData, currencySign);
@@ -979,6 +979,9 @@ function PeruServiceItemDesktop({
979
979
  setIsExpand && setIsExpand(isItemExpanded ? null : serviceItem.id)
980
980
  }
981
981
  isPeru={isPeru}
982
+ availableSeats={
983
+ showAvailableSeats ? serviceItem?.available_seats : undefined
984
+ }
982
985
  />
983
986
  </div>
984
987
  </div>
@@ -791,6 +791,9 @@ function ServiceItemPB({
791
791
  showServiceTypeUnderLogo ? undefined : serviceItem.service_type
792
792
  }
793
793
  renderIcon={renderIcon}
794
+ availableSeats={
795
+ showAvailableSeats ? serviceItem?.available_seats : undefined
796
+ }
794
797
  />
795
798
  </div>
796
799
  </div>
@@ -33,6 +33,7 @@ interface BottomAmenitiesProps {
33
33
  isDpEnabled?: boolean;
34
34
  serviceType?: string;
35
35
  renderIcon?: (iconKey: string, size?: string) => React.ReactNode;
36
+ availableSeats?: number;
36
37
  }
37
38
 
38
39
  function BottomAmenities({
@@ -51,6 +52,7 @@ function BottomAmenities({
51
52
  isDpEnabled,
52
53
  serviceType,
53
54
  renderIcon,
55
+ availableSeats,
54
56
  }: BottomAmenitiesProps): React.ReactElement {
55
57
  const hasPetInfo =
56
58
  serviceItem.pet_seat_info &&
@@ -93,7 +95,16 @@ function BottomAmenities({
93
95
  </div>
94
96
 
95
97
  {/* PET + FLEXIBLE (always visible) */}
96
- <div className="flex items-center justify-end shrink-0 ml-[5px] w-[150px]">
98
+ <div className="flex items-center justify-end shrink-0 ml-[5px] min-w-[150px]">
99
+ {availableSeats !== undefined && availableSeats > 0 && !isSoldOut && (
100
+ <div
101
+ className="text-[13.33px] whitespace-nowrap mr-[10px]"
102
+ style={{ color:"#464647" }}
103
+ >
104
+ {availableSeats}{" "}
105
+ {availableSeats === 1 ? "asiento restante" : "asientos restantes"}
106
+ </div>
107
+ )}
97
108
  {serviceItem?.is_tracking_enabled && (
98
109
  <div className={grayscaleClass + " mr-[10px]"}>
99
110
  <LottiePlayer
@@ -131,36 +131,17 @@ const FeatureServiceUiMobile = ({
131
131
  )
132
132
  : savingsPercent;
133
133
 
134
- // Convert "HH:MM" (24h) → "H:MM AM/PM"
135
- const formatTimeAmPm = (time: string): string => {
136
- const match = time.match(/(\d{1,2}):(\d{2})/);
137
- if (!match) return time;
138
- let h = parseInt(match[1], 10);
139
- const m = match[2];
140
- const period = h >= 12 ? "PM" : "AM";
141
- h = h % 12 || 12;
142
- return `${h}:${m} ${period}`;
143
- };
144
-
145
- // Convert all HH:MM occurrences in a label string to AM/PM
146
- const formatLabelAmPm = (label: string): string =>
147
- label.replace(/(\d{1,2}):(\d{2})/g, (_, hh, mm) => {
148
- let h = parseInt(hh, 10);
149
- const period = h >= 12 ? "PM" : "AM";
150
- h = h % 12 || 12;
151
- return `${h}:${mm} ${period}`;
152
- });
134
+ // The label shown on the dropdown button (24h format, e.g. "Entre 16:00 y 20:00")
135
+ const departureRange =
136
+ activeSlot?.label || `Entre ${dealWindowFrom} y ${dealWindowTo}`;
153
137
 
154
- // The label shown on the dropdown button
155
- const departureRange = formatLabelAmPm(
156
- activeSlot?.label || `Entre ${dealWindowFrom} y ${dealWindowTo}`,
157
- );
158
-
159
- const currentWindowFrom = activeSlot?.label
160
- ? activeSlot.label.split(" - ")[0]
138
+ const currentWindowFrom = activeSlot
139
+ ? commonService.minutesToTime(activeSlot.start)
161
140
  : dealWindowFrom;
162
- const currentWindowTo = activeSlot?.label
163
- ? activeSlot.label.split(" - ")[1]
141
+ const currentWindowTo = activeSlot
142
+ ? commonService.minutesToTime(
143
+ activeSlot.end === 1440 ? 1439 : activeSlot.end,
144
+ )
164
145
  : dealWindowTo;
165
146
 
166
147
  const isItemExpanded =
@@ -147,11 +147,13 @@ const FeatureServiceUi = ({
147
147
  activeSlot?.label || `${dealWindowFrom} y ${dealWindowTo}`;
148
148
  // activeSlot?.label || `Entre ${dealWindowFrom} y ${dealWindowTo}`;
149
149
 
150
- const currentWindowFrom = activeSlot?.label
151
- ? activeSlot.label.split(" - ")[0]
150
+ const currentWindowFrom = activeSlot
151
+ ? commonService.minutesToTime(activeSlot.start)
152
152
  : dealWindowFrom;
153
- const currentWindowTo = activeSlot?.label
154
- ? activeSlot.label.split(" - ")[1]
153
+ const currentWindowTo = activeSlot
154
+ ? commonService.minutesToTime(
155
+ activeSlot.end === 1440 ? 1439 : activeSlot.end,
156
+ )
155
157
  : dealWindowTo;
156
158
 
157
159
  if (expandedStateMap[serviceItem.id] === undefined) {