From 99e0b3b7e52b340925d5c4a234e7de4cceb4553c Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:24:14 +0530 Subject: [PATCH 1/3] chore: update @planet-sdk/common to version 0.1.47 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1bd5fb0b..9560f835 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@mui/material": "^5.11.8", "@next/bundle-analyzer": "^10.1.3", "@paypal/react-paypal-js": "^7.8.2", - "@planet-sdk/common": "^0.1.42", + "@planet-sdk/common": "^0.1.47", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", @@ -1812,9 +1812,9 @@ "dev": true }, "node_modules/@planet-sdk/common": { - "version": "0.1.42", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.42.tgz", - "integrity": "sha512-C8rV0i3P9YyAUQlldFT91JxVpUX5rQcmKMB9IDqLKKByJ8794GTiL2y+zaJixBB1UnG/4isqyyPXTE2m1zomYg==", + "version": "0.1.47", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.47.tgz", + "integrity": "sha512-ISmU8nr5k2xg1YLE4gk9vaCbCEnioA5Eoy6D2ad2X+RFxCdi2OA9xjG8bUvlHuG99yQ4WJxYCb3BlVXHdKga+g==", "dependencies": { "@types/geojson": "^7946.0.10" } @@ -10431,9 +10431,9 @@ } }, "@planet-sdk/common": { - "version": "0.1.42", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.42.tgz", - "integrity": "sha512-C8rV0i3P9YyAUQlldFT91JxVpUX5rQcmKMB9IDqLKKByJ8794GTiL2y+zaJixBB1UnG/4isqyyPXTE2m1zomYg==", + "version": "0.1.47", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.47.tgz", + "integrity": "sha512-ISmU8nr5k2xg1YLE4gk9vaCbCEnioA5Eoy6D2ad2X+RFxCdi2OA9xjG8bUvlHuG99yQ4WJxYCb3BlVXHdKga+g==", "requires": { "@types/geojson": "^7946.0.10" } diff --git a/package.json b/package.json index 02ab2ac6..3a3dd5a1 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@mui/material": "^5.11.8", "@next/bundle-analyzer": "^10.1.3", "@paypal/react-paypal-js": "^7.8.2", - "@planet-sdk/common": "^0.1.42", + "@planet-sdk/common": "^0.1.47", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", From 71554b5c6e2704554539a3d5f6a542c89725a502 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:28:06 +0530 Subject: [PATCH 2/3] fix: correct typos for getFormattedCurrency / getFormattedCurrencySymbol --- src/Donations/Components/ContactsForm.tsx | 4 ++-- src/Donations/Components/DonationsForm.tsx | 10 +++++----- src/Donations/Components/PaymentsForm.tsx | 4 ++-- src/Donations/LeftPanel/TransactionSummary.tsx | 4 ++-- src/Donations/Micros/DonationAmount.tsx | 4 ++-- .../Micros/DonationTypes/BouquetDonations.tsx | 10 +++++----- .../Micros/DonationTypes/FundingDonations.tsx | 8 ++++---- src/Donations/Micros/DonationTypes/TreeDonation.tsx | 4 ++-- src/Donations/Micros/PaymentStatus/ImageComponent.tsx | 3 +-- src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx | 4 ++-- src/Donations/Micros/PaymentStatus/TransferDetails.tsx | 4 ++-- src/Donations/Micros/PlanetCashSelector.tsx | 8 ++++---- src/Donations/PaymentMethods/PaymentMethodTabs.tsx | 8 ++++---- src/Utils/getFormattedCurrency.ts | 4 ++-- 14 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/Donations/Components/ContactsForm.tsx b/src/Donations/Components/ContactsForm.tsx index 069ac3d5..eccccaf0 100644 --- a/src/Donations/Components/ContactsForm.tsx +++ b/src/Donations/Components/ContactsForm.tsx @@ -12,7 +12,7 @@ import themeProperties from "../../../styles/themeProperties"; import { ThemeContext } from "../../../styles/themeContext"; import { useAuth0 } from "@auth0/auth0-react"; import { useRouter } from "next/router"; -import getFormatedCurrency from "src/Utils/getFormattedCurrency"; +import getFormattedCurrency from "src/Utils/getFormattedCurrency"; import { DONATE, PAYMENT } from "src/Utils/donationStepConstants"; import { ContactDetails } from "@planet-sdk/common"; import { AddressCandidate, GeocodeSuggestion } from "src/Common/Types/arcgis"; @@ -588,7 +588,7 @@ function ContactsForm(): ReactElement { > {paymentSetup && t("donate_button", { - totalCost: getFormatedCurrency( + totalCost: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity diff --git a/src/Donations/Components/DonationsForm.tsx b/src/Donations/Components/DonationsForm.tsx index 188ade15..6545d04b 100644 --- a/src/Donations/Components/DonationsForm.tsx +++ b/src/Donations/Components/DonationsForm.tsx @@ -2,7 +2,7 @@ import React, { ReactElement } from "react"; import { QueryParamContext } from "../../Layout/QueryParamContext"; import GiftForm from "../Micros/GiftForm"; import { useTranslation } from "next-i18next"; -import getFormatedCurrency from "../../Utils/getFormattedCurrency"; +import getFormattedCurrency from "../../Utils/getFormattedCurrency"; import { getMinimumAmountForCurrency } from "../../Utils/getExchange"; import { formatAmountForStripe } from "../../Utils/stripe/stripeHelpers"; import { NativePay } from "../PaymentMethods/PaymentRequestCustomButton"; @@ -257,7 +257,7 @@ function DonationsForm(): ReactElement { break; case "funds": paymentLabel = t("fundingPaymentLabel", { - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity @@ -266,7 +266,7 @@ function DonationsForm(): ReactElement { break; case "planet-cash": paymentLabel = t("pcashPaymentLabel", { - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity @@ -276,7 +276,7 @@ function DonationsForm(): ReactElement { case "bouquet": case "conservation": paymentLabel = t("bouquetPaymentLabel", { - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity @@ -466,7 +466,7 @@ function DonationsForm(): ReactElement {

{t("minDonate")}{" "} - {getFormatedCurrency(i18n.language, currency, minAmt)} + {getFormattedCurrency(i18n.language, currency, minAmt)}

) : ( diff --git a/src/Donations/Components/PaymentsForm.tsx b/src/Donations/Components/PaymentsForm.tsx index 5e26c6d1..4a18229f 100644 --- a/src/Donations/Components/PaymentsForm.tsx +++ b/src/Donations/Components/PaymentsForm.tsx @@ -7,7 +7,7 @@ import { apiRequest } from "../../Utils/api"; import PaymentProgress from "../../Common/ContentLoaders/Donations/PaymentProgress"; import { Elements } from "@stripe/react-stripe-js"; import getStripe from "../../Utils/stripe/getStripe"; -import getFormatedCurrency from "../../Utils/getFormattedCurrency"; +import getFormattedCurrency from "../../Utils/getFormattedCurrency"; import { createDonationFunction, payDonationFunction, @@ -419,7 +419,7 @@ function PaymentsForm(): ReactElement { {t("donating")}{" "} - {getFormatedCurrency( + {getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity diff --git a/src/Donations/Micros/DonationAmount.tsx b/src/Donations/Micros/DonationAmount.tsx index 454837a1..bc999855 100644 --- a/src/Donations/Micros/DonationAmount.tsx +++ b/src/Donations/Micros/DonationAmount.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from "react"; import { QueryParamContext } from "../../Layout/QueryParamContext"; -import getFormatedCurrency from "../../Utils/getFormattedCurrency"; +import getFormattedCurrency from "../../Utils/getFormattedCurrency"; import { getFormattedNumber } from "../../Utils/getFormattedNumber"; import TreeCostLoader from "../../Common/ContentLoaders/TreeCostLoader"; import { useTranslation } from "next-i18next"; @@ -15,7 +15,7 @@ function DonationAmount(): ReactElement { {paymentSetup && paymentSetup.unitCost ? (
- {getFormatedCurrency( + {getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity diff --git a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx index ed3ce57e..2395a69f 100644 --- a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx +++ b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx @@ -8,8 +8,8 @@ import React, { import { useTranslation } from "next-i18next"; import { QueryParamContext } from "../../../Layout/QueryParamContext"; import themeProperties from "../../../../styles/themeProperties"; -import getFormatedCurrency, { - getFormatedCurrencySymbol, +import getFormattedCurrency, { + getFormattedCurrencySymbol, } from "../../../Utils/getFormattedCurrency"; import DownArrowIcon from "../../../../public/assets/icons/DownArrowIcon"; import TreeCostLoader from "../../../Common/ContentLoaders/TreeCostLoader"; @@ -160,7 +160,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { {paymentSetup.purpose === "conservation" ? option.quantity - : getFormatedCurrency( + : getFormattedCurrency( i18n.language, currency, option.quantity * paymentSetup.unitCost @@ -193,7 +193,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { }} > {paymentSetup.purpose === "bouquet" - ? getFormatedCurrencySymbol(currency) + ? getFormattedCurrencySymbol(currency) : []}

)} {paymentSetup.purpose === "conservation" - ? getFormatedCurrency( + ? getFormattedCurrency( i18n.language, "", Number(paymentSetup.unitCost) diff --git a/src/Donations/Micros/DonationTypes/FundingDonations.tsx b/src/Donations/Micros/DonationTypes/FundingDonations.tsx index 062359da..de696880 100644 --- a/src/Donations/Micros/DonationTypes/FundingDonations.tsx +++ b/src/Donations/Micros/DonationTypes/FundingDonations.tsx @@ -7,8 +7,8 @@ import React, { import { useTranslation } from "next-i18next"; import { QueryParamContext } from "../../../Layout/QueryParamContext"; import themeProperties from "../../../../styles/themeProperties"; -import getFormatedCurrency, { - getFormatedCurrencySymbol, +import getFormattedCurrency, { + getFormattedCurrencySymbol, } from "../../../Utils/getFormattedCurrency"; import DownArrowIcon from "../../../../public/assets/icons/DownArrowIcon"; import TreeCostLoader from "../../../Common/ContentLoaders/TreeCostLoader"; @@ -164,7 +164,7 @@ function FundingDonations({ setopenCurrencyModal }: Props): ReactElement { fontSize: option.caption ? "14px" : "18px", }} > - {getFormatedCurrency( + {getFormattedCurrency( i18n.language, currency, option.quantity * paymentSetup.unitCost @@ -195,7 +195,7 @@ function FundingDonations({ setopenCurrencyModal }: Props): ReactElement { marginTop: "3px", }} > - {getFormatedCurrencySymbol(currency)} + {getFormattedCurrencySymbol(currency)}

)} - {getFormatedCurrency( + {getFormattedCurrency( i18n.language, "", Number(paymentSetup.unitCost) diff --git a/src/Donations/Micros/PaymentStatus/ImageComponent.tsx b/src/Donations/Micros/PaymentStatus/ImageComponent.tsx index 382ca014..42c6e24c 100644 --- a/src/Donations/Micros/PaymentStatus/ImageComponent.tsx +++ b/src/Donations/Micros/PaymentStatus/ImageComponent.tsx @@ -1,7 +1,6 @@ import React, { ReactElement, RefObject } from "react"; import { useTranslation } from "next-i18next"; import { getFormattedNumber } from "src/Utils/getFormattedNumber"; -import getFormatedCurrency from "src/Utils/getFormattedCurrency"; import getFormattedCurrency from "src/Utils/getFormattedCurrency"; import { QueryParamContext } from "src/Layout/QueryParamContext"; import { FetchedProjectDetails } from "src/Common/Types"; @@ -24,7 +23,7 @@ const ImageComponent = ({ let currencyFormat = () => {}; if (donation) { currencyFormat = () => - getFormatedCurrency(i18n.language, donation.currency, donation.amount); + getFormattedCurrency(i18n.language, donation.currency, donation.amount); } const pluralProfileTypes = [ diff --git a/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx b/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx index 300ee601..975ac5fd 100644 --- a/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx +++ b/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from "react"; import { useTranslation } from "next-i18next"; -import getFormatedCurrency from "src/Utils/getFormattedCurrency"; +import getFormattedCurrency from "src/Utils/getFormattedCurrency"; import { getFormattedNumber } from "src/Utils/getFormattedNumber"; import { QueryParamContext } from "src/Layout/QueryParamContext"; import { FetchedProjectDetails } from "src/Common/Types"; @@ -22,7 +22,7 @@ function ThankyouMessage({ let currencyFormat = () => {}; if (donation) { currencyFormat = () => - getFormatedCurrency( + getFormattedCurrency( i18n.language, donation.currency, Number(donation.amount) diff --git a/src/Donations/Micros/PaymentStatus/TransferDetails.tsx b/src/Donations/Micros/PaymentStatus/TransferDetails.tsx index 8236578b..f8e44757 100644 --- a/src/Donations/Micros/PaymentStatus/TransferDetails.tsx +++ b/src/Donations/Micros/PaymentStatus/TransferDetails.tsx @@ -8,7 +8,7 @@ import ReturnToButton from "./Components/ReturnToButton"; import { Donation } from "@planet-sdk/common/build/types/donation"; import { ReactElement } from "react"; import { TFunction } from "next-i18next"; -import getFormatedCurrency from "src/Utils/getFormattedCurrency"; +import getFormattedCurrency from "src/Utils/getFormattedCurrency"; interface TransferDetailsProps { donationID: string; @@ -51,7 +51,7 @@ function TransferDetails({ ? t("common:transferDetailsMessage") : t("common:recurrentTransferDetailsMsg", { frequency, - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, donation.currency, donation.amount diff --git a/src/Donations/Micros/PlanetCashSelector.tsx b/src/Donations/Micros/PlanetCashSelector.tsx index 15cdeacb..c017f138 100644 --- a/src/Donations/Micros/PlanetCashSelector.tsx +++ b/src/Donations/Micros/PlanetCashSelector.tsx @@ -4,7 +4,7 @@ import { FC, useContext, useEffect } from "react"; import ToggleSwitch from "src/Common/InputTypes/ToggleSwitch"; import { QueryParamContext } from "src/Layout/QueryParamContext"; import { getCountryDataBy } from "src/Utils/countryUtils"; -import getFormatedCurrency from "src/Utils/getFormattedCurrency"; +import getFormattedCurrency from "src/Utils/getFormattedCurrency"; // TODO - Sentry captureException; @@ -144,7 +144,7 @@ const PlanetCashSelector: FC = () => { : "-negative") } > - {getFormatedCurrency( + {getFormattedCurrency( i18n.language, profile.planetCash.currency, profile.planetCash.balance / 100 @@ -163,7 +163,7 @@ const PlanetCashSelector: FC = () => { : "-negative") } > - {getFormatedCurrency( + {getFormattedCurrency( i18n.language, profile.planetCash.currency, profile.planetCash.creditLimit / 100 @@ -186,7 +186,7 @@ const PlanetCashSelector: FC = () => { : "-negative") } > - {getFormatedCurrency( + {getFormattedCurrency( i18n.language, profile.planetCash.currency, profile.planetCash.balance / 100 + diff --git a/src/Donations/PaymentMethods/PaymentMethodTabs.tsx b/src/Donations/PaymentMethods/PaymentMethodTabs.tsx index f60a22fd..84d98796 100644 --- a/src/Donations/PaymentMethods/PaymentMethodTabs.tsx +++ b/src/Donations/PaymentMethods/PaymentMethodTabs.tsx @@ -9,7 +9,7 @@ import BankIcon from "../../../public/assets/icons/donation/BankIcon"; import { QueryParamContext } from "../../Layout/QueryParamContext"; import { formatAmountForStripe } from "../../Utils/stripe/stripeHelpers"; import { NativePay } from "./PaymentRequestCustomButton"; -import getFormatedCurrency from "src/Utils/getFormattedCurrency"; +import getFormattedCurrency from "src/Utils/getFormattedCurrency"; import { PaymentMethod } from "@stripe/stripe-js/types/api/payment-methods"; import { PaymentRequest } from "@stripe/stripe-js/types/stripe-js/payment-request"; @@ -104,7 +104,7 @@ export default function PaymentMethodTabs({ break; case "funds": paymentLabel = t("fundingPaymentLabel", { - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity @@ -113,7 +113,7 @@ export default function PaymentMethodTabs({ break; case "planet-cash": paymentLabel = t("pcashPaymentLabel", { - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity @@ -123,7 +123,7 @@ export default function PaymentMethodTabs({ case "bouquet": case "conservation": paymentLabel = t("bouquetPaymentLabel", { - amount: getFormatedCurrency( + amount: getFormattedCurrency( i18n.language, currency, paymentSetup.unitCost * quantity diff --git a/src/Utils/getFormattedCurrency.ts b/src/Utils/getFormattedCurrency.ts index 9ae9dbc3..4d03165d 100644 --- a/src/Utils/getFormattedCurrency.ts +++ b/src/Utils/getFormattedCurrency.ts @@ -1,4 +1,4 @@ -export default function getFormatedCurrency( +export default function getFormattedCurrency( langCode: string, currency: string, number: number @@ -19,7 +19,7 @@ export default function getFormatedCurrency( return formatter.format(number); } -export function getFormatedCurrencySymbol( +export function getFormattedCurrencySymbol( currency: string ): string | undefined { let options: Intl.NumberFormatOptions = { From f2574c10ffdd9460f9b2ec8f891f39acb23379ec Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:58:54 +0530 Subject: [PATCH 3/3] refactor: minor refactors to address codefactor feedback - removes unnecessary `true &&...` expression - refactors onClick handler for currency selector in TreeDonations --- src/Donations/Components/ContactsForm.tsx | 44 +++++++++---------- .../Micros/DonationTypes/TreeDonation.tsx | 2 +- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/Donations/Components/ContactsForm.tsx b/src/Donations/Components/ContactsForm.tsx index eccccaf0..d54da170 100644 --- a/src/Donations/Components/ContactsForm.tsx +++ b/src/Donations/Components/ContactsForm.tsx @@ -401,29 +401,27 @@ function ContactsForm(): ReactElement {
- {true && ( - ( - - )} - /> - )} + ( + + )} + /> {errors.zipCode !== undefined && (
{errors.zipCode.message}
)} diff --git a/src/Donations/Micros/DonationTypes/TreeDonation.tsx b/src/Donations/Micros/DonationTypes/TreeDonation.tsx index 5a1d0020..891964d7 100644 --- a/src/Donations/Micros/DonationTypes/TreeDonation.tsx +++ b/src/Donations/Micros/DonationTypes/TreeDonation.tsx @@ -152,7 +152,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement {