Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update @planet-sdk/common and fix typos in currency functions #475

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 23 additions & 25 deletions src/Donations/Components/ContactsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -401,29 +401,27 @@ function ContactsForm(): ReactElement {
</div>
<div style={{ width: "20px" }} />
<div className={"form-field mt-30 flex-1"}>
{true && (
<Controller
name="zipCode"
control={control}
rules={{
required: t("zipCodeRequired"),
pattern: {
value: postalRegex as RegExp,
message: t("zipCodeInvalid"),
},
}}
render={({ field: { onChange, value, onBlur } }) => (
<MaterialTextField
onChange={onChange}
onBlur={onBlur}
value={value}
label={t("zipCode")}
variant="outlined"
data-test-id="test-zipCode"
/>
)}
/>
)}
<Controller
name="zipCode"
control={control}
rules={{
required: t("zipCodeRequired"),
pattern: {
value: postalRegex as RegExp,
message: t("zipCodeInvalid"),
},
}}
render={({ field: { onChange, value, onBlur } }) => (
<MaterialTextField
onChange={onChange}
onBlur={onBlur}
value={value}
label={t("zipCode")}
variant="outlined"
data-test-id="test-zipCode"
/>
)}
/>
{errors.zipCode !== undefined && (
<div className={"form-errors"}>{errors.zipCode.message}</div>
)}
Expand Down Expand Up @@ -588,7 +586,7 @@ function ContactsForm(): ReactElement {
>
{paymentSetup &&
t("donate_button", {
totalCost: getFormatedCurrency(
totalCost: getFormattedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
Expand Down
10 changes: 5 additions & 5 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -257,7 +257,7 @@ function DonationsForm(): ReactElement {
break;
case "funds":
paymentLabel = t("fundingPaymentLabel", {
amount: getFormatedCurrency(
amount: getFormattedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
Expand All @@ -266,7 +266,7 @@ function DonationsForm(): ReactElement {
break;
case "planet-cash":
paymentLabel = t("pcashPaymentLabel", {
amount: getFormatedCurrency(
amount: getFormattedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
Expand All @@ -276,7 +276,7 @@ function DonationsForm(): ReactElement {
case "bouquet":
case "conservation":
paymentLabel = t("bouquetPaymentLabel", {
amount: getFormatedCurrency(
amount: getFormattedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
Expand Down Expand Up @@ -466,7 +466,7 @@ function DonationsForm(): ReactElement {
<p className={"text-danger mt-20 text-center"}>
{t("minDonate")}{" "}
<span>
{getFormatedCurrency(i18n.language, currency, minAmt)}
{getFormattedCurrency(i18n.language, currency, minAmt)}
</span>
</p>
) : (
Expand Down
4 changes: 2 additions & 2 deletions src/Donations/Components/PaymentsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -419,7 +419,7 @@ function PaymentsForm(): ReactElement {
<Elements stripe={stripePromise}>
<CardPayments
donorDetails={contactDetails}
totalCost={getFormatedCurrency(
totalCost={getFormattedCurrency(
i18n.language,
currency,
paymentSetup?.unitCost * quantity
Expand Down
4 changes: 2 additions & 2 deletions src/Donations/LeftPanel/TransactionSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { 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 { PaymentOptions, UnitType } from "src/Common/Types";
import styles from "./LeftPanel.module.scss";
Expand Down Expand Up @@ -68,7 +68,7 @@ const TransactionSummary = ({
<div className={styles["transaction-summary"]}>
{t("donating")}{" "}
<strong>
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
Expand Down
4 changes: 2 additions & 2 deletions src/Donations/Micros/DonationAmount.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -15,7 +15,7 @@ function DonationAmount(): ReactElement {
{paymentSetup && paymentSetup.unitCost ? (
<div className={"w-100 text-center text-bold mt-20"}>
<span className={"text-primary"} style={{ marginRight: "4px" }}>
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
Expand Down
10 changes: 5 additions & 5 deletions src/Donations/Micros/DonationTypes/BouquetDonations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -160,7 +160,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement {
<span style={{ fontSize: "18px" }}>
{paymentSetup.purpose === "conservation"
? option.quantity
: getFormatedCurrency(
: getFormattedCurrency(
i18n.language,
currency,
option.quantity * paymentSetup.unitCost
Expand Down Expand Up @@ -193,7 +193,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement {
}}
>
{paymentSetup.purpose === "bouquet"
? getFormatedCurrencySymbol(currency)
? getFormattedCurrencySymbol(currency)
: []}
</p>
<input
Expand Down Expand Up @@ -281,7 +281,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement {
<DownArrowIcon color={themeProperties.primaryColor} />
)}
{paymentSetup.purpose === "conservation"
? getFormatedCurrency(
? getFormattedCurrency(
i18n.language,
"",
Number(paymentSetup.unitCost)
Expand Down
8 changes: 4 additions & 4 deletions src/Donations/Micros/DonationTypes/FundingDonations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -164,7 +164,7 @@ function FundingDonations({ setopenCurrencyModal }: Props): ReactElement {
fontSize: option.caption ? "14px" : "18px",
}}
>
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
currency,
option.quantity * paymentSetup.unitCost
Expand Down Expand Up @@ -195,7 +195,7 @@ function FundingDonations({ setopenCurrencyModal }: Props): ReactElement {
marginTop: "3px",
}}
>
{getFormatedCurrencySymbol(currency)}
{getFormattedCurrencySymbol(currency)}
</p>
<input
className={"funding-custom-tree-input"}
Expand Down
6 changes: 3 additions & 3 deletions src/Donations/Micros/DonationTypes/TreeDonation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
import CustomIcon from "../../../../public/assets/icons/CustomIcon";
import { QueryParamContext } from "../../../Layout/QueryParamContext";
import DownArrowIcon from "../../../../public/assets/icons/DownArrowIcon";
import getFormatedCurrency from "../../../Utils/getFormattedCurrency";
import getFormattedCurrency from "../../../Utils/getFormattedCurrency";
import themeProperties from "../../../../styles/themeProperties";
import { useTranslation } from "next-i18next";
import TreeCostLoader from "../../../Common/ContentLoaders/TreeCostLoader";
Expand Down Expand Up @@ -152,7 +152,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement {
<button
onClick={() => {
// Lock the currency/country change if planetCash is active
!isPlanetCashActive && setopenCurrencyModal(true);
if (!isPlanetCashActive) setopenCurrencyModal(true);
}}
className="text-bold text-primary"
style={{
Expand All @@ -165,7 +165,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement {
{!isPlanetCashActive && (
<DownArrowIcon color={themeProperties.primaryColor} />
)}
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
"",
Number(paymentSetup.unitCost)
Expand Down
3 changes: 1 addition & 2 deletions src/Donations/Micros/PaymentStatus/ImageComponent.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -22,7 +22,7 @@ function ThankyouMessage({
let currencyFormat = () => {};
if (donation) {
currencyFormat = () =>
getFormatedCurrency(
getFormattedCurrency(
i18n.language,
donation.currency,
Number(donation.amount)
Expand Down
4 changes: 2 additions & 2 deletions src/Donations/Micros/PaymentStatus/TransferDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +51,7 @@ function TransferDetails({
? t("common:transferDetailsMessage")
: t("common:recurrentTransferDetailsMsg", {
frequency,
amount: getFormatedCurrency(
amount: getFormattedCurrency(
i18n.language,
donation.currency,
donation.amount
Expand Down
8 changes: 4 additions & 4 deletions src/Donations/Micros/PlanetCashSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
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;

const PlanetCashSelector: FC = () => {
const { t, i18n } = useTranslation("common");
const {
profile,
isPlanetCashActive,
setIsPlanetCashActive,
paymentSetup,
quantity,
country,
setcountry,
frequency,
} = useContext(QueryParamContext);
const router = useRouter();

Check notice on line 24 in src/Donations/Micros/PlanetCashSelector.tsx

View check run for this annotation

codefactor.io / CodeFactor

src/Donations/Micros/PlanetCashSelector.tsx#L11-L24

Complex Method
useEffect(() => {
// Here checking country is important as many countries could have same currency.

Expand Down Expand Up @@ -144,7 +144,7 @@
: "-negative")
}
>
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
profile.planetCash.currency,
profile.planetCash.balance / 100
Expand All @@ -163,7 +163,7 @@
: "-negative")
}
>
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
profile.planetCash.currency,
profile.planetCash.creditLimit / 100
Expand All @@ -186,7 +186,7 @@
: "-negative")
}
>
{getFormatedCurrency(
{getFormattedCurrency(
i18n.language,
profile.planetCash.currency,
profile.planetCash.balance / 100 +
Expand Down
Loading
Loading