kupos-ui-components-lib 10.2.1 → 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.
- package/dist/components/PaymentSideBar/PaymentSideBarDesktop.js +4 -1
- package/dist/components/PaymentSideBar/PaymentSideBarMobile.js +3 -1
- package/dist/ui/AmenitiesBlock.js +0 -1
- package/dist/utils/CommonService.d.ts +1 -0
- package/dist/utils/CommonService.js +14 -0
- package/package.json +1 -1
- package/src/components/PaymentSideBar/PaymentSideBarDesktop.tsx +6 -1
- package/src/components/PaymentSideBar/PaymentSideBarMobile.tsx +5 -1
- package/src/ui/AmenitiesBlock.tsx +0 -5
- package/src/utils/CommonService.ts +17 -0
|
@@ -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:
|
|
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:
|
|
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 } },
|
|
@@ -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
|
@@ -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={
|
|
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={
|
|
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=""
|
|
@@ -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()
|