From 5924aa10c4275af224a12f41e8f09c04deb79426 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:01:03 +0530 Subject: [PATCH 01/10] docs: adds explanation (handleStripeSCAPayment) --- src/Donations/PaymentMethods/PaymentFunctions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Donations/PaymentMethods/PaymentFunctions.ts b/src/Donations/PaymentMethods/PaymentFunctions.ts index e0495966..e3693638 100644 --- a/src/Donations/PaymentMethods/PaymentFunctions.ts +++ b/src/Donations/PaymentMethods/PaymentFunctions.ts @@ -466,6 +466,7 @@ export async function handleStripeSCAPayment({ } try { const payDonationData = { + // method not sent here as it was already captured in the 1st request. paymentProviderRequest: { account: paymentSetup.gateways.stripe.account, gateway: "stripe" as const, From 53345a01bedec103357dd3df1973b74b53b0987f Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:45:56 +0530 Subject: [PATCH 02/10] chore: updates planet-sdk --- 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 1fd66929..3efee66b 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.8", + "@planet-sdk/common": "^0.1.21", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", @@ -1078,9 +1078,9 @@ "dev": true }, "node_modules/@planet-sdk/common": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.8.tgz", - "integrity": "sha512-1K3NACqgom4ZgA0GRWPXWRnTA72I4HHwBDbWOSTnRZkKE7Pl9fAwWjYyy72xJ5D654q66KmLSy4dMvRmcvBUMA==", + "version": "0.1.21", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.21.tgz", + "integrity": "sha512-XDrA0eylGezdA+Y4WcJVV9kzQ9HtlYIf5w7t+HMdsIXKV6UCc1Rb65J/rQPp4YKaUIYhCkmF9Sgd+BlVt5R1Ew==", "dependencies": { "@types/geojson": "^7946.0.10" } @@ -8722,9 +8722,9 @@ } }, "@planet-sdk/common": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.8.tgz", - "integrity": "sha512-1K3NACqgom4ZgA0GRWPXWRnTA72I4HHwBDbWOSTnRZkKE7Pl9fAwWjYyy72xJ5D654q66KmLSy4dMvRmcvBUMA==", + "version": "0.1.21", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.21.tgz", + "integrity": "sha512-XDrA0eylGezdA+Y4WcJVV9kzQ9HtlYIf5w7t+HMdsIXKV6UCc1Rb65J/rQPp4YKaUIYhCkmF9Sgd+BlVt5R1Ew==", "requires": { "@types/geojson": "^7946.0.10" } diff --git a/package.json b/package.json index 9a8a1186..4d99351b 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.8", + "@planet-sdk/common": "^0.1.21", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", From 476b00fa21c5c3e6aa233d1c8899ea5d4a1e1fce Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:54:16 +0530 Subject: [PATCH 03/10] feat: adds `unitType` (`PaymentOptions` interface) - marks `unit` as deprecated - updates to `unitType` throughout code --- src/Common/Types/index.tsx | 4 ++-- src/Donations/Micros/DonationTypes/BouquetDonations.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Common/Types/index.tsx b/src/Common/Types/index.tsx index c2d6dacd..4aba52c9 100644 --- a/src/Common/Types/index.tsx +++ b/src/Common/Types/index.tsx @@ -143,12 +143,12 @@ export interface PaymentOptions extends FetchedProjectDetails { frequencies: Frequencies; gateways: Gateways; recurrency: Recurrency; + /** @deprecated - use unitType instead */ unit: string; + unitType: string; unitCost: number; currency: string; destination: string; - isApproved: boolean; - isTopProject: boolean; } interface Frequencies { diff --git a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx index 4bf8a149..f368d7e8 100644 --- a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx +++ b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx @@ -108,7 +108,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { setCustomInputValue( getFormattedNumber( i18n.language, - paymentSetup.unit !== "currency" + paymentSetup.unitType !== "currency" ? newQuantity : newQuantity * paymentSetup.unitCost ) @@ -227,7 +227,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { }} > {paymentSetup.purpose === "conservation" - ? t(paymentSetup.unit) + ? t(paymentSetup.unitType) : []} </p> </div> @@ -238,7 +238,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { > <p style={{ margin: "5px" }}> {" "} - {paymentSetup.unit === "currency" + {paymentSetup.unitType === "currency" ? t("customAmount") : t("custom")} </p> From a04b1f157d46a42bf828c4c722af52fac20a40df Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:51:33 +0530 Subject: [PATCH 04/10] feat: integrate unitType in DonationsForm - only for tree/conservation projects --- public/locales/en/common.json | 6 ++++++ src/Common/Types/index.tsx | 3 ++- src/Donations/Micros/DonationAmount.tsx | 4 ++-- .../Micros/DonationTypes/BouquetDonations.tsx | 16 +++++++++++++--- .../Micros/DonationTypes/TreeDonation.tsx | 16 ++++++++++++---- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 7bb657ef..fc22f358 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -3,6 +3,8 @@ "fortreeCountTrees_other": "for {{treeCount}} Trees", "forQuantitym2": "for {{quantity}} m²", "m2": "m²", + "tree_one": "tree", + "tree_other": "trees", "recipientName": "Recipient Name", "recipientNameRequired": "Recipient Name is required", "email": "Email", @@ -37,6 +39,10 @@ "orgNamePublishedTax": "Company name is visible on our leaderboard and app. Tax-deduction receipts will be issued for the same name.", "orgNamePublished": "Company name is visible on our leaderboard and app.", "paymentDetails": "Payment Details", + "perUnit": { + "tree": "per tree", + "m2": "per m²" + }, "perTree": "per tree", "perm2": "per m²", "youWillReceiveTaxDeduction": "You will receive a tax deduction receipt for ", diff --git a/src/Common/Types/index.tsx b/src/Common/Types/index.tsx index 4aba52c9..01c1df9b 100644 --- a/src/Common/Types/index.tsx +++ b/src/Common/Types/index.tsx @@ -10,6 +10,7 @@ import { ContactDetails, BankTransferDetails, PaymentGateway, + CurrencyCode, } from "@planet-sdk/common"; /** planet-donations only allows direct or invitation gifts */ @@ -145,7 +146,7 @@ export interface PaymentOptions extends FetchedProjectDetails { recurrency: Recurrency; /** @deprecated - use unitType instead */ unit: string; - unitType: string; + unitType: "tree" | "m2" | "currency" | CurrencyCode; unitCost: number; currency: string; destination: string; diff --git a/src/Donations/Micros/DonationAmount.tsx b/src/Donations/Micros/DonationAmount.tsx index 3fcd60ec..454837a1 100644 --- a/src/Donations/Micros/DonationAmount.tsx +++ b/src/Donations/Micros/DonationAmount.tsx @@ -21,12 +21,12 @@ function DonationAmount(): ReactElement { paymentSetup.unitCost * quantity )} </span> - {paymentSetup.purpose === "trees" + {paymentSetup.unitType === "tree" ? t("fortreeCountTrees", { count: Number(quantity), treeCount: getFormattedNumber(i18n.language, Number(quantity)), }) - : paymentSetup.purpose === "conservation" + : paymentSetup.unitType === "m2" ? t("forQuantitym2", { quantity: getFormattedNumber(i18n.language, Number(quantity)), }) diff --git a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx index f368d7e8..3893f92d 100644 --- a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx +++ b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx @@ -165,7 +165,11 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { currency, option.quantity * paymentSetup.unitCost )}{" "} - {paymentSetup.purpose === "conservation" ? t("m2") : []} + {/* Below condition is redundant currently, but is left here as a reminder while refactoring */} + {paymentSetup.purpose === "conservation" && + paymentSetup.unitType === "m2" + ? t(paymentSetup.unitType) + : []} </span> </div> </div> @@ -226,7 +230,9 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { fontWeight: "800", }} > - {paymentSetup.purpose === "conservation" + {/* Below condition is redundant currently, but is left here as a reminder while refactoring */} + {paymentSetup.purpose === "conservation" && + paymentSetup.unitType === "m2" ? t(paymentSetup.unitType) : []} </p> @@ -282,7 +288,11 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { ) : []}{" "} </button> - {paymentSetup.purpose === "conservation" ? t("perm2") : []} + {/* Below condition is redundant currently, but is left here as a reminder while refactoring */} + {paymentSetup.purpose === "conservation" && + paymentSetup.unitType === "m2" + ? t("perUnit.m2") + : []} </p> ) : ( <div className={"mt-20"}> diff --git a/src/Donations/Micros/DonationTypes/TreeDonation.tsx b/src/Donations/Micros/DonationTypes/TreeDonation.tsx index f09cf700..3d812c93 100644 --- a/src/Donations/Micros/DonationTypes/TreeDonation.tsx +++ b/src/Donations/Micros/DonationTypes/TreeDonation.tsx @@ -74,7 +74,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { }, [quantity]); const customInputRef = React.useRef<HTMLInputElement>(null); - return ( + return paymentSetup !== null ? ( <div className={`donations-tree-selection ${ isGift && giftDetails.recipientName === "" ? "display-none" : "" @@ -99,7 +99,9 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { {option.iconFile} <div className="tree-selection-option-text"> <p>{option.quantity}</p> - <span>{t("trees")}</span> + <span> + {t(paymentSetup.unitType, { count: option.quantity })} + </span> </div> </div> ); @@ -136,7 +138,11 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { }} ref={customInputRef} /> - <span>{t("trees")}</span> + <span> + {t(paymentSetup.unitType, { + count: parseInt(customTreeInputValue), + })} + </span> </div> </div> </div> @@ -165,7 +171,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { Number(paymentSetup.unitCost) )}{" "} </button> - {t("perTree")} + {t(`perUnit.${paymentSetup.unitType}`)} </p> ) : ( <div className={"mt-20"}> @@ -173,6 +179,8 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { </div> )} </div> + ) : ( + <div>Payment Setup Failed</div> ); } From 39d2cb81f108d0d03ef94c8c4832d5a13c0c07ae Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:22:52 +0530 Subject: [PATCH 05/10] feat: use unitType in TransactionSummary - this is seen in the Left Panel - Also converts `getAdditionalInfo` into a pure function - Also adds a separate type definition for UnitType --- src/Common/Types/index.tsx | 4 ++- .../LeftPanel/TransactionSummary.tsx | 25 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Common/Types/index.tsx b/src/Common/Types/index.tsx index 01c1df9b..25fea83d 100644 --- a/src/Common/Types/index.tsx +++ b/src/Common/Types/index.tsx @@ -146,12 +146,14 @@ export interface PaymentOptions extends FetchedProjectDetails { recurrency: Recurrency; /** @deprecated - use unitType instead */ unit: string; - unitType: "tree" | "m2" | "currency" | CurrencyCode; + unitType: UnitType; unitCost: number; currency: string; destination: string; } +export type UnitType = "tree" | "m2" | "currency" | CurrencyCode; + interface Frequencies { [key: string]: Frequency; } diff --git a/src/Donations/LeftPanel/TransactionSummary.tsx b/src/Donations/LeftPanel/TransactionSummary.tsx index 3b3cf673..f0598d49 100644 --- a/src/Donations/LeftPanel/TransactionSummary.tsx +++ b/src/Donations/LeftPanel/TransactionSummary.tsx @@ -2,7 +2,7 @@ import { ReactElement } from "react"; import { useTranslation } from "next-i18next"; import getFormatedCurrency from "src/Utils/getFormattedCurrency"; import { getFormattedNumber } from "src/Utils/getFormattedNumber"; -import { PaymentOptions, ProjectPurpose } from "src/Common/Types"; +import { PaymentOptions, ProjectPurpose, UnitType } from "src/Common/Types"; import styles from "./LeftPanel.module.scss"; interface Props { @@ -22,26 +22,28 @@ const TransactionSummary = ({ /** Generates unit/frequency info when needed */ const getAdditionalInfo = ( - purpose: ProjectPurpose, - frequency: string + unitType: UnitType, + frequency: string, + language: string, + quantity: number ): string => { let info = ""; - switch (purpose) { - case "trees": + switch (unitType) { + case "tree": info = info + " " + t("fortreeCountTrees", { count: Number(quantity), - treeCount: getFormattedNumber(i18n.language, Number(quantity)), + treeCount: getFormattedNumber(language, Number(quantity)), }); break; - case "conservation": + case "m2": info = info + " " + t("forQuantitym2", { - quantity: getFormattedNumber(i18n.language, Number(quantity)), + quantity: getFormattedNumber(language, Number(quantity)), }); break; default: @@ -72,7 +74,12 @@ const TransactionSummary = ({ paymentSetup.unitCost * quantity )} </strong> - {getAdditionalInfo(paymentSetup.purpose, frequency)} + {getAdditionalInfo( + paymentSetup.unitType, + frequency, + i18n.language, + quantity + )} </div> ); }; From e66fd6c96f57afb2e8416a03837e67a76587df6a Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:54:21 +0530 Subject: [PATCH 06/10] feat: allows PC* payment only for unitType=tree * PC = PlanetCash --- src/Donations/Components/DonationsForm.tsx | 3 ++- src/Donations/Micros/DonationTypes/TreeDonation.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Donations/Components/DonationsForm.tsx b/src/Donations/Components/DonationsForm.tsx index b4ac75a8..bb202657 100644 --- a/src/Donations/Components/DonationsForm.tsx +++ b/src/Donations/Components/DonationsForm.tsx @@ -326,7 +326,8 @@ function DonationsForm(): ReactElement { <p className="title-text">{t("donate")}</p> )} {/* show PlanetCashSelector only if user is signed up and have a planetCash account */} - {projectDetails.purpose !== "funds" && + {paymentSetup?.unitType === "tree" && + projectDetails.purpose !== "funds" && projectDetails.purpose !== "planet-cash" && !(isGift && giftDetails.recipientName === "") && !(onBehalf && onBehalfDonor.firstName === "") && diff --git a/src/Donations/Micros/DonationTypes/TreeDonation.tsx b/src/Donations/Micros/DonationTypes/TreeDonation.tsx index 3d812c93..b959dabe 100644 --- a/src/Donations/Micros/DonationTypes/TreeDonation.tsx +++ b/src/Donations/Micros/DonationTypes/TreeDonation.tsx @@ -180,7 +180,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { )} </div> ) : ( - <div>Payment Setup Failed</div> + <></> ); } From 976b0368dc40fc47247f0f6bb96135ce164d0b40 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:57:01 +0530 Subject: [PATCH 07/10] fix: removes unused ProjectPurpose type --- src/Donations/LeftPanel/TransactionSummary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Donations/LeftPanel/TransactionSummary.tsx b/src/Donations/LeftPanel/TransactionSummary.tsx index f0598d49..57bffc07 100644 --- a/src/Donations/LeftPanel/TransactionSummary.tsx +++ b/src/Donations/LeftPanel/TransactionSummary.tsx @@ -2,7 +2,7 @@ import { ReactElement } from "react"; import { useTranslation } from "next-i18next"; import getFormatedCurrency from "src/Utils/getFormattedCurrency"; import { getFormattedNumber } from "src/Utils/getFormattedNumber"; -import { PaymentOptions, ProjectPurpose, UnitType } from "src/Common/Types"; +import { PaymentOptions, UnitType } from "src/Common/Types"; import styles from "./LeftPanel.module.scss"; interface Props { From 238f907c83cbc01a357632b1c0568cfe67b57923 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:41:30 +0530 Subject: [PATCH 08/10] feat: updates Thank you screen for m2 donations - updates planet-sdk to get latest `Donation` type - adapts thank you message and image text for donations with unitType = m2 and purpose = trees --- package-lock.json | 14 ++++----- package.json | 2 +- public/locales/en/common.json | 7 +++-- .../Micros/PaymentStatus/ImageComponent.tsx | 29 +++++++++++++------ .../Micros/PaymentStatus/ThankyouMessage.tsx | 22 +++++++------- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0ef25aef..bb9bab44 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.27", + "@planet-sdk/common": "^0.1.29", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", @@ -1079,9 +1079,9 @@ "dev": true }, "node_modules/@planet-sdk/common": { - "version": "0.1.28", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.28.tgz", - "integrity": "sha512-8SAoDEhX2dsSXuRfcIlNR10ptGntsTb14YHkOuLvXkNCdHrYB4gtZ365EmxsziQqoEk+4QhMVZD1yikbmRgh9w==", + "version": "0.1.29", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.29.tgz", + "integrity": "sha512-hNmkxfYcqmUuYGm0BLWSvr+sIbZxOXCy1AEhpClTTcfQjpofyqfHfrgkmgoFzZqK9WXPEq0Tn2uSDfqPPcRpFg==", "dependencies": { "@types/geojson": "^7946.0.10" } @@ -8852,9 +8852,9 @@ } }, "@planet-sdk/common": { - "version": "0.1.28", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.28.tgz", - "integrity": "sha512-8SAoDEhX2dsSXuRfcIlNR10ptGntsTb14YHkOuLvXkNCdHrYB4gtZ365EmxsziQqoEk+4QhMVZD1yikbmRgh9w==", + "version": "0.1.29", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.29.tgz", + "integrity": "sha512-hNmkxfYcqmUuYGm0BLWSvr+sIbZxOXCy1AEhpClTTcfQjpofyqfHfrgkmgoFzZqK9WXPEq0Tn2uSDfqPPcRpFg==", "requires": { "@types/geojson": "^7946.0.10" } diff --git a/package.json b/package.json index 2dc58fe0..90549fd4 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.27", + "@planet-sdk/common": "^0.1.29", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index cd0f6d60..a166f478 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -78,9 +78,10 @@ "contributionMessage": "Maybe you'll visit them some day? In the mean time, maybe hook up your friends with some trees of their own by telling them about yours?", "fundingDonationSuccess": "Thank you for your contribution! You’ll receive a confirmation for your contribution on your email.", "fundingContributionMessage": "We will keep you posted about our actions, in the mean time maybe share with your friends about your contribution.", - "yourTreesPlantedByOnLocation": "Your {{treeCount}} trees will be planted by {{projectName}} in {{location}}.", + "restorationDonationUsage": "Your donation will be used to restore {{units}} {{unitType}} by {{projectName}} in {{location}}.", "m2conservedByOnLocation": "{{quantity}} m² forest will be conserved by {{projectName}} in {{location}}.", "myTreesPlantedByOnLocation": "My {{treeCount}} trees are being planted in {{location}}.", + "restorationDonationShareDetails": "I donated {{amount}} for forest restoration in {{location}}.", "iDonatedForestOnLocation": "I donated {{amount}} for forest conservation in {{location}}.", "weDonatedForestOnLocation": "We donated {{amount}} for forest conservation in {{location}}.", "plantTreesAtURL": "Restore & protect trees at {{url}}", @@ -172,7 +173,7 @@ "lowBalance": "Balance is low", "oneTimePay": "Donation with PlanetCash is a one time payment", "currency": "Currency", - "treesPurpose": "tree donation", + "treesPurpose": "restoration donation", "fundsPurpose": "donation", "bouquetPurpose": "donation", "conservationPurpose": "conservation donation", @@ -216,4 +217,4 @@ "top_project_standards_fulfilled": "The project inspection revealed that this project fulfilled at least 12 of the 19 Top Project <2>standards.</2>", "standardsLink": "https://www.plant-for-the-planet.org/standards/", "enterValidEmail": "Please enter a valid email" -} \ No newline at end of file +} diff --git a/src/Donations/Micros/PaymentStatus/ImageComponent.tsx b/src/Donations/Micros/PaymentStatus/ImageComponent.tsx index 0c43a31c..382ca014 100644 --- a/src/Donations/Micros/PaymentStatus/ImageComponent.tsx +++ b/src/Donations/Micros/PaymentStatus/ImageComponent.tsx @@ -60,15 +60,26 @@ const ImageComponent = ({ return ( <div className={"donation-count p-20"}> {projectDetails?.purpose === "trees" && - t("common:myTreesPlantedByOnLocation", { - treeCount: getFormattedNumber( - i18n.language, - Number(donation.treeCount) - ), - location: t( - "country:" + donation.destination.country.toLowerCase() - ), - })} + (donation.unitType === "tree" + ? t("common:myTreesPlantedByOnLocation", { + treeCount: getFormattedNumber( + i18n.language, + Number(donation.treeCount) + ), + location: t( + "country:" + donation.destination.country.toLowerCase() + ), + }) + : t("common:restorationDonationShareDetails", { + amount: getFormattedCurrency( + i18n.language, + donation.currency, + Number(donation.amount) + ), + location: t( + "country:" + donation.destination.country.toLowerCase() + ), + }))} {projectDetails?.purpose === "conservation" && t( `common:${ diff --git a/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx b/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx index 3af17716..cf3a700e 100644 --- a/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx +++ b/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx @@ -1,7 +1,6 @@ import React, { ReactElement } from "react"; import { useTranslation } from "next-i18next"; import getFormatedCurrency from "src/Utils/getFormattedCurrency"; -import { getFormattedNumber } from "src/Utils/getFormattedNumber"; import { QueryParamContext } from "src/Layout/QueryParamContext"; import { FetchedProjectDetails } from "src/Common/Types"; import { Donation } from "@planet-sdk/common/build/types/donation"; @@ -49,17 +48,16 @@ function ThankyouMessage({ : null; // EXAMPLE: Your 50 trees will be planted by AMU EcoVillage Project, Ethiopia in Ethiopia. - const donationProjectMessage = donation.destination - ? " " + - t("common:yourTreesPlantedByOnLocation", { - treeCount: getFormattedNumber( - i18n.language, - Number(donation.treeCount) - ), - projectName: donation.destination.name, - location: t("country:" + donation.destination.country.toLowerCase()), - }) - : null; + const donationProjectMessage = + donation.destination && donation.units + ? " " + + t("common:restorationDonationUsage", { + units: donation.units, + unitType: t(`common:${donation.unitType}`, { count: donation.units }), + projectName: donation.destination.name, + location: t("country:" + donation.destination.country.toLowerCase()), + }) + : null; const Message = () => { return ( From 3976a99ba976a03cb7fabc12fdc390afefa1acce Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:08:45 +0530 Subject: [PATCH 09/10] feat: temp adjustments for tree + m2 donations - disables inv. gifts for "trees+m2" donations - enables PC payment only for "unitType: tree" donations --- src/Donations/Components/DonationsForm.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Donations/Components/DonationsForm.tsx b/src/Donations/Components/DonationsForm.tsx index c466c684..be22af4c 100644 --- a/src/Donations/Components/DonationsForm.tsx +++ b/src/Donations/Components/DonationsForm.tsx @@ -109,6 +109,7 @@ function DonationsForm(): ReactElement { projectDetails !== null && projectDetails.purpose !== "funds" && projectDetails.purpose !== "planet-cash" && + paymentSetup?.unitType === "tree" && //Enables planetcash for restoration projects with unitType tree only (TEMP) profile !== null && isSignedUp && profile.planetCash !== null && @@ -339,7 +340,9 @@ function DonationsForm(): ReactElement { {/* show PlanetCashSelector only if user is signed up and have a planetCash account */} {canPayWithPlanetCash && <PlanetCashSelector />} {!(onBehalf && onBehalfDonor.firstName === "") && - (projectDetails.purpose === "trees" ? ( + (projectDetails.purpose === "trees" && + (paymentSetup?.unitType !== "m2" || + giftDetails.type === "direct") ? ( <div className="donations-gift-container mt-10"> <GiftForm /> </div> From f01b7e8f0880abc590d064488612ad891e179adf Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:07:22 -0500 Subject: [PATCH 10/10] fix: formats donation.units in ThankyouMessage --- src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx b/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx index cf3a700e..73d036c1 100644 --- a/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx +++ b/src/Donations/Micros/PaymentStatus/ThankyouMessage.tsx @@ -1,6 +1,7 @@ import React, { ReactElement } from "react"; import { useTranslation } from "next-i18next"; import getFormatedCurrency from "src/Utils/getFormattedCurrency"; +import { getFormattedNumber } from "src/Utils/getFormattedNumber"; import { QueryParamContext } from "src/Layout/QueryParamContext"; import { FetchedProjectDetails } from "src/Common/Types"; import { Donation } from "@planet-sdk/common/build/types/donation"; @@ -47,12 +48,13 @@ function ThankyouMessage({ }) : null; - // EXAMPLE: Your 50 trees will be planted by AMU EcoVillage Project, Ethiopia in Ethiopia. + // EXAMPLE: Your donation will be used to restore 1,000 trees by Yucatán Restoration in Mexico. + // EXAMPLE: Your donation will be used to restore 2,000 m² by Saving Sumatra’s Last Refuge in Indonesia. const donationProjectMessage = donation.destination && donation.units ? " " + t("common:restorationDonationUsage", { - units: donation.units, + units: getFormattedNumber(i18n.language, donation.units), unitType: t(`common:${donation.unitType}`, { count: donation.units }), projectName: donation.destination.name, location: t("country:" + donation.destination.country.toLowerCase()),