kupos-ui-components-lib 9.6.2 → 9.6.3

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.
@@ -409,6 +409,12 @@ function ServiceItemPB({
409
409
  isPeru={isPeru}
410
410
  siteType={siteType}
411
411
  isAllinBus={isAllinBus}
412
+ viewersConfig={viewersConfig}
413
+ isLoggedIn={isLoggedIn}
414
+ showLoginModal={showLoginModal}
415
+ isExpand={isExpand}
416
+ setIsExpand={setIsExpand}
417
+ coachKey={coachKey}
412
418
  />
413
419
  ) : (
414
420
  <div
@@ -518,6 +524,7 @@ function ServiceItemPB({
518
524
  removeDuplicateSeats={removeDuplicateSeats}
519
525
  isPeru={isPeru}
520
526
  renderIcon={renderIcon}
527
+ discountSeatPriceColor={colors.discountSeatPriceColor}
521
528
  />
522
529
  </div>
523
530
 
@@ -269,7 +269,7 @@ function ServiceItemMobile({
269
269
  color: colors.tooltipBgColor,
270
270
  }}
271
271
  >
272
- ¡ Últimos Asientos!
272
+ ¡Últimos Asientos!
273
273
  </div>
274
274
  )}
275
275
  </div>
@@ -480,7 +480,7 @@ function ServiceItemMobile({
480
480
  <span className="bold-text">personas</span>{" "}
481
481
  <span>
482
482
  {" "}
483
- {viewersConfig.label || " están viendo este viaje"}
483
+ {viewersConfig?.label || " están viendo este viaje"}
484
484
  </span>
485
485
  </span>
486
486
  </div>
@@ -129,6 +129,7 @@ export interface ServiceItemProps {
129
129
  downArrow?:string
130
130
  personIcon?: string
131
131
  whiteFireIcon?: string
132
+ fireIcon?: string
132
133
 
133
134
  [key: string]: string | Record<string, string | undefined> | undefined;
134
135
  };
@@ -159,6 +160,7 @@ export interface ServiceItemProps {
159
160
  seatPriceColor?: string;
160
161
  rightGradiantColor?: string;
161
162
  leftGradiantColor?: string;
163
+ discountSeatPriceColor?: string
162
164
  };
163
165
  cityOrigin?: { value: number; label: string };
164
166
  cityDestination?: { value: number; label: string };
@@ -20,6 +20,7 @@ interface SeatSectionProps {
20
20
  isPeru?: boolean;
21
21
  serviceItem?: any;
22
22
  renderIcon?: (iconKey: string, size?: string) => React.ReactNode;
23
+ discountSeatPriceColor?: string;
23
24
  }
24
25
 
25
26
  function getAllSeatTypes(seatTypes: SeatType[]) {
@@ -100,6 +101,7 @@ function SeatSection({
100
101
  serviceItem,
101
102
  renderIcon,
102
103
  dpSeatColor,
104
+ discountSeatPriceColor,
103
105
  }: SeatSectionProps): React.ReactElement {
104
106
  const uniqueSeats = getUniqueSeats(seatTypes);
105
107
  const sortedSeatTypes = getSortedSeatTypes(seatTypes);
@@ -193,11 +195,23 @@ function SeatSection({
193
195
  .filter((seat) => !SEAT_EXCEPTIONS.includes(seat.label))
194
196
  .sort((a, b) => a.discountedPrice - b.discountedPrice)[0];
195
197
 
196
- const discountValue =
197
- serviceItem?.discount_type === "percentage" &&
198
- typeof serviceItem?.discount_value === "number"
199
- ? Math.round(serviceItem.discount_value)
200
- : null;
198
+ const discountValue = (() => {
199
+ if (
200
+ serviceItem?.discount_type === "percentage" &&
201
+ typeof serviceItem?.discount_value === "number"
202
+ ) {
203
+ return Math.round(serviceItem.discount_value);
204
+ }
205
+ if (serviceItem?.discount_type === "fixed" && discountSeat) {
206
+ const { originalPrice, discountedPrice } = discountSeat;
207
+ if (originalPrice > 0 && originalPrice !== discountedPrice) {
208
+ return Math.round(
209
+ ((originalPrice - discountedPrice) / originalPrice) * 100,
210
+ );
211
+ }
212
+ }
213
+ return null;
214
+ })();
201
215
 
202
216
  const renderLabels = () => {
203
217
  if (isPeru) {
@@ -411,6 +425,7 @@ function SeatSection({
411
425
  style={{
412
426
  animation: "pulse-zoom 2s ease-in-out infinite",
413
427
  whiteSpace: "nowrap",
428
+ backgroundColor: discountSeatPriceColor,
414
429
  }}
415
430
  >
416
431
  {discountValue}% OFF
@@ -447,7 +462,7 @@ function SeatSection({
447
462
  <div className="col-start-2 row-start-3 flex h-[30px] items-end justify-center relative">
448
463
  <span
449
464
  className="flex items-center gap-[6px] text-[22px] bold-text leading-[30px]"
450
- style={{ color: isSoldOut ? "#c0c0c0" : "#ff5964" }}
465
+ style={{ color: isSoldOut ? "#c0c0c0" : discountSeatPriceColor }}
451
466
  >
452
467
  {/* <span className="text-[18px] leading-[24px]">🔥</span> */}
453
468
  <div
@@ -117,6 +117,7 @@ function SeatSectionMobile({
117
117
  tooltipBgColor,
118
118
  showLastSeats,
119
119
  }: SeatSectionMobileProps): React.ReactElement {
120
+ console.log("🚀 ~ SeatSectionMobile ~ serviceItem:", serviceItem);
120
121
  const hasMultipleTypes = (seatTypesData?.length ?? 0) > 2;
121
122
 
122
123
  const getFare = (fare: number) => {
@@ -243,7 +244,7 @@ function SeatSectionMobile({
243
244
  {commonService.currency(discountedPrice, currencySign)}
244
245
  </span>
245
246
  </div>
246
- {showLastSeats ? (
247
+ {/* {showLastSeats ? (
247
248
  <div className="flex justify-end">
248
249
  {serviceItem?.available_seats < 10 &&
249
250
  serviceItem?.available_seats > 0 && (
@@ -257,7 +258,7 @@ function SeatSectionMobile({
257
258
  </div>
258
259
  )}
259
260
  </div>
260
- ) : null}
261
+ ) : null} */}
261
262
  {isSoldOut ? (
262
263
  <div className="flex justify-end">
263
264
  <span
@@ -303,15 +303,20 @@ const commonService = {
303
303
 
304
304
  const { discount_type, discount_value, max_discount } = serviceItem;
305
305
 
306
+ const fixedDiscount =
307
+ discount_type === "fixed" && discount_value != null ? discount_value : 0;
308
+
306
309
  const percentageDiscount =
307
310
  discount_type === "percentage" && discount_value != null
308
311
  ? (price * discount_value) / 100
309
312
  : 0;
310
313
 
314
+ const rawDiscount = fixedDiscount || percentageDiscount;
315
+
311
316
  const finalDiscount =
312
317
  max_discount != null && max_discount > 0
313
- ? Math.min(percentageDiscount, max_discount)
314
- : percentageDiscount;
318
+ ? Math.min(rawDiscount, max_discount)
319
+ : rawDiscount;
315
320
 
316
321
  const discountedPrice = Math.max(0, price - finalDiscount);
317
322