kupos-ui-components-lib 4.0.2 → 4.0.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.
@@ -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 = () => {
@@ -24,7 +25,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
24
25
  }, className: `object-contain ${moreAnemities ? "w-[16px] h-[16px]" : "w-[16px] h-[16px]"}` }));
25
26
  };
26
27
  const getAmenitiesImage = (name) => {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
28
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
28
29
  switch (name) {
29
30
  case "air_condtion.png": {
30
31
  return (_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _a === void 0 ? void 0 : _a.airConditionIcon;
@@ -68,6 +69,33 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
68
69
  case "frazada.png": {
69
70
  return (_p = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _p === void 0 ? void 0 : _p.frazaIcon;
70
71
  }
72
+ case "blankket.png": {
73
+ return (_q = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _q === void 0 ? void 0 : _q.blankketIcon;
74
+ }
75
+ case "cctv.png": {
76
+ return (_r = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _r === void 0 ? void 0 : _r.cctvIcon;
77
+ }
78
+ case "cup_holder.png": {
79
+ return (_s = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _s === void 0 ? void 0 : _s.cupHolderIcon;
80
+ }
81
+ case "emergency_contact.png": {
82
+ return (_t = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _t === void 0 ? void 0 : _t.emergencyContactIcon;
83
+ }
84
+ case "emergency_exit.png": {
85
+ return (_u = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _u === void 0 ? void 0 : _u.emergencyExitIcon;
86
+ }
87
+ case "fire_extinguisher.png": {
88
+ return (_v = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _v === void 0 ? void 0 : _v.fireExtinguisherIcon;
89
+ }
90
+ case "reading_light.png": {
91
+ return (_w = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _w === void 0 ? void 0 : _w.readingLIghtIcon;
92
+ }
93
+ case "security_belt.png": {
94
+ return (_x = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _x === void 0 ? void 0 : _x.sercurityBeltIcon;
95
+ }
96
+ case "service_on_board.png": {
97
+ return (_y = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _y === void 0 ? void 0 : _y.serviceOnBoardIcon;
98
+ }
71
99
  default: {
72
100
  return "";
73
101
  }
@@ -96,7 +124,25 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
96
124
  case "cortina divisoria":
97
125
  return "Cortina Divisoria";
98
126
  case "frazada":
99
- return "";
127
+ return "Frazada";
128
+ case "blankket":
129
+ return "Mantas";
130
+ case "cctv":
131
+ return "Cámara de seguridad";
132
+ case "cup_holder":
133
+ return "Portavasos";
134
+ case "emergency_contact":
135
+ return "Contacto de emergencia";
136
+ case "emergency_exit":
137
+ return "Salida de emergencia";
138
+ case "fire_extinguisher":
139
+ return "Extintor de incendio";
140
+ case "reading_light":
141
+ return "Luz de lectura";
142
+ case "security_belt":
143
+ return "Cinturón de seguridad";
144
+ case "service_on_board":
145
+ return "Servicio a bordo";
100
146
  default:
101
147
  return rawAmenity;
102
148
  }
@@ -164,7 +210,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
164
210
  }
165
211
  return null;
166
212
  };
167
- const getSortedSeatTypes = () => {
213
+ const getAllSeatTypes = () => {
168
214
  var _a;
169
215
  if (!((_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.length)) {
170
216
  return [{ label: "Salon cama", price: 0 }];
@@ -176,6 +222,14 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
176
222
  price: val === null || val === void 0 ? void 0 : val.fare,
177
223
  }));
178
224
  seatTypesWithPrices.sort((a, b) => a.price - b.price);
225
+ return seatTypesWithPrices;
226
+ };
227
+ const getSortedSeatTypes = () => {
228
+ var _a;
229
+ if (!((_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.seat_types) === null || _a === void 0 ? void 0 : _a.length)) {
230
+ return [{ label: "Salon cama", price: 0 }];
231
+ }
232
+ let seatTypesWithPrices = getAllSeatTypes();
179
233
  const premiumIndex = seatTypesWithPrices.findIndex((item) => item.label === "Premium");
180
234
  if (premiumIndex >= 3) {
181
235
  seatTypesWithPrices[2] = seatTypesWithPrices[premiumIndex];
@@ -183,15 +237,14 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
183
237
  seatTypesWithPrices = seatTypesWithPrices.slice(0, 2);
184
238
  return seatTypesWithPrices;
185
239
  };
186
- const getUniqueSeatsWithLowestPrice = () => {
187
- const sortedSeatTypes = getSortedSeatTypes();
240
+ const getUniqueSeats = () => {
241
+ const allSeatTypes = getAllSeatTypes();
188
242
  const seatMap = new Map();
189
- sortedSeatTypes.forEach((seat) => {
243
+ allSeatTypes.forEach((seat) => {
190
244
  if (SEAT_EXCEPTIONS.includes(seat.label))
191
245
  return;
192
- const currentLowest = seatMap.get(seat.label);
193
- const seatPrice = parseFloat(seat.price);
194
- if (!currentLowest || seatPrice < parseFloat(currentLowest.price)) {
246
+ // Only check if the label already exists in the map, don't compare prices
247
+ if (!seatMap.has(seat.label)) {
195
248
  seatMap.set(seat.label, seat);
196
249
  }
197
250
  });
@@ -201,10 +254,10 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
201
254
  return serviceItem.seat_types.filter((val) => !SEAT_EXCEPTIONS.includes(val.label)).length;
202
255
  };
203
256
  const getSeatNames = () => {
204
- const sortedSeatTypesDuplicate = getUniqueSeatsWithLowestPrice();
257
+ const uniqueSeats = getUniqueSeats();
205
258
  const sortedSeatTypes = getSortedSeatTypes();
206
259
  if (removeDuplicateSeats) {
207
- return sortedSeatTypesDuplicate.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"
260
+ 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
261
  ? val.label
209
262
  : null)));
210
263
  }
@@ -214,7 +267,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
214
267
  };
215
268
  const getSeatPrice = () => {
216
269
  const sortedSeatTypes = getSortedSeatTypes();
217
- const uniqueSeats = getUniqueSeatsWithLowestPrice();
270
+ const uniqueSeats = getUniqueSeats();
218
271
  if (removeDuplicateSeats) {
219
272
  return uniqueSeats.map((val, key) => (React.createElement("span", { key: key }, (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats) <= 0
220
273
  ? CommonService.currency(0, currencySign)
@@ -84,7 +84,7 @@ function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, o
84
84
  return item;
85
85
  };
86
86
  const getAmenitiesImage = (name) => {
87
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
87
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
88
88
  switch (name) {
89
89
  case "air_condtion.png": {
90
90
  return (_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _a === void 0 ? void 0 : _a.airConditionIcon;
@@ -128,6 +128,33 @@ function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, o
128
128
  case "frazada.png": {
129
129
  return (_p = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _p === void 0 ? void 0 : _p.frazaIcon;
130
130
  }
131
+ case "blankket.png": {
132
+ return (_q = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _q === void 0 ? void 0 : _q.blankketIcon;
133
+ }
134
+ case "cctv.png": {
135
+ return (_r = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _r === void 0 ? void 0 : _r.cctvIcon;
136
+ }
137
+ case "cup_holder.png": {
138
+ return (_s = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _s === void 0 ? void 0 : _s.cupHolderIcon;
139
+ }
140
+ case "emergency_contact.png": {
141
+ return (_t = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _t === void 0 ? void 0 : _t.emergencyContactIcon;
142
+ }
143
+ case "emergency_exit.png": {
144
+ return (_u = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _u === void 0 ? void 0 : _u.emergencyExitIcon;
145
+ }
146
+ case "fire_extinguisher.png": {
147
+ return (_v = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _v === void 0 ? void 0 : _v.fireExtinguisherIcon;
148
+ }
149
+ case "reading_light.png": {
150
+ return (_w = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _w === void 0 ? void 0 : _w.readingLIghtIcon;
151
+ }
152
+ case "security_belt.png": {
153
+ return (_x = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _x === void 0 ? void 0 : _x.sercurityBeltIcon;
154
+ }
155
+ case "service_on_board.png": {
156
+ return (_y = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.icons) === null || _y === void 0 ? void 0 : _y.serviceOnBoardIcon;
157
+ }
131
158
  default: {
132
159
  return "";
133
160
  }
@@ -91,6 +91,15 @@ export interface MobileServiceItemProps {
91
91
  wifiIcon?: string;
92
92
  cortinaIcon?: string;
93
93
  frazaIcon?: string;
94
+ blankketIcon?: string;
95
+ cctvIcon?: string;
96
+ cupHolderIcon?: string;
97
+ emergencyContactIcon?: string;
98
+ emergencyExitIcon?: string;
99
+ fireExtinguisherIcon?: string;
100
+ readingLIghtIcon?: string;
101
+ sercurityBeltIcon?: string;
102
+ serviceOnBoardIcon?: string;
94
103
  airportIcon?: string;
95
104
  [key: string]: string | Record<string, string | undefined> | undefined;
96
105
  };
@@ -96,6 +96,15 @@ export interface ServiceItemProps {
96
96
  wifiIcon?: string;
97
97
  cortinaIcon?: string;
98
98
  frazaIcon?: string;
99
+ blankketIcon?: string;
100
+ cctvIcon?: string;
101
+ cupHolderIcon?: string;
102
+ emergencyContactIcon?: string;
103
+ emergencyExitIcon?: string;
104
+ fireExtinguisherIcon?: string;
105
+ readingLIghtIcon?: string;
106
+ sercurityBeltIcon?: string;
107
+ serviceOnBoardIcon?: string;
99
108
  [key: string]: string | Record<string, string | undefined> | undefined;
100
109
  };
101
110
  useLottieFor?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -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,
@@ -113,6 +114,33 @@ function ServiceItemPB({
113
114
  case "frazada.png": {
114
115
  return serviceItem?.icons?.frazaIcon;
115
116
  }
117
+ case "blankket.png": {
118
+ return serviceItem?.icons?.blankketIcon;
119
+ }
120
+ case "cctv.png": {
121
+ return serviceItem?.icons?.cctvIcon;
122
+ }
123
+ case "cup_holder.png": {
124
+ return serviceItem?.icons?.cupHolderIcon;
125
+ }
126
+ case "emergency_contact.png": {
127
+ return serviceItem?.icons?.emergencyContactIcon;
128
+ }
129
+ case "emergency_exit.png": {
130
+ return serviceItem?.icons?.emergencyExitIcon;
131
+ }
132
+ case "fire_extinguisher.png": {
133
+ return serviceItem?.icons?.fireExtinguisherIcon;
134
+ }
135
+ case "reading_light.png": {
136
+ return serviceItem?.icons?.readingLIghtIcon;
137
+ }
138
+ case "security_belt.png": {
139
+ return serviceItem?.icons?.sercurityBeltIcon;
140
+ }
141
+ case "service_on_board.png": {
142
+ return serviceItem?.icons?.serviceOnBoardIcon;
143
+ }
116
144
  default: {
117
145
  return "";
118
146
  }
@@ -142,7 +170,25 @@ function ServiceItemPB({
142
170
  case "cortina divisoria":
143
171
  return "Cortina Divisoria";
144
172
  case "frazada":
145
- return "";
173
+ return "Frazada";
174
+ case "blankket":
175
+ return "Mantas";
176
+ case "cctv":
177
+ return "Cámara de seguridad";
178
+ case "cup_holder":
179
+ return "Portavasos";
180
+ case "emergency_contact":
181
+ return "Contacto de emergencia";
182
+ case "emergency_exit":
183
+ return "Salida de emergencia";
184
+ case "fire_extinguisher":
185
+ return "Extintor de incendio";
186
+ case "reading_light":
187
+ return "Luz de lectura";
188
+ case "security_belt":
189
+ return "Cinturón de seguridad";
190
+ case "service_on_board":
191
+ return "Servicio a bordo";
146
192
  default:
147
193
  return rawAmenity;
148
194
  }
@@ -243,7 +289,7 @@ function ServiceItemPB({
243
289
  return null;
244
290
  };
245
291
 
246
- const getSortedSeatTypes = () => {
292
+ const getAllSeatTypes = () => {
247
293
  if (!serviceItem?.seat_types?.length) {
248
294
  return [{ label: "Salon cama", price: 0 }];
249
295
  }
@@ -256,6 +302,16 @@ function ServiceItemPB({
256
302
  }));
257
303
 
258
304
  seatTypesWithPrices.sort((a, b) => a.price - b.price);
305
+
306
+ return seatTypesWithPrices;
307
+ };
308
+
309
+ const getSortedSeatTypes = () => {
310
+ if (!serviceItem?.seat_types?.length) {
311
+ return [{ label: "Salon cama", price: 0 }];
312
+ }
313
+
314
+ let seatTypesWithPrices = getAllSeatTypes();
259
315
  const premiumIndex = seatTypesWithPrices.findIndex(
260
316
  (item) => item.label === "Premium"
261
317
  );
@@ -269,17 +325,15 @@ function ServiceItemPB({
269
325
  return seatTypesWithPrices;
270
326
  };
271
327
 
272
- const getUniqueSeatsWithLowestPrice = () => {
273
- const sortedSeatTypes = getSortedSeatTypes();
328
+ const getUniqueSeats = () => {
329
+ const allSeatTypes = getAllSeatTypes();
274
330
  const seatMap = new Map();
275
331
 
276
- sortedSeatTypes.forEach((seat) => {
332
+ allSeatTypes.forEach((seat) => {
277
333
  if (SEAT_EXCEPTIONS.includes(seat.label)) return;
278
334
 
279
- const currentLowest = seatMap.get(seat.label);
280
- const seatPrice = parseFloat(seat.price as any);
281
-
282
- if (!currentLowest || seatPrice < parseFloat(currentLowest.price)) {
335
+ // Only check if the label already exists in the map, don't compare prices
336
+ if (!seatMap.has(seat.label)) {
283
337
  seatMap.set(seat.label, seat);
284
338
  }
285
339
  });
@@ -294,11 +348,11 @@ function ServiceItemPB({
294
348
  };
295
349
 
296
350
  const getSeatNames = () => {
297
- const sortedSeatTypesDuplicate = getUniqueSeatsWithLowestPrice();
351
+ const uniqueSeats = getUniqueSeats();
298
352
  const sortedSeatTypes = getSortedSeatTypes();
299
353
 
300
354
  if (removeDuplicateSeats) {
301
- return sortedSeatTypesDuplicate.map((val, key: number) =>
355
+ return uniqueSeats.map((val, key: number) =>
302
356
  SEAT_EXCEPTIONS.includes(val.label) ? null : (
303
357
  <span
304
358
  key={key}
@@ -331,7 +385,7 @@ function ServiceItemPB({
331
385
 
332
386
  const getSeatPrice = () => {
333
387
  const sortedSeatTypes = getSortedSeatTypes();
334
- const uniqueSeats = getUniqueSeatsWithLowestPrice();
388
+ const uniqueSeats = getUniqueSeats();
335
389
  if (removeDuplicateSeats) {
336
390
  return uniqueSeats.map((val, key) => (
337
391
  <span key={key}>
@@ -200,6 +200,33 @@ function ServiceItemMobile({
200
200
  case "frazada.png": {
201
201
  return serviceItem?.icons?.frazaIcon;
202
202
  }
203
+ case "blankket.png": {
204
+ return serviceItem?.icons?.blankketIcon;
205
+ }
206
+ case "cctv.png": {
207
+ return serviceItem?.icons?.cctvIcon;
208
+ }
209
+ case "cup_holder.png": {
210
+ return serviceItem?.icons?.cupHolderIcon;
211
+ }
212
+ case "emergency_contact.png": {
213
+ return serviceItem?.icons?.emergencyContactIcon;
214
+ }
215
+ case "emergency_exit.png": {
216
+ return serviceItem?.icons?.emergencyExitIcon;
217
+ }
218
+ case "fire_extinguisher.png": {
219
+ return serviceItem?.icons?.fireExtinguisherIcon;
220
+ }
221
+ case "reading_light.png": {
222
+ return serviceItem?.icons?.readingLIghtIcon;
223
+ }
224
+ case "security_belt.png": {
225
+ return serviceItem?.icons?.sercurityBeltIcon;
226
+ }
227
+ case "service_on_board.png": {
228
+ return serviceItem?.icons?.serviceOnBoardIcon;
229
+ }
203
230
  default: {
204
231
  return "";
205
232
  }
@@ -94,6 +94,15 @@ export interface MobileServiceItemProps {
94
94
  wifiIcon?: string;
95
95
  cortinaIcon?: string;
96
96
  frazaIcon?: string;
97
+ blankketIcon?: string;
98
+ cctvIcon?: string;
99
+ cupHolderIcon?: string;
100
+ emergencyContactIcon?: string;
101
+ emergencyExitIcon?: string;
102
+ fireExtinguisherIcon?: string;
103
+ readingLIghtIcon?: string;
104
+ sercurityBeltIcon?: string;
105
+ serviceOnBoardIcon?: string;
97
106
  airportIcon?: string;
98
107
  [key: string]: string | Record<string, string | undefined> | undefined;
99
108
  };
@@ -98,6 +98,15 @@ export interface ServiceItemProps {
98
98
  wifiIcon?: string;
99
99
  cortinaIcon?: string;
100
100
  frazaIcon?: string;
101
+ blankketIcon?: string;
102
+ cctvIcon?: string;
103
+ cupHolderIcon?: string;
104
+ emergencyContactIcon?: string;
105
+ emergencyExitIcon?: string;
106
+ fireExtinguisherIcon?: string;
107
+ readingLIghtIcon?: string;
108
+ sercurityBeltIcon?: string;
109
+ serviceOnBoardIcon?: string;
101
110
  [key: string]: string | Record<string, string | undefined> | undefined;
102
111
  };
103
112
  useLottieFor?: string[];