Skip to content

Commit

Permalink
Merge pull request #307 from Plant-for-the-Planet-org/feat/planetCash…
Browse files Browse the repository at this point in the history
…-topup

Feat/planet cash topup
  • Loading branch information
mariahosfeld authored Jul 5, 2022
2 parents 8b71f93 + 623bda7 commit c586df1
Show file tree
Hide file tree
Showing 9 changed files with 670 additions and 369 deletions.
60 changes: 30 additions & 30 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { setCountryCode } from "src/Utils/setCountryCode";
import { DONATE } from "src/Utils/donationStepConstants";

interface Props {
projectDetails: Object;
projectDetails?: Object;
donationStep: any;
giftDetails: Object;
isGift: boolean;
resolvedUrl: any;
resolvedUrl?: any;
isDirectDonation: boolean;
hideTaxDeduction: boolean;
isTaxDeductible: boolean;
Expand All @@ -28,7 +28,7 @@ interface Props {
allowTaxDeductionChange: boolean;
currency: any;
paymentSetup: any;
treecount: any;
treecount?: any;
amount: any;
meta: { title: string; description: string; image: string; url: string };
frequency: string;
Expand All @@ -38,11 +38,9 @@ interface Props {
}

function index({
projectDetails,
donationStep,
giftDetails,
isGift,
resolvedUrl,
isDirectDonation,
hideTaxDeduction,
isTaxDeductible,
Expand All @@ -53,7 +51,6 @@ function index({
allowTaxDeductionChange,
currency,
paymentSetup,
treecount,
amount,
meta,
frequency,
Expand All @@ -62,7 +59,6 @@ function index({
callbackMethod,
}: Props): ReactElement {
const {
setprojectDetails,
setdonationStep,
loadselectedProjects,
setgiftDetails,
Expand All @@ -82,6 +78,8 @@ function index({
settenant,
setcallbackUrl,
setCallbackMethod,
projectDetails,
setprojectDetails,
} = React.useContext(QueryParamContext);

const router = useRouter();
Expand Down Expand Up @@ -252,31 +250,33 @@ export async function getServerSideProps(context: any) {
) {
const to = context.query?.to?.replace(/\//g, "") || "";
donationStep = 1;
try {
const requestParams = {
url: `/app/paymentOptions/${to}?country=${country}`,
setshowErrorCard,
tenant,
locale,
};
const paymentOptionsResponse = await apiRequest(requestParams);
if (paymentOptionsResponse.data) {
projectDetails = {
id: paymentOptionsResponse.data.id,
name: paymentOptionsResponse.data.name,
description: paymentOptionsResponse.data.description,
purpose: paymentOptionsResponse.data.purpose,
ownerName: paymentOptionsResponse.data.ownerName,
taxDeductionCountries:
paymentOptionsResponse.data.taxDeductionCountries,
projectImage: paymentOptionsResponse.data.image,
ownerAvatar: paymentOptionsResponse.data.ownerAvatar,
if (to !== "planetCash") {
try {
const requestParams = {
url: `/app/paymentOptions/${to}?country=${country}`,
setshowErrorCard,
tenant,
locale,
};
donationStep = 1;
const paymentOptionsResponse = await apiRequest(requestParams);
if (paymentOptionsResponse.data) {
projectDetails = {
id: paymentOptionsResponse.data.id,
name: paymentOptionsResponse.data.name,
description: paymentOptionsResponse.data.description,
purpose: paymentOptionsResponse.data.purpose,
ownerName: paymentOptionsResponse.data.ownerName,
taxDeductionCountries:
paymentOptionsResponse.data.taxDeductionCountries,
projectImage: paymentOptionsResponse.data.image,
ownerAvatar: paymentOptionsResponse.data.ownerAvatar,
};
donationStep = 1;
}
} catch (err) {
donationStep = 0;
console.log("err", err);
}
} catch (err) {
donationStep = 0;
console.log("err", err);
}
} else {
if (!context.query.context) {
Expand Down
7 changes: 6 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,10 @@
"conservationPurpose": "conservation donation",
"planet-cashPurpose": "PlanetCash donation",
"pfpSupportsUNEP": "Plant-for-the-Planet Supports the United Nations Environment Program",
"noPlanetCashAccount": "You do not have a PlanetCash account, however you can signup for one below",
"planetCashSignup": "Sign Up for PlanetCash",
"planetCashTC": "By clicking \"Create PlanetCash Account\", I agree to the <0>Terms and Conditions</0> of Plant-for-the-Planet Platform, and PlanetCash.",
"planetCashIUnderstand": "I understand that PlanetCash donation/payments are non-refundable, and unallocated payments will be auto allocated to projects on the Platform after six months of Payment.",
"createPlanetCashAccount": "Create PlanetCash Account",
"myContributionIsPartOfThat": "And my contribution is a part of that."
}
}
Loading

0 comments on commit c586df1

Please sign in to comment.