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