kupos-ui-components-lib 4.0.1 → 4.0.3
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/components/ServiceItem/ServiceItemDesktop.js +18 -10
- package/dist/components/ServiceItem/ServiceItemMobile.d.ts +1 -1
- package/dist/components/ServiceItem/ServiceItemMobile.js +20 -2
- package/dist/components/ServiceItem/mobileTypes.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/ServiceItem/ServiceItemDesktop.tsx +20 -11
- package/src/components/ServiceItem/ServiceItemMobile.tsx +40 -1
- package/src/components/ServiceItem/mobileTypes.ts +1 -0
|
@@ -8,6 +8,7 @@ import LottiePlayer from "../../assets/LottiePlayer";
|
|
|
8
8
|
const SEAT_EXCEPTIONS = ["Asiento mascota"];
|
|
9
9
|
function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, children, busStage, serviceDetailsLoading, cityOrigin, cityDestination, translation, orignLabel, destinationLabel, currencySign, isCiva, showRating, showLastSeats, removeArrivalTime, removeDuplicateSeats, originIconStyle, t = (key) => key, }) {
|
|
10
10
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
|
+
console.log("🚀 ~ ServiceItemPB ~ serviceItem:", serviceItem);
|
|
11
12
|
const SvgAmenities = ({ moreAnemities, name, color, }) => {
|
|
12
13
|
const amenityKey = name.toLowerCase().replace(/\s/g, "_");
|
|
13
14
|
const getIconPath = () => {
|
|
@@ -164,7 +165,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
164
165
|
}
|
|
165
166
|
return null;
|
|
166
167
|
};
|
|
167
|
-
const
|
|
168
|
+
const getAllSeatTypes = () => {
|
|
168
169
|
var _a;
|
|
169
170
|
if (!((_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
170
171
|
return [{ label: "Salon cama", price: 0 }];
|
|
@@ -176,6 +177,14 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
176
177
|
price: val === null || val === void 0 ? void 0 : val.fare,
|
|
177
178
|
}));
|
|
178
179
|
seatTypesWithPrices.sort((a, b) => a.price - b.price);
|
|
180
|
+
return seatTypesWithPrices;
|
|
181
|
+
};
|
|
182
|
+
const getSortedSeatTypes = () => {
|
|
183
|
+
var _a;
|
|
184
|
+
if (!((_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
185
|
+
return [{ label: "Salon cama", price: 0 }];
|
|
186
|
+
}
|
|
187
|
+
let seatTypesWithPrices = getAllSeatTypes();
|
|
179
188
|
const premiumIndex = seatTypesWithPrices.findIndex((item) => item.label === "Premium");
|
|
180
189
|
if (premiumIndex >= 3) {
|
|
181
190
|
seatTypesWithPrices[2] = seatTypesWithPrices[premiumIndex];
|
|
@@ -183,15 +192,14 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
183
192
|
seatTypesWithPrices = seatTypesWithPrices.slice(0, 2);
|
|
184
193
|
return seatTypesWithPrices;
|
|
185
194
|
};
|
|
186
|
-
const
|
|
187
|
-
const
|
|
195
|
+
const getUniqueSeats = () => {
|
|
196
|
+
const allSeatTypes = getAllSeatTypes();
|
|
188
197
|
const seatMap = new Map();
|
|
189
|
-
|
|
198
|
+
allSeatTypes.forEach((seat) => {
|
|
190
199
|
if (SEAT_EXCEPTIONS.includes(seat.label))
|
|
191
200
|
return;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (!currentLowest || seatPrice < parseFloat(currentLowest.price)) {
|
|
201
|
+
// Only check if the label already exists in the map, don't compare prices
|
|
202
|
+
if (!seatMap.has(seat.label)) {
|
|
195
203
|
seatMap.set(seat.label, seat);
|
|
196
204
|
}
|
|
197
205
|
});
|
|
@@ -201,10 +209,10 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
201
209
|
return serviceItem.seat_types.filter((val) => !SEAT_EXCEPTIONS.includes(val.label)).length;
|
|
202
210
|
};
|
|
203
211
|
const getSeatNames = () => {
|
|
204
|
-
const
|
|
212
|
+
const uniqueSeats = getUniqueSeats();
|
|
205
213
|
const sortedSeatTypes = getSortedSeatTypes();
|
|
206
214
|
if (removeDuplicateSeats) {
|
|
207
|
-
return
|
|
215
|
+
return uniqueSeats.map((val, key) => SEAT_EXCEPTIONS.includes(val.label) ? null : (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"
|
|
208
216
|
? val.label
|
|
209
217
|
: null)));
|
|
210
218
|
}
|
|
@@ -214,7 +222,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
214
222
|
};
|
|
215
223
|
const getSeatPrice = () => {
|
|
216
224
|
const sortedSeatTypes = getSortedSeatTypes();
|
|
217
|
-
const uniqueSeats =
|
|
225
|
+
const uniqueSeats = getUniqueSeats();
|
|
218
226
|
if (removeDuplicateSeats) {
|
|
219
227
|
return uniqueSeats.map((val, key) => (React.createElement("span", { key: key }, (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats) <= 0
|
|
220
228
|
? CommonService.currency(0, currencySign)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MobileServiceItemProps } from "./mobileTypes";
|
|
3
|
-
declare function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, orignLabel, destinationLabel, amenitiesData, setShowDropdown, showDropdown, setAmenetiesAtomValue, isCiva, currencySign, isPeru, showRating, showLastSeats, }: MobileServiceItemProps): React.ReactElement;
|
|
3
|
+
declare function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, orignLabel, destinationLabel, amenitiesData, setShowDropdown, showDropdown, setAmenetiesAtomValue, isCiva, currencySign, isPeru, showRating, showLastSeats, removeDuplicateSeats, }: MobileServiceItemProps): React.ReactElement;
|
|
4
4
|
export default ServiceItemMobile;
|
|
@@ -14,7 +14,7 @@ const exceptions = [
|
|
|
14
14
|
"blanco",
|
|
15
15
|
"asiento_mascota",
|
|
16
16
|
];
|
|
17
|
-
function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, orignLabel, destinationLabel, amenitiesData, setShowDropdown, showDropdown, setAmenetiesAtomValue, isCiva, currencySign, isPeru, showRating, showLastSeats, }) {
|
|
17
|
+
function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, orignLabel, destinationLabel, amenitiesData, setShowDropdown, showDropdown, setAmenetiesAtomValue, isCiva, currencySign, isPeru, showRating, showLastSeats, removeDuplicateSeats, }) {
|
|
18
18
|
var _a, _b, _c;
|
|
19
19
|
const isPetSeat = (Object.keys(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.pet_seat_info) || []).length > 0;
|
|
20
20
|
let isSoldOut = serviceItem.available_seats <= 0;
|
|
@@ -36,6 +36,22 @@ function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, o
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
const seatTypes = () => {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
let seatTypes = (_d = (_c = (_b = (_a = serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.filter((item) => getFilteredSeats(item.label))) === null || _b === void 0 ? void 0 : _b.sort((a, b) => a.fare - b.fare) // Add this line to sort by fare
|
|
41
|
+
) === null || _c === void 0 ? void 0 : _c.slice(0, 2)) === null || _d === void 0 ? void 0 : _d.map((type, i) => {
|
|
42
|
+
var _a;
|
|
43
|
+
return exceptions.includes(type.label) ? null : (React.createElement("div", { className: ((_a = serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.length) > 2
|
|
44
|
+
? "w-[100%] flex flex-row justify-between "
|
|
45
|
+
: "w-[100%] flex flex-row justify-between items-center", key: i },
|
|
46
|
+
React.createElement("span", { className: "min-[420]:text-[13px] text-[11px] ", style: {
|
|
47
|
+
// marginLeft: "10px",
|
|
48
|
+
color: isSoldOut ? "#bbb" : "#464647",
|
|
49
|
+
} }, type.label),
|
|
50
|
+
React.createElement("span", { className: "min-[420]:text-[13px] text-[11px] bold-text", style: { color: isSoldOut ? "#bbb" : colors.seatPriceColor } }, commonService.currency(type.fare, currencySign))));
|
|
51
|
+
});
|
|
52
|
+
return seatTypes;
|
|
53
|
+
};
|
|
54
|
+
const seatTypesWithRemoveDuplicateSeats = () => {
|
|
39
55
|
var _a, _b;
|
|
40
56
|
const seatMap = new Map();
|
|
41
57
|
(_b = (_a = serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.filter((item) => getFilteredSeats(item.label))) === null || _b === void 0 ? void 0 : _b.forEach((item) => {
|
|
@@ -209,7 +225,9 @@ function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, o
|
|
|
209
225
|
? "space-between"
|
|
210
226
|
: "center",
|
|
211
227
|
} },
|
|
212
|
-
|
|
228
|
+
removeDuplicateSeats
|
|
229
|
+
? seatTypesWithRemoveDuplicateSeats()
|
|
230
|
+
: seatTypes(),
|
|
213
231
|
isSoldOut ? (React.createElement("div", { className: "flex justify-end" },
|
|
214
232
|
React.createElement("span", { className: "min-[420]:text-[13px] text-[11px] text-[#ccc]" }, "Agotado"))) : null))),
|
|
215
233
|
React.createElement("div", { className: "bg-[#E6E6E6] -ml-[12px] -mr-[12px] mt-[10px] mb-[10px] h-[1px]" }),
|
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@ function ServiceItemPB({
|
|
|
31
31
|
originIconStyle,
|
|
32
32
|
t = (key: string) => key,
|
|
33
33
|
}: ServiceItemProps & { currencySign?: string }): React.ReactElement {
|
|
34
|
+
console.log("🚀 ~ ServiceItemPB ~ serviceItem:", serviceItem);
|
|
34
35
|
const SvgAmenities = ({
|
|
35
36
|
moreAnemities,
|
|
36
37
|
name,
|
|
@@ -243,7 +244,7 @@ function ServiceItemPB({
|
|
|
243
244
|
return null;
|
|
244
245
|
};
|
|
245
246
|
|
|
246
|
-
const
|
|
247
|
+
const getAllSeatTypes = () => {
|
|
247
248
|
if (!serviceItem?.seat_types?.length) {
|
|
248
249
|
return [{ label: "Salon cama", price: 0 }];
|
|
249
250
|
}
|
|
@@ -256,6 +257,16 @@ function ServiceItemPB({
|
|
|
256
257
|
}));
|
|
257
258
|
|
|
258
259
|
seatTypesWithPrices.sort((a, b) => a.price - b.price);
|
|
260
|
+
|
|
261
|
+
return seatTypesWithPrices;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const getSortedSeatTypes = () => {
|
|
265
|
+
if (!serviceItem?.seat_types?.length) {
|
|
266
|
+
return [{ label: "Salon cama", price: 0 }];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let seatTypesWithPrices = getAllSeatTypes();
|
|
259
270
|
const premiumIndex = seatTypesWithPrices.findIndex(
|
|
260
271
|
(item) => item.label === "Premium"
|
|
261
272
|
);
|
|
@@ -269,17 +280,15 @@ function ServiceItemPB({
|
|
|
269
280
|
return seatTypesWithPrices;
|
|
270
281
|
};
|
|
271
282
|
|
|
272
|
-
const
|
|
273
|
-
const
|
|
283
|
+
const getUniqueSeats = () => {
|
|
284
|
+
const allSeatTypes = getAllSeatTypes();
|
|
274
285
|
const seatMap = new Map();
|
|
275
286
|
|
|
276
|
-
|
|
287
|
+
allSeatTypes.forEach((seat) => {
|
|
277
288
|
if (SEAT_EXCEPTIONS.includes(seat.label)) return;
|
|
278
289
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (!currentLowest || seatPrice < parseFloat(currentLowest.price)) {
|
|
290
|
+
// Only check if the label already exists in the map, don't compare prices
|
|
291
|
+
if (!seatMap.has(seat.label)) {
|
|
283
292
|
seatMap.set(seat.label, seat);
|
|
284
293
|
}
|
|
285
294
|
});
|
|
@@ -294,11 +303,11 @@ function ServiceItemPB({
|
|
|
294
303
|
};
|
|
295
304
|
|
|
296
305
|
const getSeatNames = () => {
|
|
297
|
-
const
|
|
306
|
+
const uniqueSeats = getUniqueSeats();
|
|
298
307
|
const sortedSeatTypes = getSortedSeatTypes();
|
|
299
308
|
|
|
300
309
|
if (removeDuplicateSeats) {
|
|
301
|
-
return
|
|
310
|
+
return uniqueSeats.map((val, key: number) =>
|
|
302
311
|
SEAT_EXCEPTIONS.includes(val.label) ? null : (
|
|
303
312
|
<span
|
|
304
313
|
key={key}
|
|
@@ -331,7 +340,7 @@ function ServiceItemPB({
|
|
|
331
340
|
|
|
332
341
|
const getSeatPrice = () => {
|
|
333
342
|
const sortedSeatTypes = getSortedSeatTypes();
|
|
334
|
-
const uniqueSeats =
|
|
343
|
+
const uniqueSeats = getUniqueSeats();
|
|
335
344
|
if (removeDuplicateSeats) {
|
|
336
345
|
return uniqueSeats.map((val, key) => (
|
|
337
346
|
<span key={key}>
|
|
@@ -34,6 +34,7 @@ function ServiceItemMobile({
|
|
|
34
34
|
isPeru,
|
|
35
35
|
showRating,
|
|
36
36
|
showLastSeats,
|
|
37
|
+
removeDuplicateSeats,
|
|
37
38
|
}: MobileServiceItemProps): React.ReactElement {
|
|
38
39
|
const isPetSeat = (Object.keys(serviceItem?.pet_seat_info) || []).length > 0;
|
|
39
40
|
let isSoldOut = serviceItem.available_seats <= 0;
|
|
@@ -60,6 +61,42 @@ function ServiceItemMobile({
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
const seatTypes = () => {
|
|
64
|
+
let seatTypes = serviceItem.seat_types
|
|
65
|
+
?.filter((item) => getFilteredSeats(item.label))
|
|
66
|
+
?.sort((a, b) => a.fare - b.fare) // Add this line to sort by fare
|
|
67
|
+
?.slice(0, 2)
|
|
68
|
+
?.map((type, i) =>
|
|
69
|
+
exceptions.includes(type.label) ? null : (
|
|
70
|
+
<div
|
|
71
|
+
className={
|
|
72
|
+
serviceItem.seat_types?.length > 2
|
|
73
|
+
? "w-[100%] flex flex-row justify-between "
|
|
74
|
+
: "w-[100%] flex flex-row justify-between items-center"
|
|
75
|
+
}
|
|
76
|
+
key={i}
|
|
77
|
+
>
|
|
78
|
+
<span
|
|
79
|
+
className="min-[420]:text-[13px] text-[11px] "
|
|
80
|
+
style={{
|
|
81
|
+
// marginLeft: "10px",
|
|
82
|
+
color: isSoldOut ? "#bbb" : "#464647",
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{type.label}
|
|
86
|
+
</span>
|
|
87
|
+
<span
|
|
88
|
+
className={"min-[420]:text-[13px] text-[11px] bold-text"}
|
|
89
|
+
style={{ color: isSoldOut ? "#bbb" : colors.seatPriceColor }}
|
|
90
|
+
>
|
|
91
|
+
{commonService.currency(type.fare, currencySign)}
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
return seatTypes;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const seatTypesWithRemoveDuplicateSeats = () => {
|
|
63
100
|
const seatMap = new Map();
|
|
64
101
|
|
|
65
102
|
serviceItem.seat_types
|
|
@@ -403,7 +440,9 @@ function ServiceItemMobile({
|
|
|
403
440
|
: "center",
|
|
404
441
|
}}
|
|
405
442
|
>
|
|
406
|
-
{
|
|
443
|
+
{removeDuplicateSeats
|
|
444
|
+
? seatTypesWithRemoveDuplicateSeats()
|
|
445
|
+
: seatTypes()}
|
|
407
446
|
|
|
408
447
|
{isSoldOut ? (
|
|
409
448
|
<div className="flex justify-end">
|