kupos-ui-components-lib 4.0.1 → 4.0.2

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,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
- seatTypes(),
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]" }),
@@ -137,4 +137,5 @@ export interface MobileServiceItemProps {
137
137
  variant?: "desktop" | "mobile" | "auto";
138
138
  showRating?: boolean;
139
139
  showLastSeats?: boolean;
140
+ removeDuplicateSeats?: boolean;
140
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -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
- {seatTypes()}
443
+ {removeDuplicateSeats
444
+ ? seatTypesWithRemoveDuplicateSeats()
445
+ : seatTypes()}
407
446
 
408
447
  {isSoldOut ? (
409
448
  <div className="flex justify-end">
@@ -151,4 +151,5 @@ export interface MobileServiceItemProps {
151
151
  variant?: "desktop" | "mobile" | "auto";
152
152
  showRating?: boolean;
153
153
  showLastSeats?: boolean;
154
+ removeDuplicateSeats?: boolean;
154
155
  }