kupos-ui-components-lib 10.2.0 → 10.2.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.
@@ -179,6 +179,7 @@ const renderSummaryDetailsCard = ({ serviceName, date, source, dest, boardingSta
179
179
  };
180
180
  const PaymentSideBarDesktop = ({ serviceNameOnward, serviceNameReturn, metaData, currencySign, dateOnward, dateReturn, sourceOnward, sourceReturn, destinationOnward, destinationReturn, boardingStageOnward, boardingStageReturn, droppingStageOnward, droppingStageReturn, boardingTimeOnward, boardingTimeReturn, droppingTimeOnward, droppingTimeReturn, durationOnward, durationReturn, selectSeatOnward, selectSeatReturn, journeyTypeActive, setJourneyTypeActive, translation, trainTypeOnward, trainTypeReturn, colors, trainType, icons, selectedOnward, selectedReturn, conexionChecked, conexionPassengers, returnConexionFare, conexionFare, loginData, checkWhatsappEligibility, removeDiscountAtomValue, netFare, promoCode, onPromoRemove, isAgency, agencyFee, walletMoney, virtualMoney, virtualLimit, showUsd, netFareInUsd, renderDiscount, discountAmount, walletLabel, creditosLabel, currency, customSideBarwidth, isLinatal, insuranceData, isPeru, serviceFeeDataStateValue, isOpsite, }) => {
181
181
  var _a, _b, _c, _d, _e;
182
+ console.log("🚀 ~ PaymentSideBarDesktop ~ walletMoney:", walletMoney);
182
183
  // REMOVED AM/PM DUPLICATION AND ADDED 24 HOUR TIME FORMAT IN BOARDING STAGE
183
184
  const depTime = droppingTimeOnward || "";
184
185
  const returnTime = droppingTimeReturn || "";
@@ -456,7 +457,9 @@ const PaymentSideBarDesktop = ({ serviceNameOnward, serviceNameReturn, metaData,
456
457
  React.createElement("div", { className: "duration-mouseover font9", style: { lineHeight: "1.3" } },
457
458
  React.createElement("span", null, translation === null || translation === void 0 ? void 0 : translation.serviceFeeHoverLabel)))), amount: CommonService.currency(serviceFeeDataStateValue === null || serviceFeeDataStateValue === void 0 ? void 0 : serviceFeeDataStateValue.total_convenience_fee_amount, currencySign), className: "font10", currency: currency, customStyle: { color: colors === null || colors === void 0 ? void 0 : colors.serviceFeePriceColor } })),
458
459
  isAgency && (React.createElement(PaymentItem, { label: translation === null || translation === void 0 ? void 0 : translation.agencyFee, amount: CommonService.currency(agencyFee ? agencyFee : 0, currencySign), currency: "", customStyle: { color: colors === null || colors === void 0 ? void 0 : colors.agencyFeePriceColor }, isBoldText: true })),
459
- walletMoney ? (React.createElement(PaymentItem, { label: walletLabel, amount: CommonService.currency(walletMoney, currencySign), currency: "", isBoldText: true })) : null,
460
+ walletMoney ? (React.createElement(PaymentItem, { label: walletLabel, amount: isPeru
461
+ ? CommonService.currencyFixed(walletMoney, currencySign)
462
+ : CommonService.currency(walletMoney, currencySign), currency: "", isBoldText: true })) : null,
460
463
  virtualMoney ? (React.createElement(PaymentItem, { label: React.createElement("span", { className: "secondary-text " }, `${creditosLabel}(${virtualLimit}%)`), amount: CommonService.currency(virtualMoney, currencySign), customStyle: { color: "var(--secondary-color)" }, currency: "", isBoldText: true })) : null,
461
464
  showUsd ? (React.createElement(PaymentItem, { label: React.createElement("span", { className: "secondary-text" }, translation === null || translation === void 0 ? void 0 : translation.showUsd), className: "text-[13.33px]", amount: CommonService.currency(isAgency ? netFareInUsd + agencyFee : netFareInUsd, currencySign), currency: "USD", customStyle: { color: "var(--secondary-color)" }, isBoldText: true })) : null),
462
465
  React.createElement("div", { className: ` text-white p-[10px_15px] text-left w-full flex items-center absolute -bottom-[35px] pt-[50px] -z-10 rounded-b-[14px] text-[14px]`, style: { backgroundColor: colors === null || colors === void 0 ? void 0 : colors.bottomStripColor } },
@@ -243,7 +243,9 @@ const PaymentSideBarMobile = ({ serviceNameOnward, serviceNameReturn, metaData,
243
243
  : conexionFare, currencySign), className: "subtotal-row text-[14px]", customStyle: { color: colors === null || colors === void 0 ? void 0 : colors.seatPriceColor }, isBoldText: true })) : null,
