kupos-ui-components-lib 10.3.6 → 10.3.8

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.
@@ -1,9 +1,13 @@
1
1
  import React from "react";
2
2
  import CommonService from "../../utils/CommonService";
3
3
  const SEAT_EXCEPTIONS = ["Asiento mascota"];
4
- function getAllSeatTypes(seatTypes) {
4
+ function getAllSeatTypes(seatTypes, isTrain) {
5
5
  if (!(seatTypes === null || seatTypes === void 0 ? void 0 : seatTypes.length)) {
6
- return [{ label: "Salon cama", price: 0 }];
6
+ return [
7
+ isTrain
8
+ ? { label: "Salon cama", price: 0, apiSeatType: "Standard" }
9
+ : { label: "Salon cama", price: 0 },
10
+ ];
7
11
  }
8
12
  let seatTypesWithPrices = seatTypes.filter(Boolean).map((val) => ({
9
13
  label: val === null || val === void 0 ? void 0 : val.label,
@@ -16,9 +20,13 @@ function getAllSeatTypes(seatTypes) {
16
20
  }
17
21
  function getSortedSeatTypes(seatTypes, isTrain) {
18
22
  if (!(seatTypes === null || seatTypes === void 0 ? void 0 : seatTypes.length)) {
19
- return [{ label: "Salon cama", price: 0 }];
23
+ return [
24
+ isTrain
25
+ ? { label: "Salon cama", price: 0, apiSeatType: "Standard" }
26
+ : { label: "Salon cama", price: 0 },
27
+ ];
20
28
  }
21
- let seatTypesWithPrices = getAllSeatTypes(seatTypes);
29
+ let seatTypesWithPrices = getAllSeatTypes(seatTypes, isTrain);
22
30
  const premiumIndex = seatTypesWithPrices.findIndex((item) => item.label === "Premium");
23
31
  if (premiumIndex >= 3) {
24
32
  seatTypesWithPrices[2] = seatTypesWithPrices[premiumIndex];
@@ -38,8 +46,8 @@ function getSortedSeatTypes(seatTypes, isTrain) {
38
46
  });
39
47
  return seatTypesWithPrices;
40
48
  }
41
- function getUniqueSeats(seatTypes) {
42
- const allSeatTypes = getAllSeatTypes(seatTypes);
49
+ function getUniqueSeats(seatTypes, isTrain) {
50
+ const allSeatTypes = getAllSeatTypes(seatTypes, isTrain);
43
51
  const seatMap = new Map();
44
52
  allSeatTypes.forEach((seat) => {
45
53
  if (SEAT_EXCEPTIONS.includes(seat.label))
@@ -74,7 +82,8 @@ function getSeatTypeIcon(label, serviceItem) {
74
82
  }
75
83
  function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, selectedSeatKey, onSeatSelect, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, isSeatIcon, isTrain, topLabelColor, tooltipColor, }) {
76
84
  var _a;
77
- const uniqueSeats = getUniqueSeats(seatTypes);
85
+ console.log("🚀 ~ SeatSection ~ serviceItem:", serviceItem);
86
+ const uniqueSeats = getUniqueSeats(seatTypes, isTrain);
78
87
  const sortedSeatTypes = getSortedSeatTypes(seatTypes, isTrain);
79
88
  const numberOfSeats = getNumberOfSeats(seatTypes);
80
89
  const isCentered = numberOfSeats < 2 || removeDuplicateSeats;
@@ -134,7 +143,7 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
134
143
  });
135
144
  }
136
145
  // Single seat type → original behaviour (one lowest-fare price)
137
- const allSeats = getAllSeatTypes(seatTypes);
146
+ const allSeats = getAllSeatTypes(seatTypes, isTrain);
138
147
  const lowestFare = allSeats.length > 0 ? allSeats[0].price : 0;
139
148
  const { discountedPrice } = CommonService.calculateDiscountedPrice(lowestFare, serviceItem);
140
149
  return (React.createElement(React.Fragment, null,
@@ -353,7 +362,7 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
353
362
  ? CommonService.currency(0, currencySign)
354
363
  : CommonService.discountedCurrency(discountSeat.discountedPrice, currencySign)))));
355
364
  }
356
- return (React.createElement("div", { className: "relative flex gap-[10px] text-[13.33px] justify-between min-h-[2.2rem]", style: isCentered ? { alignItems: "center" } : {} },
365
+ return isTrain && availableSeats <= 0 ? null : (React.createElement("div", { className: "relative flex gap-[10px] text-[13.33px] justify-between min-h-[2.2rem]", style: isCentered ? { alignItems: "center" } : {} },
357
366
  React.createElement("div", { className: "flex flex-col justify-between", style: { gap: "10px" } }, renderLabels()),
358
367
  React.createElement("div", { className: "flex flex-col justify-between absolute inset-y-0 right-0 left-1/2 h-full", style: {
359
368
  color: isSoldOut ? "#c0c0c0" : priceColor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "10.3.6",
3
+ "version": "10.3.8",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -36,9 +36,13 @@ interface SeatSectionProps {
36
36
  tooltipColor?: string;
37
37
  }
38
38
 
39
- function getAllSeatTypes(seatTypes: SeatType[]) {
39
+ function getAllSeatTypes(seatTypes: SeatType[], isTrain?: boolean) {
40
40
  if (!seatTypes?.length) {
41
- return [{ label: "Salon cama", price: 0 }];
41
+ return [
42
+ isTrain
43
+ ? { label: "Salon cama", price: 0, apiSeatType: "Standard" }
44
+ : { label: "Salon cama", price: 0 },
45
+ ];
42
46
  }
43
47
 
44
48
  let seatTypesWithPrices = seatTypes.filter(Boolean).map((val) => ({
@@ -55,10 +59,14 @@ function getAllSeatTypes(seatTypes: SeatType[]) {
55
59
 
56
60
  function getSortedSeatTypes(seatTypes: SeatType[], isTrain: any) {
57
61
  if (!seatTypes?.length) {
58
- return [{ label: "Salon cama", price: 0 }];
62
+ return [
63
+ isTrain
64
+ ? { label: "Salon cama", price: 0, apiSeatType: "Standard" }
65
+ : { label: "Salon cama", price: 0 },
66
+ ];
59
67
  }
60
68
 
61
- let seatTypesWithPrices = getAllSeatTypes(seatTypes);
69
+ let seatTypesWithPrices = getAllSeatTypes(seatTypes, isTrain);
62
70
 
63
71
  const premiumIndex = seatTypesWithPrices.findIndex(
64
72
  (item) => item.label === "Premium",
@@ -86,8 +94,8 @@ function getSortedSeatTypes(seatTypes: SeatType[], isTrain: any) {
86
94
  return seatTypesWithPrices;
87
95
  }
88
96
 
89
- function getUniqueSeats(seatTypes: SeatType[]) {
90
- const allSeatTypes = getAllSeatTypes(seatTypes);
97
+ function getUniqueSeats(seatTypes: SeatType[], isTrain?: boolean) {
98
+ const allSeatTypes = getAllSeatTypes(seatTypes, isTrain);
91
99
  const seatMap = new Map();
92
100
 
93
101
  allSeatTypes.forEach((seat) => {
@@ -139,7 +147,8 @@ function SeatSection({
139
147
  topLabelColor,
140
148
  tooltipColor,
141
149
  }: SeatSectionProps): React.ReactElement {
142
- const uniqueSeats = getUniqueSeats(seatTypes);
150
+ console.log("🚀 ~ SeatSection ~ serviceItem:", serviceItem);
151
+ const uniqueSeats = getUniqueSeats(seatTypes, isTrain);
143
152
  const sortedSeatTypes = getSortedSeatTypes(seatTypes, isTrain);
144
153
  const numberOfSeats = getNumberOfSeats(seatTypes);
145
154
  const isCentered = numberOfSeats < 2 || removeDuplicateSeats;
@@ -254,7 +263,7 @@ function SeatSection({
254
263
  }
255
264
 
256
265
  // Single seat type → original behaviour (one lowest-fare price)
257
- const allSeats = getAllSeatTypes(seatTypes);
266
+ const allSeats = getAllSeatTypes(seatTypes, isTrain);
258
267
  const lowestFare = allSeats.length > 0 ? allSeats[0].price : 0;
259
268
  const { discountedPrice } = CommonService.calculateDiscountedPrice(
260
269
  lowestFare,
@@ -707,7 +716,7 @@ function SeatSection({
707
716
  );
708
717
  }
709
718
 
710
- return (
719
+ return isTrain && availableSeats <= 0 ? null : (
711
720
  <div
712
721
  className="relative flex gap-[10px] text-[13.33px] justify-between min-h-[2.2rem]"
713
722
  style={isCentered ? { alignItems: "center" } : {}}