From a8882e720cefa801744d0a7d41ae509cf2cbbada Mon Sep 17 00:00:00 2001 From: prachigarg19 <72646230+prachigarg19@users.noreply.github.com> Date: Tue, 17 Jan 2023 21:02:34 +0530 Subject: [PATCH 1/2] fix: error while changing country --- src/Utils/stripe/stripeHelpers.tsx | 49 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/Utils/stripe/stripeHelpers.tsx b/src/Utils/stripe/stripeHelpers.tsx index 1b0aaf79..d75a7e52 100644 --- a/src/Utils/stripe/stripeHelpers.tsx +++ b/src/Utils/stripe/stripeHelpers.tsx @@ -1,37 +1,38 @@ -import AmexIcon from '../../../public/assets/icons/CreditCardIcons/AmexIcon'; -import DinersClub from '../../../public/assets/icons/CreditCardIcons/DinersClub'; -import DiscoverIcon from '../../../public/assets/icons/CreditCardIcons/DiscoverIcon'; -import JcbIcon from '../../../public/assets/icons/CreditCardIcons/JcbIcon'; -import Mastercard from '../../../public/assets/icons/CreditCardIcons/Mastercard'; -import StripeIcon from '../../../public/assets/icons/CreditCardIcons/StripeIcon'; -import VisaIcon from '../../../public/assets/icons/CreditCardIcons/VisaIcon'; +import AmexIcon from "../../../public/assets/icons/CreditCardIcons/AmexIcon"; +import DinersClub from "../../../public/assets/icons/CreditCardIcons/DinersClub"; +import DiscoverIcon from "../../../public/assets/icons/CreditCardIcons/DiscoverIcon"; +import JcbIcon from "../../../public/assets/icons/CreditCardIcons/JcbIcon"; +import Mastercard from "../../../public/assets/icons/CreditCardIcons/Mastercard"; +import StripeIcon from "../../../public/assets/icons/CreditCardIcons/StripeIcon"; +import VisaIcon from "../../../public/assets/icons/CreditCardIcons/VisaIcon"; export function formatAmountForDisplay( amount: number, - currency: string, + currency: string ): string { - const numberFormat = new Intl.NumberFormat(['en-US'], { - style: 'currency', + const numberFormat = new Intl.NumberFormat(["en-US"], { + style: "currency", currency, - currencyDisplay: 'symbol', + currencyDisplay: "symbol", }); return numberFormat.format(amount); } export function formatAmountForStripe( amount: number, - currency: string, + currency: string ): number { - const numberFormat = new Intl.NumberFormat(['en-US'], { - style: 'currency', + const numberFormat = new Intl.NumberFormat(["en-US"], { + style: "currency", currency, - currencyDisplay: 'symbol', + currencyDisplay: "symbol", + maximumSignificantDigits: 21, }); const parts = numberFormat.formatToParts(amount); let zeroDecimalCurrency = true; parts.forEach((part) => { - if (part.type === 'decimal') { + if (part.type === "decimal") { zeroDecimalCurrency = false; } }); @@ -40,21 +41,21 @@ export function formatAmountForStripe( export const getCardBrand = (brand: String) => { switch (brand) { - case 'visa': + case "visa": return ; - case 'mastercard': + case "mastercard": return ; - case 'amex': + case "amex": return ; - case 'discover': + case "discover": return ; - case 'diners': + case "diners": return ; - case 'jcb': + case "jcb": return ; - case 'unionpay': + case "unionpay": return ; - case 'unknown': + case "unknown": return ; default: return ; From 4c7b72e86ecf2ae7e39b304f01bb17a484059daf Mon Sep 17 00:00:00 2001 From: prachigarg19 <72646230+prachigarg19@users.noreply.github.com> Date: Fri, 27 Jan 2023 17:48:54 +0530 Subject: [PATCH 2/2] refactor: resolve es lint errors --- src/Utils/stripe/stripeHelpers.tsx | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Utils/stripe/stripeHelpers.tsx b/src/Utils/stripe/stripeHelpers.tsx index f483b2f2..572462d6 100644 --- a/src/Utils/stripe/stripeHelpers.tsx +++ b/src/Utils/stripe/stripeHelpers.tsx @@ -1,4 +1,3 @@ - import { ReactElement } from "react"; import AmexIcon from "../../../public/assets/icons/CreditCardIcons/AmexIcon"; import DinersClub from "../../../public/assets/icons/CreditCardIcons/DinersClub"; @@ -44,21 +43,6 @@ export function formatAmountForStripe( export const getCardBrand = (brand: string): ReactElement => { switch (brand) { case "visa": - return ; - case "mastercard": - return ; - case "amex": - return ; - case "discover": - return ; - case "diners": - return ; - case "jcb": - return ; - case "unionpay": - return ; - case "unknown": - return ; return ; case "mastercard": return ;