244
244
  removeDiscountAtomValue && (React.createElement(PaymentItem, { label: "Cup\u00F3n", amount: CommonService.currency(netFare, currencySign), isNegative: true, customStyle: { color: "var(--secondary-color)" }, className: "text-[14px]", isBoldText: true })),
245
245
  isAgency && (React.createElement(PaymentItem, { label: translation === null || translation === void 0 ? void 0 : translation.agencyFee, amount: CommonService.currency(agencyFee ? agencyFee : 0, currencySign), className: "text-[14px", customStyle: { color: colors === null || colors === void 0 ? void 0 : colors.agencyFeePriceColor }, isBoldText: true })),
246
- walletMoney ? (React.createElement(PaymentItem, { label: walletLabel, amount: CommonService.currency(walletMoney, currencySign), className: "text-[14px]", customStyle: { color: "var(--secondary-color)" }, currency: "", isBoldText: true })) : null,
246
+ walletMoney ? (React.createElement(PaymentItem, { label: walletLabel, amount: isPeru
247
+ ? CommonService.currencyFixed(walletMoney, currencySign)
248
+ : CommonService.currency(walletMoney, currencySign), className: "text-[14px]", customStyle: { color: "var(--secondary-color)" }, currency: "", isBoldText: true })) : null,
247
249
  virtualMoney ? (React.createElement(PaymentItem, { label: React.createElement("span", { className: "secondary-text", style: { color: "var(--secondary-color)" } }, `${creditosLabel}(${virtualLimit}%)`), amount: CommonService.currency(virtualMoney, currencySign), customStyle: { color: "var(--secondary-color)" }, className: "text-[14px]", currency: "", isBoldText: true })) : null,
248
250
  showUsd ? (React.createElement(PaymentItem, { label: React.createElement("span", { className: "primary-text" }, translation === null || translation === void 0 ? void 0 : translation.showUsd), amount: CommonService.currency(isAgency ? netFareInUsd + agencyFee : netFareInUsd, currencySign), currency: "USD", customStyle: { color: "var(--primary-color)" }, className: "text-[14px]", isBoldText: true })) : null)),
