kupos-ui-components-lib 10.3.6 → 10.3.7
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 [
|
|
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 [
|
|
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,7 @@ 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
|
+
const uniqueSeats = getUniqueSeats(seatTypes, isTrain);
|
|
78
86
|
const sortedSeatTypes = getSortedSeatTypes(seatTypes, isTrain);
|
|
79
87
|
const numberOfSeats = getNumberOfSeats(seatTypes);
|
|
80
88
|
const isCentered = numberOfSeats < 2 || removeDuplicateSeats;
|
|
@@ -134,7 +142,7 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
|
|
|
134
142
|
});
|
|
135
143
|
}
|
|
136
144
|
// Single seat type → original behaviour (one lowest-fare price)
|
|
137
|
-
const allSeats = getAllSeatTypes(seatTypes);
|
|
145
|
+
const allSeats = getAllSeatTypes(seatTypes, isTrain);
|
|
138
146
|
const lowestFare = allSeats.length > 0 ? allSeats[0].price : 0;
|
|
139
147
|
const { discountedPrice } = CommonService.calculateDiscountedPrice(lowestFare, serviceItem);
|
|
140
148
|
return (React.createElement(React.Fragment, null,
|
package/package.json
CHANGED
|
@@ -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 [
|
|
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 [
|
|
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,7 @@ function SeatSection({
|
|
|
139
147
|
topLabelColor,
|
|
140
148
|
tooltipColor,
|
|
141
149
|
}: SeatSectionProps): React.ReactElement {
|
|
142
|
-
const uniqueSeats = getUniqueSeats(seatTypes);
|
|
150
|
+
const uniqueSeats = getUniqueSeats(seatTypes, isTrain);
|
|
143
151
|
const sortedSeatTypes = getSortedSeatTypes(seatTypes, isTrain);
|
|
144
152
|
const numberOfSeats = getNumberOfSeats(seatTypes);
|
|
145
153
|
const isCentered = numberOfSeats < 2 || removeDuplicateSeats;
|
|
@@ -254,7 +262,7 @@ function SeatSection({
|
|
|
254
262
|
}
|
|
255
263
|
|
|
256
264
|
// Single seat type → original behaviour (one lowest-fare price)
|
|
257
|
-
const allSeats = getAllSeatTypes(seatTypes);
|
|
265
|
+
const allSeats = getAllSeatTypes(seatTypes, isTrain);
|
|
258
266
|
const lowestFare = allSeats.length > 0 ? allSeats[0].price : 0;
|
|
259
267
|
const { discountedPrice } = CommonService.calculateDiscountedPrice(
|
|
260
268
|
lowestFare,
|