kupos-ui-components-lib 9.8.4 → 9.8.6

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.
Files changed (28) hide show
  1. package/dist/KuposUIComponent.d.ts +0 -3
  2. package/dist/components/ServiceItem/PeruServiceItemDesktop.d.ts +1 -1
  3. package/dist/components/ServiceItem/PeruServiceItemDesktop.js +2 -2
  4. package/dist/components/ServiceItem/ServiceItemDesktop.d.ts +1 -1
  5. package/dist/components/ServiceItem/ServiceItemDesktop.js +21 -21
  6. package/dist/components/ServiceItem/ServiceItemMobile.d.ts +1 -1
  7. package/dist/components/ServiceItem/ServiceItemMobile.js +7 -16
  8. package/dist/components/ServiceItem/mobileTypes.d.ts +0 -33
  9. package/dist/components/ServiceItem/types.d.ts +8 -23
  10. package/dist/styles.css +6 -212
  11. package/dist/ui/SeatSection/SeatSection.d.ts +7 -1
  12. package/dist/ui/SeatSection/SeatSection.js +31 -6
  13. package/dist/utils/CommonService.js +1 -11
  14. package/package.json +1 -1
  15. package/src/KuposUIComponent.tsx +0 -3
  16. package/src/components/ServiceItem/PeruServiceItemDesktop.tsx +24 -34
  17. package/src/components/ServiceItem/ServiceItemDesktop.tsx +45 -57
  18. package/src/components/ServiceItem/ServiceItemMobile.tsx +286 -342
  19. package/src/components/ServiceItem/mobileTypes.ts +1 -30
  20. package/src/components/ServiceItem/types.ts +24 -35
  21. package/src/styles.css +0 -15
  22. package/src/ui/SeatSection/SeatSection.tsx +76 -15
  23. package/src/utils/CommonService.ts +1 -13
  24. package/src/assets/images/anims/service_list/flame_anim.json +0 -1
  25. package/src/assets/images/anims/service_list/thunder_icon.json +0 -1
  26. package/src/assets/images/anims/service_list/users_anim.json +0 -1
  27. package/src/ui/FeaturServiceUiMobile/FeatureServiceUiMobile.tsx +0 -556
  28. package/src/ui/FeatureServiceUI/FeatureServiceUi.tsx +0 -592
@@ -1,556 +0,0 @@
1
- import React from "react";
2
- import LottiePlayer from "../../assets/LottiePlayer";
3
- import commonService from "../../utils/CommonService";
4
- import flameAnimation from "../../assets/images/anims/service_list/flame_anim.json";
5
-
6
- const TIME_SLOTS = [
7
- "Entre 07:00 AM y 10:00 AM",
8
- "Entre 11:00 AM y 14:00 AM",
9
- "Entre 15:00 PM y 18:00 PM",
10
- "Entre 19:00 PM y 22:00 PM",
11
- ];
12
-
13
- const HARDCODED_OPERATORS = [
14
- {
15
- logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Turbus_logo.svg/320px-Turbus_logo.svg.png",
16
- name: "Turbus",
17
- time: "7:00 am",
18
- seatsAvailable: "3 disponibles",
19
- },
20
- {
21
- logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Pullman_Bus_logo.svg/320px-Pullman_Bus_logo.svg.png",
22
- name: "Turbus",
23
- time: "8:00 am",
24
- seatsAvailable: "5 disponibles",
25
- },
26
- {
27
- logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Turbus_logo.svg/320px-Turbus_logo.svg.png",
28
- name: "Turbus",
29
- time: "9:00 am",
30
- seatsAvailable: "3 disponibles",
31
- },
32
- ];
33
-
34
- const FeatureServiceUiMobile = ({
35
- serviceItem,
36
- showTopLabel,
37
- colors,
38
- isSoldOut,
39
- cityOrigin,
40
- cityDestination,
41
- renderIcon,
42
- viewersConfig,
43
- isFeatureDropDownExpand,
44
- onToggleExpand,
45
- ticketQuantity = 1,
46
- onIncreaseTicketQuantity,
47
- onDecreaseTicketQuantity,
48
- onBookButtonPress,
49
- selectedTimeSlot = TIME_SLOTS[0],
50
- onTimeSlotChange,
51
- isTimeDropdownOpen,
52
- onTimeDropdownToggle,
53
- wowDealData = undefined,
54
- }) => {
55
- // Use wow_deal data if available, otherwise fall back to serviceItem operators or hardcoded
56
- const operators =
57
- wowDealData?.operators?.length > 0
58
- ? wowDealData.operators.map((op: any) => ({
59
- logo: op.operator_logo_url,
60
- name: op.operator_name,
61
- time: op.starting_departure,
62
- seatsAvailable: `${op.available_seats} disponibles`,
63
- }))
64
- : serviceItem?.operators?.length > 0
65
- ? serviceItem.operators
66
- : HARDCODED_OPERATORS;
67
-
68
- // Use wow_deal pricing if available
69
- const finalPrice = wowDealData?.final_price || 4000;
70
- const originalPrice = wowDealData?.original_price || 10000;
71
- const savingsPercent = wowDealData?.savings_percent || 60;
72
- const operatorsCompetingCount = wowDealData?.operators_competing_count || 3;
73
- const maxSeatsPerBooking = wowDealData?.max_seats_per_booking || 4;
74
- const expiresAt = wowDealData?.expires_at;
75
- const isPostPaymentAssignment = wowDealData?.is_post_payment_assignment;
76
- const dealWindowFrom = wowDealData?.deal_window_from || "07:00";
77
- const dealWindowTo = wowDealData?.deal_window_to || "10:00";
78
- const travelDate = wowDealData?.travel_date;
79
-
80
- // Calculate countdown seconds from expires_at ISO timestamp
81
- const getCountdownSeconds = () => {
82
- if (!expiresAt) return 599;
83
- const expires = new Date(expiresAt).getTime();
84
- const now = Date.now();
85
- const seconds = Math.max(0, Math.floor((expires - now) / 1000));
86
- return seconds;
87
- };
88
-
89
- // Generate time slot from deal window
90
- const dynamicTimeSlot = `Entre ${dealWindowFrom} y ${dealWindowTo}`;
91
- const displayTimeSlot = selectedTimeSlot || dynamicTimeSlot;
92
-
93
- const isItemExpanded =
94
- serviceItem.id === isFeatureDropDownExpand ||
95
- isFeatureDropDownExpand === true;
96
- const isThisTimeDropdownOpen = isTimeDropdownOpen === serviceItem.id;
97
-
98
- const canDecreaseTicketQuantity = ticketQuantity > 1;
99
-
100
- const HOW_IT_WORKS_STEPS = [
101
- {
102
- icon: "flexible",
103
- name: "Salida flexible",
104
- text: `Viajas en un horario entre las ${dealWindowFrom} y las ${dealWindowTo} del día elegido.`,
105
- },
106
- {
107
- icon: "bus",
108
- name: "Empresa asignada",
109
- text: isPostPaymentAssignment
110
- ? "Empresa y hora a confirmar luego del pago."
111
- : "Una de las empresas confirmará tu viaje al instante tras el pago.",
112
- },
113
- {
114
- icon: "price",
115
- name: "Precio garantizado",
116
- text: "Mejor precio garantizado. Sin cambios ni cancelación.",
117
- },
118
- {
119
- icon: "ticket",
120
- name: "¡Listo!",
121
- text: "Recibe todos los detalles de tu viaje al instante tras la compra.",
122
- },
123
- ];
124
-
125
- const FeatureStepIcon = ({ icon }) => {
126
- switch (icon) {
127
- case "flexible":
128
- return renderIcon("flexibleIcon", "20px");
129
- case "bus":
130
- return renderIcon("empressaIcon", "20px");
131
- case "price":
132
- return renderIcon("precioIcon", "20px");
133
- default:
134
- return renderIcon("listoIcon", "20px");
135
- }
136
- };
137
-
138
- return (
139
- <div
140
- // ${
141
- // serviceItem.offer_text ? "mb-[55px]" : "mb-[10px]"
142
- // }
143
- className={`relative mb-[10px]
144
- ${serviceItem?.is_direct_trip ||
145
- serviceItem?.train_type_label === "Tren Express (Nuevo)" ||
146
- showTopLabel
147
- ? "mt-[24px]"
148
- : "mt-[20px]"
149
- }`}
150
- >
151
- <div
152
- // className="shadow-service"
153
- style={{
154
- border: "1px solid #c0c0c0",
155
- padding: "12px",
156
- borderRadius: "14px",
157
- }}
158
- >
159
- <div className="flex flex-col items-center px-[12px] pb-[8px] text-[13.33px] gap-[8px]">
160
- <div className="flex items-center gap-[10px] mt-[16px]">
161
- <span>Salida flexible</span>
162
- <div
163
- className="bold-text font-[9px]"
164
- style={{
165
- backgroundColor: "#FF5C60",
166
- padding: "4px 8px",
167
- borderRadius: "10px",
168
- color: "#fff",
169
- animation: "pulse-zoom 2s ease-in-out infinite",
170
- whiteSpace: "nowrap",
171
- fontSize: "10px",
172
- }}
173
- >
174
- <span>AHORRAS {savingsPercent}%</span>
175
- </div>
176
- </div>
177
- </div>
178
- <div
179
- id={`service-card-${serviceItem.id}`}
180
- className="bg-[#0C1421] text-white mx-auto relative rounded-[14px] p-[14px] text-[13.33px]"
181
- >
182
- <div className="flex flex-col gap-[10px]">
183
- <div className=" text-[white]">
184
- <div className="flex flex-col gap-[10px] relative">
185
- <div className="flex items-center gap-[6px]">
186
- <img
187
- src={serviceItem.icons?.whiteOrigin}
188
- alt="origin"
189
- className={`w-[13px] h-[13px] shrink-0 ${isSoldOut ? "grayscale" : ""
190
- }`}
191
- />
192
-
193
- <span className="text-[14px] bold-text">
194
- {cityOrigin?.label.split(",")[0]}
195
- </span>
196
-
197
- <span className="mx-[6px] text-[14px] bold-text">→</span>
198
-
199
- <img
200
- src={serviceItem.icons?.whiteDestination}
201
- alt="destination"
202
- className={`w-[13px] h-[13px] shrink-0 ${isSoldOut ? "grayscale" : ""
203
- }`}
204
- style={{ opacity: isSoldOut ? 0.5 : 1 }}
205
- />
206
-
207
- <span className="text-[14px] bold-text">
208
- {cityDestination?.label.split(",")[0]}
209
- </span>
210
- </div>
211
-
212
- <div className="flex items-center gap-[6px]">
213
- <div
214
- className="kupos-time-dd relative"
215
- tabIndex={0}
216
- onBlur={(e) => {
217
- if (!e.currentTarget.contains(e.relatedTarget as Node)) {
218
- onTimeDropdownToggle?.(null);
219
- }
220
- }}
221
- style={{ outline: "none" }}
222
- >
223
- <button
224
- type="button"
225
- onClick={() =>
226
- onTimeDropdownToggle?.(
227
- isThisTimeDropdownOpen ? null : serviceItem.id,
228
- )
229
- }
230
- className="flex cursor-pointer select-none items-center gap-[6px] border-none bg-transparent p-0 bold-text text-[13px] text-[white]"
231
- >
232
- <span>{displayTimeSlot}</span>
233
- <img
234
- src={serviceItem?.icons?.downArrow}
235
- alt="down arrow"
236
- className={`kupos-time-chevron transition-transform duration-200 ${isThisTimeDropdownOpen ? "rotate-180" : "rotate-0"}`}
237
- style={{
238
- width: "12px",
239
- height: "8px",
240
- filter: "brightness(0) invert(1)",
241
- }}
242
- />
243
- </button>
244
- {isThisTimeDropdownOpen && (
245
- <>
246
- <div
247
- className="absolute left-0 top-[calc(100%+10px)]"
248
- style={{
249
- zIndex: 20,
250
- backgroundColor: "#fff",
251
- borderRadius: "14px",
252
- minWidth: "190px",
253
- boxShadow: "0 8px 32px rgba(0,0,0,0.28)",
254
- overflow: "hidden",
255
- padding: "6px 0",
256
- }}
257
- >
258
- {TIME_SLOTS.map((slot) => {
259
- const isActive = slot === selectedTimeSlot;
260
- return (
261
- <button
262
- key={slot}
263
- type="button"
264
- onClick={() => {
265
- onTimeSlotChange?.(slot);
266
- onTimeDropdownToggle?.(null);
267
- }}
268
- className={`flex w-full cursor-pointer items-center gap-[10px] border-none px-[12px] py-[9px] text-left text-[13px] ${isActive ? "bg-[#FF5C60] font-bold text-[white]" : "bg-transparent font-normal text-[#1a1a1a]"}`}
269
- >
270
- <span>{slot}</span>
271
- </button>
272
- );
273
- })}
274
- </div>
275
- </>
276
- )}
277
- </div>
278
- </div>
279
- </div>
280
- </div>
281
-
282
- <div className="border-t border-[#363c48] my-[8px]" />
283
-
284
- <div>
285
- <span
286
- className="block w-full text-[14px] bold-text text-[white] mb-[10px]"
287
- style={{ textAlign: "center" }}
288
- >
289
- {operatorsCompetingCount} operadores compitiendo <br />
290
- por tu compra
291
- </span>
292
- <div
293
- className="flex gap-[8px] text-[white]"
294
- style={{ width: "100%" }}
295
- >
296
- {operators.map((op, idx) => (
297
- <div
298
- key={idx}
299
- className="flex min-w-0 flex-col items-center justify-center gap-[8px] rounded-[8px]"
300
- style={{
301
- flex: 1,
302
- minWidth: 0,
303
- height: "100px",
304
- border: "1px solid #363c48",
305
- backgroundColor: "#1a202e",
306
- padding: "14px 6px",
307
- }}
308
- >
309
- <img
310
- src={op.logo}
311
- alt={op.name}
312
- onError={(e) => {
313
- e.currentTarget.src = serviceItem?.operator_details?.[0] || "/images/service-list/bus-icon.svg";
314
- }}
315
- className={`h-[24px] max-w-full object-contain ${isSoldOut ? "grayscale" : ""
316
- }`}
317
- />
318
- <span className="text-[12px] truncate max-w-full text-center ">
319
- {op.name}
320
- </span>
321
- {/* <div className="bg-[#FF8F45] text-[12px] font-bold px-[10px] py-[4px] rounded-[4px] bold-text whitespace-nowrap">
322
- <span>{op?.time}</span>
323
- </div> */}
324
- <span className="text-[11px] whitespace-nowrap">
325
- {op?.seatsAvailable}
326
- </span>
327
- </div>
328
- ))}
329
- </div>
330
-
331
- <div
332
- className="flex w-full items-center justify-center gap-[6px] text-[12px] mt-[12px]"
333
- style={{
334
- padding: "4px 14px",
335
- }}
336
- >
337
- <LottiePlayer
338
- animationData={serviceItem.icons.personsAnim}
339
- width="18px"
340
- height="18px"
341
- />
342
- <span>
343
- <span className="bold-text text-[white]">
344
- {" "}
345
- <span
346
- className="bold-text"
347
- ref={(node) =>
348
- commonService.startViewerCount(node, viewersConfig)
349
- }
350
- style={{
351
- fontVariantNumeric: "tabular-nums",
352
- color: "#FF5C60",
353
- }}
354
- />{" "}
355
- </span>{" "}
356
- <span style={{ color: "#FF5C60" }}>viendo</span>
357
- <span className="text-[white]"> |</span>{" "}
358
- <span
359
- className="bold-text text-[white]"
360
- ref={(node) =>
361
- commonService.startComprandoCount(node, 4, 16)
362
- }
363
- style={{ fontVariantNumeric: "tabular-nums" }}
364
- />{" "}
365
- <span className="text-[white]">han comprado</span>
366
- </span>
367
- </div>
368
-
369
- <div className="mt-[10px] flex flex-col items-center gap-[8px]">
370
- <span className="text-[12px] text-[white]">
371
- ¿Cuántos pasajes quieres?
372
- </span>
373
- <div
374
- className="flex w-[50%] items-center justify-between"
375
- style={{
376
- border: "1px solid #363c48",
377
- backgroundColor: "#1a202e",
378
- padding: "4px 14px",
379
- borderRadius: "14px",
380
- }}
381
- >
382
- <button
383
- type="button"
384
- aria-label="Disminuir pasajes"
385
- disabled={!canDecreaseTicketQuantity}
386
- onClick={() => onDecreaseTicketQuantity?.(serviceItem)}
387
- className={`flex h-[26px] w-[26px] items-center justify-center rounded-full border-none text-[16px] leading-none text-[white] ${canDecreaseTicketQuantity
388
- ? "cursor-pointer bg-[#2d374d]"
389
- : "cursor-not-allowed bg-[#222b3d] opacity-50"
390
- }`}
391
- >
392
- -
393
- </button>
394
- <span className="bold-text text-[14px] text-[white]">
395
- {ticketQuantity}
396
- </span>
397
- <button
398
- type="button"
399
- aria-label="Aumentar pasajes"
400
- onClick={() => onIncreaseTicketQuantity?.(serviceItem)}
401
- className="flex h-[26px] w-[26px] cursor-pointer items-center justify-center rounded-full border-none bg-[#2d374d] text-[16px] leading-none text-[white]"
402
- >
403
- +
404
- </button>
405
- </div>
406
- </div>
407
-
408
- <div
409
- className="mt-[10px] flex justify-between items-center rounded-[14px]"
410
- style={{
411
- // height: "80px",
412
- border: "1px solid #363c48",
413
- backgroundColor: "#1a202e",
414
- padding: "14px 10px",
415
- }}
416
- >
417
- <div className="flex flex-col">
418
- <span
419
- className="text-[18px] font-normal leading-[20px] text-[#9f9f9f] relative"
420
- style={{ position: "relative" }}
421
- >
422
- ${originalPrice.toLocaleString()}
423
- <span
424
- style={{
425
- position: "absolute",
426
- left: "-2px",
427
- top: "50%",
428
- width: "calc(80% + 4px)",
429
- height: "1px",
430
-
431
- backgroundColor: "#FF5C60",
432
-
433
- transform: "rotate(-10deg)",
434
- transformOrigin: "center",
435
- }}
436
- />
437
- </span>
438
- <span className="text-[white] bold-text text-[24px] leading-none mt-[4px]">
439
- {`$${(finalPrice * ticketQuantity).toLocaleString()}`}
440
- </span>
441
- </div>
442
- <span
443
- className="text-[#FF8F45] bold-text text-[22px] leading-tight"
444
- style={{
445
- animation: "pulse-zoom 2s ease-in-out infinite",
446
- whiteSpace: "nowrap",
447
- }}
448
- >
449
- {savingsPercent}% OFF
450
- </span>
451
- </div>
452
-
453
- <button
454
- type="button"
455
- onClick={onBookButtonPress}
456
- className="flex items-center gap-[6px] px-[20px] py-[10px] rounded-[16px] text-[white] bold-text text-[13px] mt-[10px] justify-center border-none cursor-pointer"
457
- style={{
458
- backgroundColor: "#FF5C60",
459
- whiteSpace: "nowrap",
460
- width: "100%",
461
- }}
462
- >
463
- <LottiePlayer
464
- animationData={serviceItem.icons.thunderAnim}
465
- width="16px"
466
- height="16px"
467
- />
468
- <span className="whitespace-nowrap">¡Lo quiero!</span>
469
- </button>
470
-
471
- <div
472
- className="flex justify-end mt-[10px]"
473
- onClick={onToggleExpand}
474
- >
475
- <img
476
- src={serviceItem?.icons?.downArrow}
477
- alt="down arrow"
478
- className={`transition-transform duration-300 ease-in-out ${isItemExpanded ? "rotate-180" : ""}`}
479
- style={{
480
- width: "14px",
481
- height: "8px",
482
- filter: "brightness(0) invert(1)",
483
- marginRight: "2px",
484
- }}
485
- />
486
- </div>
487
- </div>
488
- </div>
489
- </div>
490
-
491
- {isItemExpanded && (
492
- <div
493
- className="flex flex-col gap-[10px]"
494
- style={{
495
- opacity: isItemExpanded ? 1 : 0,
496
- transition: "opacity 250ms ease-in-out",
497
- }}
498
- >
499
- <div
500
- className={` text-[12px] ${isItemExpanded ? "pt-[14px] pb-[6px]" : "py-0"
501
- }`}
502
- style={{ transition: "padding 300ms ease-in-out" }}
503
- >
504
- <span className="bold-text">¿Cómo funciona?</span>
505
-
506
- <div className="flex flex-col">
507
- {HOW_IT_WORKS_STEPS.map((step) => (
508
- <div className="flex items-start gap-[8px] mt-[10px]">
509
- <div>
510
- <FeatureStepIcon icon={step.icon} />
511
- </div>
512
- <div className="flex flex-col">
513
- <span className="bold-text">{step.name}</span>
514
- <span>{step.text}</span>
515
- </div>
516
- </div>
517
- ))}
518
- </div>
519
- </div>
520
- </div>
521
- )}
522
- </div>
523
-
524
- {/* TOP BADGE — "Remate | Termina en 09:55 min" hardcoded, no countdown hook */}
525
- <div className="absolute -top-[13px] left-0 w-full flex items-center justify-center gap-[12px] z-10 ">
526
- <div className="flex items-center gap-[6px] py-[5px] px-[14px] rounded-[38px] text-[12.5px] bg-[#FF8F45] text-white whitespace-nowrap">
527
- <span className="flex items-center">
528
- <div className="mb-[2px]">
529
- <LottiePlayer
530
- animationData={flameAnimation}
531
- width="16px"
532
- height="16px"
533
- />
534
- </div>
535
- <span className="bold-text text-[white] ml-[3px]">
536
- Remate&nbsp;
537
- </span>{" "}
538
- <span className="text-[white]">términa en</span>{" "}
539
- <span
540
- className="bold-text text-end"
541
- ref={(node) => commonService.startCountdown(node, getCountdownSeconds())}
542
- style={{
543
- fontVariantNumeric: "tabular-nums",
544
- display: "inline-block",
545
- color: "#fff",
546
- minWidth: "40px",
547
- }}
548
- />
549
- </span>
550
- </div>
551
- </div>
552
- </div>
553
- );
554
- };
555
-
556
- export default FeatureServiceUiMobile;