249
251
  React.createElement("div", { className: ` text-[#fff] p-[10px_15px] text-left w-full flex items-center absolute -bottom-[35px] pt-[50px] rounded-b-[14px] text-[14px]`, style: { backgroundColor: colors === null || colors === void 0 ? void 0 : colors.bottomStripColor } },
@@ -126,7 +126,7 @@ function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, o
126
126
  React.createElement("div", { className: "flex items-center justify-center gap-x-4", style: {
127
127
  marginBottom: (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) || hasDiscount ? "10px" : "",
128
128
  } },
129
- React.createElement("div", { className: `w-[auto] ${isFlores ? "" : "overflow-y-hidden"} h-[30px]` },
129
+ React.createElement("div", { className: `w-[115px] ${isFlores ? "" : "overflow-y-hidden"} h-[30px]` },
130
130
  React.createElement("img", { src: serviceItem.operator_details[0], alt: "service logo", className: `w-[100px] h-auto object-contain ${isSoldOut ? "grayscale" : ""}` })),
131
131
  isCiva ? (React.createElement("div", { className: "black-text min-[420]:text-[12px] text-[12px]" }, serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_details[2])) : showRating ? (React.createElement("div", { className: "flex min-[420]:text-[13px] text-[12px] h-[22px] items-center" },
132
132
  React.createElement("div", { className: "flex items-center" },
package/dist/styles.css CHANGED
@@ -474,6 +474,9 @@
474
474
  .w-\[100px\] {
475
475
  width: 100px;
476
476
  }
477
+ .w-\[115px\] {
478
+ width: 115px;
479
+ }
477
480
  .w-\[150px\] {
478
481
  width: 150px;
479
482
  }
@@ -71,7 +71,6 @@ const AmenitiesBlock = ({ serviceItem, metaData, isSoldOut, colors, isPeru, getA
71
71
  amenities,
72
72
  priorityIds,
73
73
  });
74
- console.log("🚀 ~ AmenitiesBlock ~ visibleAmenities:", visibleAmenities, amenities);
75
74
  const shouldShowPlus = plusAmenities.length > 0;
76
75
  const grayscaleClass = isSoldOut ? "grayscale" : "";
77
76
  return (React.createElement("div", { className: "relative flex items-center gap-[6px]" },
@@ -1,5 +1,6 @@
1
1
  declare const commonService: {
2
2
  currency(amount: number, currencySign?: string): string;
3
+ currencyFixed(amount: number, currencySign?: string, decimals?: number): string;
3
4
  currencyRounded(amount: number, currencySign?: string): string;
4
5
  discountedCurrency(amount: number, currencySign?: string): string;
5
6
  copyObject: (ob: any) => any;
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Fixes floating-point precision artifacts (e.g. 3546.1500000000005 → 3546.15)
3
+ * by rounding to the given number of decimal places.
4
+ */
5
+ const fixFloatPrecision = (amount, decimals = 2) => {
6
+ return parseFloat(amount.toFixed(decimals));
7
+ };
1
8
  const commonService = {
2
9
  currency(amount, currencySign) {
3
10
  const formattedAmount = amount
@@ -6,6 +13,13 @@ const commonService = {
6
13
  const sign = currencySign || "$";
7
14
  return sign + formattedAmount;
8
15
  },
16
+ currencyFixed(amount, currencySign, decimals = 2) {
17
+ const formattedAmount = fixFloatPrecision(amount, decimals)
18
+ .toString()
19
+ .replace(/\B(?=(\d{3})+(?!\d))/g, ".");
20
+ const sign = currencySign || "$";
21
+ return sign + formattedAmount;
22
+ },
9
23
  currencyRounded(amount, currencySign) {
10
24
  const formattedAmount = Math.round(amount)
11
25
  .toString()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "10.2.0",
3
+ "version": "10.2.2",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -339,6 +339,7 @@ const PaymentSideBarDesktop: React.FC<PaymentSideBarProps> = ({
339
339
  serviceFeeDataStateValue,
340
340
  isOpsite,
341
341
  }) => {
342
+ console.log("🚀 ~ PaymentSideBarDesktop ~ walletMoney:", walletMoney);
342
343
  // REMOVED AM/PM DUPLICATION AND ADDED 24 HOUR TIME FORMAT IN BOARDING STAGE
343
344
  const depTime = droppingTimeOnward || "";
344
345
  const returnTime = droppingTimeReturn || "";
@@ -860,7 +861,11 @@ const PaymentSideBarDesktop: React.FC<PaymentSideBarProps> = ({
860
861
  {walletMoney ? (
861
862
  <PaymentItem
862
863
  label={walletLabel}
863
- amount={CommonService.currency(walletMoney, currencySign)}
864
+ amount={
865
+ isPeru
866
+ ? CommonService.currencyFixed(walletMoney, currencySign)
867
+ : CommonService.currency(walletMoney, currencySign)
868
+ }
864
869
  currency=""
865
870
  isBoldText={true}
866
871
  />
@@ -666,7 +666,11 @@ const PaymentSideBarMobile: React.FC<PaymentSideBarProps> = ({
666
666
  {walletMoney ? (
667
667
  <PaymentItem
668
668
  label={walletLabel}
669
- amount={CommonService.currency(walletMoney, currencySign)}
669
+ amount={
670
+ isPeru
671
+ ? CommonService.currencyFixed(walletMoney, currencySign)
672
+ : CommonService.currency(walletMoney, currencySign)
673
+ }
670
674
  className="text-[14px]"
671
675
  customStyle={{ color: "var(--secondary-color)" }}
672
676
  currency=""
@@ -266,7 +266,7 @@ function ServiceItemMobile({
266
266
  }}
267
267
  >
268
268
  <div
269
- className={`w-[auto] ${isFlores ? "" : "overflow-y-hidden"} h-[30px]`}
269
+ className={`w-[115px] ${isFlores ? "" : "overflow-y-hidden"} h-[30px]`}
270
270
  >
271
271
  <img
272
272
  src={serviceItem.operator_details[0]}
@@ -108,11 +108,6 @@ const AmenitiesBlock = ({
108
108
  amenities,
109
109
  priorityIds,
110
110
  });
111
- console.log(
112
- "🚀 ~ AmenitiesBlock ~ visibleAmenities:",
113
- visibleAmenities,
114
- amenities,
115
- );
116
111
 
117
112
  const shouldShowPlus = plusAmenities.length > 0;
118
113
  const grayscaleClass = isSoldOut ? "grayscale" : "";
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Fixes floating-point precision artifacts (e.g. 3546.1500000000005 → 3546.15)
3
+ * by rounding to the given number of decimal places.
4
+ */
5
+ const fixFloatPrecision = (amount: number, decimals: number = 2): number => {
6
+ return parseFloat(amount.toFixed(decimals));
7
+ };
8
+
1
9
  const commonService = {
2
10
  currency(amount: number, currencySign?: string) {
3
11
  const formattedAmount = amount
@@ -8,6 +16,15 @@ const commonService = {
8
16
  return sign + formattedAmount;
9
17
  },
10
18
 
19
+ currencyFixed(amount: number, currencySign?: string, decimals: number = 2) {
20
+ const formattedAmount = fixFloatPrecision(amount, decimals)
21
+ .toString()
22
+ .replace(/\B(?=(\d{3})+(?!\d))/g, ".");
23
+
24
+ const sign = currencySign || "$";
25
+ return sign + formattedAmount;
26
+ },
27
+
11
28
  currencyRounded(amount: number, currencySign?: string) {
12
29
  const formattedAmount = Math.round(amount)
13
30
  .toString()