kupos-ui-components-lib 9.7.7 → 9.7.8

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