kupos-ui-components-lib 9.9.2 → 9.9.4
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/KuposUIComponent.d.ts +0 -3
- package/dist/components/ServiceItem/PeruServiceItemDesktop.d.ts +1 -1
- package/dist/components/ServiceItem/PeruServiceItemDesktop.js +2 -2
- package/dist/components/ServiceItem/ServiceItemDesktop.d.ts +1 -1
- package/dist/components/ServiceItem/ServiceItemDesktop.js +31 -30
- package/dist/components/ServiceItem/ServiceItemMobile.d.ts +1 -1
- package/dist/components/ServiceItem/ServiceItemMobile.js +17 -43
- package/dist/components/ServiceItem/mobileTypes.d.ts +2 -48
- package/dist/components/ServiceItem/types.d.ts +9 -27
- package/dist/styles.css +6 -215
- package/dist/ui/ExpendedDropDown/ExpandedDropdown.d.ts +2 -1
- package/dist/ui/ExpendedDropDown/ExpandedDropdown.js +5 -3
- package/dist/ui/OfferBanner.d.ts +0 -2
- package/dist/ui/OfferBanner.js +14 -19
- package/dist/ui/SeatSection/SeatSection.d.ts +7 -1
- package/dist/ui/SeatSection/SeatSection.js +41 -12
- package/dist/ui/mobileweb/DateTimeSectionMobile.d.ts +2 -1
- package/dist/ui/mobileweb/DateTimeSectionMobile.js +7 -5
- package/dist/ui/mobileweb/ExpandedDropdownMobile.js +1 -1
- package/dist/ui/mobileweb/SeatSectionMobile.d.ts +2 -1
- package/dist/ui/mobileweb/SeatSectionMobile.js +15 -10
- package/dist/utils/CommonService.d.ts +1 -4
- package/dist/utils/CommonService.js +6 -19
- package/package.json +1 -1
- package/src/KuposUIComponent.tsx +0 -3
- package/src/components/ServiceItem/PeruServiceItemDesktop.tsx +24 -35
- package/src/components/ServiceItem/ServiceItemDesktop.tsx +53 -65
- package/src/components/ServiceItem/ServiceItemMobile.tsx +290 -387
- package/src/components/ServiceItem/mobileTypes.ts +8 -50
- package/src/components/ServiceItem/types.ts +25 -39
- package/src/styles.css +0 -15
- package/src/ui/ExpendedDropDown/ExpandedDropdown.tsx +5 -3
- package/src/ui/OfferBanner.tsx +10 -31
- package/src/ui/SeatSection/SeatSection.tsx +86 -21
- package/src/ui/mobileweb/DateTimeSectionMobile.tsx +38 -33
- package/src/ui/mobileweb/ExpandedDropdownMobile.tsx +1 -1
- package/src/ui/mobileweb/SeatSectionMobile.tsx +12 -7
- package/src/utils/CommonService.ts +8 -27
- package/src/assets/images/anims/service_list/flame_anim.json +0 -1
- package/src/assets/images/anims/service_list/thunder_icon.json +0 -1
- package/src/assets/images/anims/service_list/users_anim.json +0 -1
- package/src/ui/FeaturServiceUiMobile/FeatureServiceUiMobile.tsx +0 -575
- package/src/ui/FeatureServiceUI/FeatureServiceUi.tsx +0 -610
|
@@ -8,11 +8,13 @@ function getAllSeatTypes(seatTypes) {
|
|
|
8
8
|
let seatTypesWithPrices = seatTypes.filter(Boolean).map((val) => ({
|
|
9
9
|
label: val === null || val === void 0 ? void 0 : val.label,
|
|
10
10
|
price: val === null || val === void 0 ? void 0 : val.fare,
|
|
11
|
+
key: val === null || val === void 0 ? void 0 : val.key,
|
|
12
|
+
apiSeatType: (val === null || val === void 0 ? void 0 : val.apiSeatType) || (val === null || val === void 0 ? void 0 : val.api_seat_type),
|
|
11
13
|
}));
|
|
12
14
|
seatTypesWithPrices.sort((a, b) => a.price - b.price);
|
|
13
15
|
return seatTypesWithPrices;
|
|
14
16
|
}
|
|
15
|
-
function getSortedSeatTypes(seatTypes) {
|
|
17
|
+
function getSortedSeatTypes(seatTypes, isTrain) {
|
|
16
18
|
if (!(seatTypes === null || seatTypes === void 0 ? void 0 : seatTypes.length)) {
|
|
17
19
|
return [{ label: "Salon cama", price: 0 }];
|
|
18
20
|
}
|
|
@@ -21,7 +23,9 @@ function getSortedSeatTypes(seatTypes) {
|
|
|
21
23
|
if (premiumIndex >= 3) {
|
|
22
24
|
seatTypesWithPrices[2] = seatTypesWithPrices[premiumIndex];
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
if (!isTrain) {
|
|
27
|
+
seatTypesWithPrices = seatTypesWithPrices.slice(0, 2);
|
|
28
|
+
}
|
|
25
29
|
const seenPrices = new Set();
|
|
26
30
|
seatTypesWithPrices = seatTypesWithPrices.filter((seat) => {
|
|
27
31
|
if (seenPrices.has(seat.price))
|
|
@@ -54,10 +58,10 @@ function getUniqueSeats(seatTypes) {
|
|
|
54
58
|
function getNumberOfSeats(seatTypes) {
|
|
55
59
|
return seatTypes.filter((val) => !SEAT_EXCEPTIONS.includes(val.label)).length;
|
|
56
60
|
}
|
|
57
|
-
function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, }) {
|
|
61
|
+
function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, selectedSeatKey, onSeatSelect, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, isTrain, topLabelColor, }) {
|
|
58
62
|
var _a;
|
|
59
63
|
const uniqueSeats = getUniqueSeats(seatTypes);
|
|
60
|
-
const sortedSeatTypes = getSortedSeatTypes(seatTypes);
|
|
64
|
+
const sortedSeatTypes = getSortedSeatTypes(seatTypes, isTrain);
|
|
61
65
|
const numberOfSeats = getNumberOfSeats(seatTypes);
|
|
62
66
|
const isCentered = numberOfSeats < 2 || removeDuplicateSeats;
|
|
63
67
|
const formatPrice = (price) => availableSeats <= 0
|
|
@@ -65,11 +69,36 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
|
|
|
65
69
|
: CommonService.currency(price, currencySign);
|
|
66
70
|
const renderSeatNames = () => {
|
|
67
71
|
const seats = removeDuplicateSeats ? uniqueSeats : sortedSeatTypes;
|
|
68
|
-
return seats.map((val, key) =>
|
|
69
|
-
?
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
return seats.map((val, key) => {
|
|
73
|
+
return SEAT_EXCEPTIONS.includes(val.label) ? null : (React.createElement("div", { className: "flex items-center", style: isTrain ? { cursor: "pointer" } : undefined, onClick: isTrain && !isSoldOut
|
|
74
|
+
? () => val.label === selectedSeatKey
|
|
75
|
+
? onSeatSelect === null || onSeatSelect === void 0 ? void 0 : onSeatSelect(null, 0, "", "")
|
|
76
|
+
: onSeatSelect === null || onSeatSelect === void 0 ? void 0 : onSeatSelect(val.label, val.price, val.key, val.apiSeatType)
|
|
77
|
+
: undefined },
|
|
78
|
+
isTrain && (React.createElement("div", { style: {
|
|
79
|
+
border: `1px solid ${val.label === selectedSeatKey ? topLabelColor : "#ccc"}`,
|
|
80
|
+
borderRadius: "50%",
|
|
81
|
+
width: "14px",
|
|
82
|
+
height: "14px",
|
|
83
|
+
minWidth: "14px",
|
|
84
|
+
marginRight: "10px",
|
|
85
|
+
display: "flex",
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
justifyContent: "center",
|
|
88
|
+
} }, val.label === selectedSeatKey && (React.createElement("div", { style: {
|
|
89
|
+
backgroundColor: topLabelColor,
|
|
90
|
+
borderRadius: "50%",
|
|
91
|
+
width: "7px",
|
|
92
|
+
height: "7px",
|
|
93
|
+
} })))),
|
|
94
|
+
React.createElement("span", { key: key, className: `flex items-center justify-between text-[13.33px] ${isSoldOut ? "text-[#c0c0c0]" : ""}` }, typeof val.label === "string" || typeof val.label === "number"
|
|
95
|
+
? removeDuplicateSeats && isPeru
|
|
96
|
+
? CommonService.truncateSeatLabel(val.label)
|
|
97
|
+
: isTrain
|
|
98
|
+
? CommonService.truncateSeatLabel(val.label, 8)
|
|
99
|
+
: val.label
|
|
100
|
+
: null)));
|
|
101
|
+
});
|
|
73
102
|
};
|
|
74
103
|
const renderSeatPrices = () => {
|
|
75
104
|
if (isPeru) {
|
|
@@ -147,7 +176,7 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
|
|
|
147
176
|
React.createElement("div", { className: "col-start-1 row-start-3 flex h-[20px] items-end" },
|
|
148
177
|
React.createElement("span", { className: "text-[13.33px] font-normal leading-[20px] text-[#464647]" }, "Desde")),
|
|
149
178
|
React.createElement("div", { className: "col-start-2 row-start-1 flex items-center justify-center absolute", style: { top: "-22px", left: "50%", transform: "translateX(-50%)" } }, !isNaN(Number(dpDiscountPercent)) &&
|
|
150
|
-
Number(dpDiscountPercent) > 0 && (React.createElement("span", { className:
|
|
179
|
+
Number(dpDiscountPercent) > 0 && (React.createElement("span", { className: "rounded-[100px] bg-[#ff5964] px-[6px] text-[12px] bold-text leading-[20px] text-white", style: {
|
|
151
180
|
animation: "pulse-zoom 2s ease-in-out infinite",
|
|
152
181
|
whiteSpace: "nowrap",
|
|
153
182
|
} },
|
|
@@ -168,7 +197,7 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
|
|
|
168
197
|
} }))),
|
|
169
198
|
React.createElement("div", { className: "col-start-2 row-start-3 flex h-[30px] items-end justify-center relative" },
|
|
170
199
|
React.createElement("span", { className: "flex items-center gap-[6px] text-[22px] bold-text leading-[30px]", style: { color: isSoldOut ? "#c0c0c0" : "#ff5964" } },
|
|
171
|
-
React.createElement("div", { className: "absolute", style: { left: isPeru ? "-
|
|
200
|
+
React.createElement("div", { className: "absolute", style: { left: isPeru ? "-19px" : "-19px", bottom: "1px" } }, renderIcon("fireIcon", "16px")),
|
|
172
201
|
availableSeats <= 0
|
|
173
202
|
? CommonService.currency(0, currencySign)
|
|
174
203
|
: CommonService.discountedCurrency(Number(seatTypeFare), currencySign)))));
|
|
@@ -239,7 +268,7 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
|
|
|
239
268
|
React.createElement("div", { className: "col-start-2 row-start-3 flex h-[30px] items-end justify-center relative" },
|
|
240
269
|
React.createElement("span", { className: "flex items-center gap-[6px] text-[22px] bold-text leading-[30px]", style: { color: isSoldOut ? "#c0c0c0" : discountSeatPriceColor } },
|
|
241
270
|
React.createElement("div", { className: "absolute", style: {
|
|
242
|
-
left: isPeru ? "-
|
|
271
|
+
left: isPeru ? "-18px" : "-18px",
|
|
243
272
|
bottom: "1px",
|
|
244
273
|
} }, renderIcon("fireIcon", "16px")),
|
|
245
274
|
availableSeats <= 0
|
|
@@ -22,6 +22,7 @@ interface DateTimeSectionMobileProps {
|
|
|
22
22
|
tooltipBgColor?: string;
|
|
23
23
|
showLastSeats?: boolean;
|
|
24
24
|
discountSeatPriceColor?: string;
|
|
25
|
+
isTrain?: boolean;
|
|
25
26
|
}
|
|
26
|
-
declare function DateTimeSectionMobile({ onBookButtonPress, isCiva, isSoldOut, isLinatal, isPeru, orignLabel, destinationLabel, originIcon, destinationIcon, travelDate, arrivalDate, depTime, arrTime, seatTypes, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, }: DateTimeSectionMobileProps): React.ReactElement;
|
|
27
|
+
declare function DateTimeSectionMobile({ onBookButtonPress, isCiva, isSoldOut, isLinatal, isPeru, orignLabel, destinationLabel, originIcon, destinationIcon, travelDate, arrivalDate, depTime, arrTime, seatTypes, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, isTrain, }: DateTimeSectionMobileProps): React.ReactElement;
|
|
27
28
|
export default DateTimeSectionMobile;
|
|
@@ -23,8 +23,10 @@ const getCleanedDepTime = (raw) => {
|
|
|
23
23
|
};
|
|
24
24
|
const TimeRow = ({ label, icon, alt, date, timeContent, isSoldOut, }) => {
|
|
25
25
|
const formattedDate = DateService.getServiceItemDate(date);
|
|
26
|
-
const dotPositionClass = formattedDate.includes("dom")
|
|
27
|
-
|
|
26
|
+
const dotPositionClass = formattedDate.includes("dom")
|
|
27
|
+
? "max-[399px]:left-[53%]"
|
|
28
|
+
: "";
|
|
29
|
+
return (React.createElement("div", { className: `flex items-center min-[420]:text-[13px] text-[12px] justify-between ${isSoldOut ? "text-[#c0c0c0]" : ""}` },
|
|
28
30
|
React.createElement("div", { className: "flex items-center", style: { flex: 1 } },
|
|
29
31
|
React.createElement("div", null,
|
|
30
32
|
" ",
|
|
@@ -33,9 +35,9 @@ const TimeRow = ({ label, icon, alt, date, timeContent, isSoldOut, }) => {
|
|
|
33
35
|
React.createElement("div", { className: "flex items-center relative capitalize justify-between", style: { flex: 1 } },
|
|
34
36
|
React.createElement("span", { className: "cursor-pointer black-text" }, formattedDate),
|
|
35
37
|
React.createElement("div", { className: `absolute left-[50%] ${dotPositionClass}` }, "\u2022"),
|
|
36
|
-
React.createElement("div", { className: "font-[900] relative black-text" }, timeContent))));
|
|
38
|
+
React.createElement("div", { className: "font-[900] relative black-text" }, timeContent)))));
|
|
37
39
|
};
|
|
38
|
-
function DateTimeSectionMobile({ onBookButtonPress, isCiva, isSoldOut, isLinatal, isPeru, orignLabel, destinationLabel, originIcon, destinationIcon, travelDate, arrivalDate, depTime, arrTime, seatTypes, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, }) {
|
|
40
|
+
function DateTimeSectionMobile({ onBookButtonPress, isCiva, isSoldOut, isLinatal, isPeru, orignLabel, destinationLabel, originIcon, destinationIcon, travelDate, arrivalDate, depTime, arrTime, seatTypes, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, isTrain, }) {
|
|
39
41
|
const { cleaned: cleanedDepTime, hasAM, hasPM } = getCleanedDepTime(depTime);
|
|
40
42
|
const depTimeContent = isLinatal ? (React.createElement("div", null,
|
|
41
43
|
React.createElement("span", null,
|
|
@@ -56,6 +58,6 @@ function DateTimeSectionMobile({ onBookButtonPress, isCiva, isSoldOut, isLinatal
|
|
|
56
58
|
backgroundColor: "#ccc",
|
|
57
59
|
margin: "auto",
|
|
58
60
|
} }),
|
|
59
|
-
React.createElement(SeatSectionMobile, { seatTypes: seatTypes, isSoldOut: isSoldOut, isPeru: isPeru, seatPriceColor: seatPriceColor, currencySign: currencySign, availableSeats: availableSeats, removeDuplicateSeats: removeDuplicateSeats, serviceItem: serviceItem, tooltipBgColor: tooltipBgColor, showLastSeats: showLastSeats, discountSeatPriceColor: discountSeatPriceColor })));
|
|
61
|
+
React.createElement(SeatSectionMobile, { seatTypes: seatTypes, isSoldOut: isSoldOut, isPeru: isPeru, seatPriceColor: seatPriceColor, currencySign: currencySign, availableSeats: availableSeats, removeDuplicateSeats: removeDuplicateSeats, serviceItem: serviceItem, tooltipBgColor: tooltipBgColor, showLastSeats: showLastSeats, discountSeatPriceColor: discountSeatPriceColor, isTrain: isTrain })));
|
|
60
62
|
}
|
|
61
63
|
export default DateTimeSectionMobile;
|
|
@@ -10,7 +10,7 @@ function ExpandedDropdownMobile({ serviceItem, isPeru, petSeatInfo, petFriendlyA
|
|
|
10
10
|
React.createElement("span", { className: "mt-[3px]" }, renderIcon("changeTicketIcon", "14px")),
|
|
11
11
|
React.createElement("span", null,
|
|
12
12
|
React.createElement("span", { className: "bold-text" }, "Pasaje flexible:"),
|
|
13
|
-
" Tu pasaje puede ser cambiado
|
|
13
|
+
" Tu pasaje puede ser cambiado sin costo",
|
|
14
14
|
" ",
|
|
15
15
|
React.createElement("span", { className: "bold-text" },
|
|
16
16
|
"hasta ",
|
|
@@ -16,6 +16,7 @@ interface SeatSectionMobileProps {
|
|
|
16
16
|
tooltipBgColor?: string;
|
|
17
17
|
showLastSeats?: boolean;
|
|
18
18
|
discountSeatPriceColor?: string;
|
|
19
|
+
isTrain?: boolean;
|
|
19
20
|
}
|
|
20
|
-
declare function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, }: SeatSectionMobileProps): React.ReactElement;
|
|
21
|
+
declare function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, isTrain, }: SeatSectionMobileProps): React.ReactElement;
|
|
21
22
|
export default SeatSectionMobile;
|
|
@@ -42,8 +42,8 @@ const getUniqueSeats = (data, limit) => {
|
|
|
42
42
|
.sort((a, b) => a.fare - b.fare)
|
|
43
43
|
.slice(0, limit);
|
|
44
44
|
};
|
|
45
|
-
function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, }) {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
45
|
+
function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPriceColor, currencySign, availableSeats, removeDuplicateSeats, serviceItem, tooltipBgColor, showLastSeats, discountSeatPriceColor, isTrain, }) {
|
|
46
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
47
|
const hasMultipleTypes = ((_a = seatTypesData === null || seatTypesData === void 0 ? void 0 : seatTypesData.length) !== null && _a !== void 0 ? _a : 0) > 2;
|
|
48
48
|
const getFare = (fare) => {
|
|
49
49
|
if (removeDuplicateSeats && availableSeats <= 0 && !isPeru) {
|
|
@@ -101,7 +101,7 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
|
|
|
101
101
|
React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] text-[#464647]", style: { opacity: isSoldOut ? 0.5 : 1 } }, "Agotado"))) : null));
|
|
102
102
|
};
|
|
103
103
|
const renderSeats = () => {
|
|
104
|
-
var _a, _b
|
|
104
|
+
var _a, _b;
|
|
105
105
|
if (isPeru) {
|
|
106
106
|
return renderPeruSeats();
|
|
107
107
|
}
|
|
@@ -109,11 +109,16 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
|
|
|
109
109
|
const uniqueSeats = getUniqueSeats(seatTypesData, 3);
|
|
110
110
|
return uniqueSeats.map((type, i) => (React.createElement(SeatRow, { key: i, type: type, index: i, displayLabel: commonService.truncateSeatLabel(type.label), fare: getFare(type.fare), isSoldOut: isSoldOut, seatPriceColor: seatPriceColor, hasMultipleTypes: hasMultipleTypes, textSize: "text-[11px]" })));
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
const filteredSeats = (_a = seatTypesData === null || seatTypesData === void 0 ? void 0 : seatTypesData.filter((item) => getFilteredSeats(item.label))) === null || _a === void 0 ? void 0 : _a.sort((a, b) => a.fare - b.fare);
|
|
113
|
+
return (_b = (isTrain ? filteredSeats : filteredSeats === null || filteredSeats === void 0 ? void 0 : filteredSeats.slice(0, 2))) === null || _b === void 0 ? void 0 : _b.map((type, i) => (React.createElement(SeatRow, { key: i, type: type, index: i, displayLabel: type.label, fare: getFare(type.fare), isSoldOut: isSoldOut, seatPriceColor: seatPriceColor, hasMultipleTypes: hasMultipleTypes, textSize: "text-[12px]" })));
|
|
113
114
|
};
|
|
114
115
|
const seats = removeDuplicateSeats
|
|
115
116
|
? getUniqueSeats(seatTypesData, 3)
|
|
116
|
-
: (
|
|
117
|
+
: (() => {
|
|
118
|
+
var _a;
|
|
119
|
+
const filtered = (_a = seatTypesData === null || seatTypesData === void 0 ? void 0 : seatTypesData.filter((item) => getFilteredSeats(item.label))) === null || _a === void 0 ? void 0 : _a.sort((a, b) => a.fare - b.fare);
|
|
120
|
+
return isTrain ? filtered : filtered === null || filtered === void 0 ? void 0 : filtered.slice(0, 2);
|
|
121
|
+
})();
|
|
117
122
|
const discountedSeats = seats === null || seats === void 0 ? void 0 : seats.map((seat) => (Object.assign(Object.assign({}, seat), commonService.calculateDiscountedPrice(seat.fare, serviceItem))));
|
|
118
123
|
const peruLowestFare = isPeru ? getLowestFare() : null;
|
|
119
124
|
const peruDiscountCalc = isPeru && peruLowestFare != null
|
|
@@ -124,7 +129,7 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
|
|
|
124
129
|
peruDiscountCalc.originalPrice !== peruDiscountCalc.discountedPrice
|
|
125
130
|
: discountedSeats === null || discountedSeats === void 0 ? void 0 : discountedSeats.some((s) => s.originalPrice !== s.discountedPrice);
|
|
126
131
|
const discountSeat = isPeru && peruDiscountCalc
|
|
127
|
-
? Object.assign({ label: "", fare: peruLowestFare }, peruDiscountCalc) : (
|
|
132
|
+
? Object.assign({ label: "", fare: peruLowestFare }, peruDiscountCalc) : (_b = discountedSeats === null || discountedSeats === void 0 ? void 0 : discountedSeats.filter((seat) => !EXCEPTIONS.includes(seat.label))) === null || _b === void 0 ? void 0 : _b.sort((a, b) => a.discountedPrice - b.discountedPrice)[0];
|
|
128
133
|
const discountValue = (() => {
|
|
129
134
|
if ((serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.discount_type) === "percentage" &&
|
|
130
135
|
typeof (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.discount_value) === "number") {
|
|
@@ -147,14 +152,14 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
|
|
|
147
152
|
};
|
|
148
153
|
const originalDpPrice = getMinValue(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.original_dp_price);
|
|
149
154
|
const dpDiscountPercent = getMinValue(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dp_discount_percents);
|
|
150
|
-
const firstSeatFare = (
|
|
155
|
+
const firstSeatFare = (_d = (_c = seatTypesData === null || seatTypesData === void 0 ? void 0 : seatTypesData.filter((item) => getFilteredSeats(item.label) && !EXCEPTIONS.includes(item.label))) === null || _c === void 0 ? void 0 : _c.sort((a, b) => a.fare - b.fare)[0]) === null || _d === void 0 ? void 0 : _d.fare;
|
|
151
156
|
const hasDpDiscount = (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dp_discounted_seats) &&
|
|
152
157
|
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dp_discount_percents) &&
|
|
153
158
|
originalDpPrice != null &&
|
|
154
159
|
dpDiscountPercent != null &&
|
|
155
160
|
firstSeatFare != null;
|
|
156
161
|
return (React.createElement("div", { className: "content-center relative", style: { width: "40%" } }, (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_dp_enabled) &&
|
|
157
|
-
!((
|
|
162
|
+
!((_e = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.dp_discounted_seats) === null || _e === void 0 ? void 0 : _e.length) &&
|
|
158
163
|
!dpDiscountPercent ? (React.createElement("div", { className: "flex flex-col justify-between h-[2.5rem]", style: { gap: isSoldOut ? "0px" : "5px" } }, renderDpSeats())) : hasDpDiscount ? (React.createElement("div", { className: "relative grid grid-cols-[auto_auto] justify-between gap-x-[8px] " },
|
|
159
164
|
!isNaN(Number(dpDiscountPercent)) &&
|
|
160
165
|
Number(dpDiscountPercent) > 0 && (React.createElement("div", { className: "absolute -top-[18px] right-[0px]", style: {
|
|
@@ -186,7 +191,7 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
|
|
|
186
191
|
React.createElement("span", { className: "flex items-center justify-end gap-[4px] text-[14px] bold-text leading-[24px]", style: {
|
|
187
192
|
color: isSoldOut ? "#bbb" : discountSeatPriceColor || "#ff5964",
|
|
188
193
|
} },
|
|
189
|
-
((
|
|
194
|
+
((_f = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _f === void 0 ? void 0 : _f.fireIcon) ? (React.createElement("img", { src: serviceItem.icons.fireIcon, alt: "discount", className: "h-[16px] w-[16px] object-contain", style: { filter: isSoldOut ? "grayscale" : "" } })) : null,
|
|
190
195
|
commonService.discountedCurrency(Number(firstSeatFare), currencySign)),
|
|
191
196
|
isSoldOut ? (React.createElement("span", { className: "col-span-2 min-[420]:text-[13px] text-right text-[12px] text-[#ccc]" }, "Agotado")) : null)) : hasDiscount && discountSeat ? (React.createElement("div", null,
|
|
192
197
|
React.createElement("div", { className: "relative grid grid-cols-[auto_auto] justify-between gap-x-[8px] " },
|
|
@@ -220,7 +225,7 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
|
|
|
220
225
|
React.createElement("span", { className: "flex items-center justify-end gap-[4px] text-[14px] bold-text leading-[24px]", style: {
|
|
221
226
|
color: isSoldOut ? "#bbb" : discountSeatPriceColor || "#ff5964",
|
|
222
227
|
} },
|
|
223
|
-
((
|
|
228
|
+
((_g = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _g === void 0 ? void 0 : _g.fireIcon) ? (React.createElement("img", { src: serviceItem.icons.fireIcon, alt: "discount", className: "h-[16px] w-[16px] object-contain", style: { opacity: isSoldOut ? 0.5 : 1 } })) : null,
|
|
224
229
|
commonService.discountedCurrency(discountSeat.discountedPrice, currencySign))))) : (React.createElement("div", { className: "flex flex-col justify-between h-[2.5rem] ", style: {
|
|
225
230
|
gap: isSoldOut ? "0px" : "5px",
|
|
226
231
|
justifyContent: hasMultipleTypes ? "space-between" : "center",
|
|
@@ -3,7 +3,7 @@ declare const commonService: {
|
|
|
3
3
|
discountedCurrency(amount: number, currencySign?: string): string;
|
|
4
4
|
copyObject: (ob: any) => any;
|
|
5
5
|
getServiceTypeLabelForFilters: (service_type: any) => "Tipo de servicio" | "Punto de embarque" | "Tipo de asiento" | "SERVICIOS" | "";
|
|
6
|
-
truncateSeatLabel: (label: string | number) => string;
|
|
6
|
+
truncateSeatLabel: (label: string | number, maxLength?: number) => string;
|
|
7
7
|
getAmenitiesImage: (name: string, serviceItem: any) => string;
|
|
8
8
|
getAmenityName: (rawAmenity: string) => string;
|
|
9
9
|
getSeatNameForFilters: (rawSeat: any) => any;
|
|
@@ -14,9 +14,6 @@ declare const commonService: {
|
|
|
14
14
|
discount_type?: string;
|
|
15
15
|
discount_value?: number;
|
|
16
16
|
max_discount?: number;
|
|
17
|
-
discounts?: Array<{
|
|
18
|
-
new_ui_enabled?: boolean;
|
|
19
|
-
}>;
|
|
20
17
|
}) => {
|
|
21
18
|
originalPrice: number;
|
|
22
19
|
discountedPrice: number;
|
|
@@ -34,11 +34,15 @@ const commonService = {
|
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
truncateSeatLabel: (label) => {
|
|
37
|
+
truncateSeatLabel: (label, maxLength) => {
|
|
38
38
|
if (typeof label !== "string")
|
|
39
39
|
return String(label);
|
|
40
40
|
if (label.includes("("))
|
|
41
41
|
return label;
|
|
42
|
+
// If maxLength provided, hard-truncate regardless of word count
|
|
43
|
+
if (maxLength != null && label.length > maxLength) {
|
|
44
|
+
return label.slice(0, maxLength) + "...";
|
|
45
|
+
}
|
|
42
46
|
const words = label.trim().split(/\s+/);
|
|
43
47
|
const truncateWord = (word) => word.length > 5 ? word.slice(0, 3) + "..." : word;
|
|
44
48
|
if (words.length === 1)
|
|
@@ -275,7 +279,6 @@ const commonService = {
|
|
|
275
279
|
return label.toLowerCase();
|
|
276
280
|
},
|
|
277
281
|
calculateDiscountedPrice: (originalPrice, serviceItem) => {
|
|
278
|
-
var _a;
|
|
279
282
|
const price = typeof originalPrice === "string"
|
|
280
283
|
? parseFloat(originalPrice)
|
|
281
284
|
: originalPrice;
|
|
@@ -283,12 +286,6 @@ const commonService = {
|
|
|
283
286
|
return { originalPrice: price, discountedPrice: price };
|
|
284
287
|
}
|
|
285
288
|
const { discount_type, discount_value, max_discount } = serviceItem;
|
|
286
|
-
// Check if there's a discount with new_ui_enabled = true
|
|
287
|
-
const newUiEnabled = (_a = serviceItem.discounts) === null || _a === void 0 ? void 0 : _a.some((d) => d.new_ui_enabled === true);
|
|
288
|
-
// Only apply discount if new_ui_enabled is true OR if regular discount exists
|
|
289
|
-
if (!newUiEnabled && (!discount_type || discount_value == null)) {
|
|
290
|
-
return { originalPrice: price, discountedPrice: price };
|
|
291
|
-
}
|
|
292
289
|
const fixedDiscount = discount_type === "fixed" && discount_value != null ? discount_value : 0;
|
|
293
290
|
const percentageDiscount = discount_type === "percentage" && discount_value != null
|
|
294
291
|
? (price * discount_value) / 100
|
|
@@ -303,14 +300,10 @@ const commonService = {
|
|
|
303
300
|
startViewerCount: (node, viewersConfig) => {
|
|
304
301
|
if (!node || !viewersConfig)
|
|
305
302
|
return;
|
|
306
|
-
const { min, max, interval = 5000 } = viewersConfig;
|
|
307
|
-
const configKey = `${min}-${max}-${interval}`;
|
|
308
|
-
if (node.dataset.viewerId && node.dataset.viewerConfig === configKey) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
303
|
const prevId = node.dataset.viewerId;
|
|
312
304
|
if (prevId)
|
|
313
305
|
clearInterval(Number(prevId));
|
|
306
|
+
const { min, max, interval = 5000 } = viewersConfig;
|
|
314
307
|
const clamp = (v) => Math.min(max, Math.max(min, v));
|
|
315
308
|
const initialValue = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
316
309
|
node.textContent = String(initialValue);
|
|
@@ -321,7 +314,6 @@ const commonService = {
|
|
|
321
314
|
node.textContent = String(clamp(Math.round(next)));
|
|
322
315
|
}, interval);
|
|
323
316
|
node.dataset.viewerId = String(id);
|
|
324
|
-
node.dataset.viewerConfig = configKey;
|
|
325
317
|
},
|
|
326
318
|
startCountdown: (node, countdownSeconds = 599) => {
|
|
327
319
|
if (!node)
|
|
@@ -351,10 +343,6 @@ const commonService = {
|
|
|
351
343
|
startComprandoCount: (node, min = 4, max = 16) => {
|
|
352
344
|
if (!node)
|
|
353
345
|
return;
|
|
354
|
-
const configKey = `${min}-${max}`;
|
|
355
|
-
if (node.dataset.comprandoId && node.dataset.comprandoConfig === configKey) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
346
|
const prevId = node.dataset.comprandoId;
|
|
359
347
|
if (prevId)
|
|
360
348
|
clearInterval(Number(prevId));
|
|
@@ -371,7 +359,6 @@ const commonService = {
|
|
|
371
359
|
node.textContent = String(next);
|
|
372
360
|
}, 5000); // Update every 5 seconds
|
|
373
361
|
node.dataset.comprandoId = String(id);
|
|
374
|
-
node.dataset.comprandoConfig = configKey;
|
|
375
362
|
},
|
|
376
363
|
};
|
|
377
364
|
export default commonService;
|
package/package.json
CHANGED
package/src/KuposUIComponent.tsx
CHANGED
|
@@ -32,9 +32,6 @@ interface KuposUIComponentProps {
|
|
|
32
32
|
orignLabel?: string;
|
|
33
33
|
destinationLabel?: string;
|
|
34
34
|
t?: (key: string) => string;
|
|
35
|
-
ticketQuantity?: number;
|
|
36
|
-
onIncreaseTicketQuantity?: (serviceItem: any) => void;
|
|
37
|
-
onDecreaseTicketQuantity?: (serviceItem: any) => void;
|
|
38
35
|
|
|
39
36
|
// New ServiceItem props
|
|
40
37
|
id?: string;
|
|
@@ -67,7 +67,7 @@ function PeruServiceItemDesktop({
|
|
|
67
67
|
isPeru,
|
|
68
68
|
siteType,
|
|
69
69
|
isAllinBus,
|
|
70
|
-
|
|
70
|
+
isFlores,
|
|
71
71
|
t = (key: string) => key,
|
|
72
72
|
}: ServiceItemProps & { currencySign?: string }): React.ReactElement {
|
|
73
73
|
const animationMap: Record<string, Record<string, any>> = {
|
|
@@ -149,9 +149,8 @@ function PeruServiceItemDesktop({
|
|
|
149
149
|
style={{
|
|
150
150
|
filter: color === "white" ? "brightness(0) invert(1)" : "",
|
|
151
151
|
}}
|
|
152
|
-
className={`object-contain ${
|
|
153
|
-
|
|
154
|
-
}`}
|
|
152
|
+
className={`object-contain ${moreAnemities ? "w-[16px] h-[16px]" : "w-[16px] h-[16px]"
|
|
153
|
+
}`}
|
|
155
154
|
/>
|
|
156
155
|
);
|
|
157
156
|
};
|
|
@@ -262,9 +261,8 @@ function PeruServiceItemDesktop({
|
|
|
262
261
|
SEAT_EXCEPTIONS.includes(val.label) ? null : (
|
|
263
262
|
<span
|
|
264
263
|
key={key}
|
|
265
|
-
className={`flex items-center justify-between text-[13.33px] ${
|
|
266
|
-
|
|
267
|
-
}`}
|
|
264
|
+
className={`flex items-center justify-between text-[13.33px] ${isSoldOut ? "text-[#c0c0c0]" : ""
|
|
265
|
+
}`}
|
|
268
266
|
>
|
|
269
267
|
<div>
|
|
270
268
|
<img
|
|
@@ -289,9 +287,8 @@ function PeruServiceItemDesktop({
|
|
|
289
287
|
SEAT_EXCEPTIONS.includes(val.label) ? null : (
|
|
290
288
|
<span
|
|
291
289
|
key={key}
|
|
292
|
-
className={`flex items-center justify-between text-[13.33px] ${
|
|
293
|
-
|
|
294
|
-
}`}
|
|
290
|
+
className={`flex items-center justify-between text-[13.33px] ${isSoldOut ? "text-[#c0c0c0]" : ""
|
|
291
|
+
}`}
|
|
295
292
|
>
|
|
296
293
|
<div>
|
|
297
294
|
<img
|
|
@@ -539,15 +536,13 @@ function PeruServiceItemDesktop({
|
|
|
539
536
|
|
|
540
537
|
return (
|
|
541
538
|
<div
|
|
542
|
-
className={`relative ${
|
|
543
|
-
serviceItem
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
serviceItem?.train_type_label === "Tren Express (Nuevo)" ||
|
|
547
|
-
showTopLabel
|
|
539
|
+
className={`relative ${serviceItem.offer_text ? "mb-[55px]" : "mb-[10px]"
|
|
540
|
+
} ${serviceItem?.is_direct_trip ||
|
|
541
|
+
serviceItem?.train_type_label === "Tren Express (Nuevo)" ||
|
|
542
|
+
showTopLabel
|
|
548
543
|
? "mt-[24px]"
|
|
549
544
|
: "mt-[20px]"
|
|
550
|
-
|
|
545
|
+
} `}
|
|
551
546
|
>
|
|
552
547
|
<div
|
|
553
548
|
className={"bg-white rounded-[20px] shadow-service mx-auto relative"}
|
|
@@ -588,9 +583,8 @@ function PeruServiceItemDesktop({
|
|
|
588
583
|
<img
|
|
589
584
|
src={serviceItem.operator_details[0]}
|
|
590
585
|
alt="service logo"
|
|
591
|
-
className={`
|
|
592
|
-
isSoldOut ? "grayscale" : ""
|
|
593
|
-
}`}
|
|
586
|
+
className={`h-auto object-contain ${isFlores ? "w-[80%]" : "w-full"
|
|
587
|
+
} ${isSoldOut ? "grayscale" : ""}`}
|
|
594
588
|
/>
|
|
595
589
|
</div>
|
|
596
590
|
{isCiva ? (
|
|
@@ -602,9 +596,8 @@ function PeruServiceItemDesktop({
|
|
|
602
596
|
|
|
603
597
|
{/* DATE AND TIME - Grid Layout */}
|
|
604
598
|
<div
|
|
605
|
-
className={`min-h-[2.5rem] grid grid-cols-[0.8fr_auto_26%_1fr] gap-x-4 items-center text-[13.33px] ${
|
|
606
|
-
|
|
607
|
-
}`}
|
|
599
|
+
className={`min-h-[2.5rem] grid grid-cols-[0.8fr_auto_26%_1fr] gap-x-4 items-center text-[13.33px] ${isSoldOut ? "text-[#c0c0c0]" : ""
|
|
600
|
+
}`}
|
|
608
601
|
style={{
|
|
609
602
|
gridTemplateRows: "1fr",
|
|
610
603
|
}}
|
|
@@ -621,9 +614,8 @@ function PeruServiceItemDesktop({
|
|
|
621
614
|
<img
|
|
622
615
|
src={serviceItem.icons?.origin}
|
|
623
616
|
alt="origin"
|
|
624
|
-
className={`w-[18px] h-auto mr-[8px] ${
|
|
625
|
-
|
|
626
|
-
}`}
|
|
617
|
+
className={`w-[18px] h-auto mr-[8px] ${isSoldOut ? "grayscale" : ""
|
|
618
|
+
}`}
|
|
627
619
|
/>
|
|
628
620
|
</div>
|
|
629
621
|
)}
|
|
@@ -638,9 +630,8 @@ function PeruServiceItemDesktop({
|
|
|
638
630
|
<div className="h-[20px] flex items-center">
|
|
639
631
|
<img
|
|
640
632
|
src={serviceItem.icons?.destination}
|
|
641
|
-
className={`w-[18px] h-auto mr-[8px] ${
|
|
642
|
-
|
|
643
|
-
}`}
|
|
633
|
+
className={`w-[18px] h-auto mr-[8px] ${isSoldOut ? "grayscale" : ""
|
|
634
|
+
}`}
|
|
644
635
|
style={{ opacity: isSoldOut ? 0.5 : 1 }}
|
|
645
636
|
/>
|
|
646
637
|
</div>
|
|
@@ -745,9 +736,8 @@ function PeruServiceItemDesktop({
|
|
|
745
736
|
{/* SEATS */}
|
|
746
737
|
<div className="content-center">
|
|
747
738
|
<div
|
|
748
|
-
className={`relative flex gap-[10px] text-[13.33px] justify-between min-h-[2.5rem] ${
|
|
749
|
-
|
|
750
|
-
}`}
|
|
739
|
+
className={`relative flex gap-[10px] text-[13.33px] justify-between min-h-[2.5rem] ${getNumberOfSeats() < 3 ? "" : ""
|
|
740
|
+
}`}
|
|
751
741
|
style={
|
|
752
742
|
getNumberOfSeats() < 2
|
|
753
743
|
? { alignItems: "center" }
|
|
@@ -793,9 +783,8 @@ function PeruServiceItemDesktop({
|
|
|
793
783
|
<button
|
|
794
784
|
onClick={() => (!isSoldOut ? checkMidnight() : null)}
|
|
795
785
|
disabled={serviceDetailsLoading}
|
|
796
|
-
className={`w-full ${
|
|
797
|
-
|
|
798
|
-
} text-[13.33px] font-bold text-white rounded-[10px] border-none px-[20px] flex items-center justify-center`}
|
|
786
|
+
className={`w-full ${serviceDetailsLoading || isSoldOut ? "py-[12px]" : "py-[12px]"
|
|
787
|
+
} text-[13.33px] font-bold text-white rounded-[10px] border-none px-[20px] flex items-center justify-center`}
|
|
799
788
|
style={{
|
|
800
789
|
backgroundColor:
|
|
801
790
|
serviceDetailsLoading || isSoldOut
|