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

Release Giftable donations #473

Merged
merged 35 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e80151a
feat: enhance project details types with classification & purpose var…
mohitb35 Nov 12, 2024
330aeda
feat: refactor project details handling with createProjectDetails uti…
mohitb35 Nov 12, 2024
4827176
feat: update GiftForm display logic
mohitb35 Nov 12, 2024
e508a6f
feat: removes unneeded GiftForm fields for membership projects
mohitb35 Nov 12, 2024
56a6baa
feat: refine DonationsForm gift handling while paying through planet …
mohitb35 Nov 12, 2024
562fa92
feat: prevent initialization of direct gift for membership projects
mohitb35 Nov 12, 2024
66552ec
feat: rename projectDetails `classification` to `category`
mohitb35 Nov 13, 2024
09ccd93
feat: prevent GiftForm display for planet-cash donations
mohitb35 Nov 13, 2024
10fbef4
fix: remove unneeded `onBehalf` while creating prepaid donation
mohitb35 Nov 13, 2024
fa0c770
feat: prevent gifts to non giftable project purposes
mohitb35 Nov 13, 2024
9ca3909
feat: update gift message to clarify dedication to recipient
mohitb35 Nov 13, 2024
92d62ab
chore: update @planet-sdk/common to version 0.1.42
mohitb35 Nov 13, 2024
62b38ac
feat: remove support link from query params when not applicable
mohitb35 Nov 14, 2024
416b7a4
feat: update gift types and usage to resolve TS warnings
mohitb35 Nov 14, 2024
ed270b3
feat: ensure donation amounts are treated as numbers for consistency
mohitb35 Nov 14, 2024
dd2b8e3
fix: standardize casing for setIsGift
mohitb35 Nov 14, 2024
e84df9b
revert: rename projectDetails `category` to `classification` for cons…
mohitb35 Nov 18, 2024
448c65d
refactor: remove conditional onBehalf donor assignment in DonationsForm
mohitb35 Nov 18, 2024
fb98cd9
fix: minor code cleanup and fixes
mohitb35 Nov 18, 2024
bc4af28
fix: fixes visible currency selector for non tree donations while dis…
mohitb35 Nov 21, 2024
83e1544
fix: resolves intermittent layout issue with MaterialTextField
mohitb35 Nov 22, 2024
c379166
fix: add validation for recipient name length in GiftForm
mohitb35 Nov 26, 2024
2890661
feat: update logic to show PlanetCashSelector
mohitb35 Nov 26, 2024
071785c
refactor: remove unused _onBehalfDonor assignment in DonationsForm
mohitb35 Nov 28, 2024
2839bc1
feat: add check for PlanetCash gateway while permitting planet cash d…
mohitb35 Dec 3, 2024
2eced0a
feat: add authentication to loadPaymentSetup
mohitb35 Dec 3, 2024
b7cb75c
Merge pull request #471 from Plant-for-the-Planet-org/feature/expand-…
mariahosfeld Dec 3, 2024
8546ebb
Merge pull request #472 from Plant-for-the-Planet-org/feature/restric…
mariahosfeld Dec 3, 2024
2a71cb1
Merge pull request #470 from Plant-for-the-Planet-org/feature/giftabl…
mariahosfeld Dec 3, 2024
088cd7b
Language update from Lingohub 🤖
lingohub[bot] Dec 3, 2024
90d2774
Merge pull request #474 from Plant-for-the-Planet-org/lingohub_langua…
mariahosfeld Dec 3, 2024
99e0b3b
chore: update @planet-sdk/common to version 0.1.47
mohitb35 Dec 3, 2024
71554b5
fix: correct typos for getFormattedCurrency / getFormattedCurrencySymbol
mohitb35 Dec 3, 2024
f2574c1
refactor: minor refactors to address codefactor feedback
mohitb35 Dec 3, 2024
0f124bf
Merge pull request #475 from Plant-for-the-Planet-org/hotfix/typos-an…
mohitb35 Dec 3, 2024
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.34",
"@planet-sdk/common": "^0.1.47",
"@sentry/browser": "^6.2.5",
"@sentry/integrations": "^6.2.5",
"@sentry/node": "^6.2.5",
Expand Down
102 changes: 51 additions & 51 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import countriesData from "./../src/Utils/countriesData.json";
import { setCountryCode } from "src/Utils/setCountryCode";
import { DONATE } from "src/Utils/donationStepConstants";
import {
SentGift,
GiftDetails,
FetchedProjectDetails,
PaymentOptions,
} from "src/Common/Types";
Expand All @@ -20,11 +20,13 @@ import {
ContactDetails,
} from "@planet-sdk/common/build/types/donation";
import { GetServerSideProps } from "next/types";
import { createProjectDetails } from "src/Utils/createProjectDetails";
import { NON_GIFTABLE_PROJECT_PURPOSES } from "src/Utils/projects/constants";

interface Props {
projectDetails?: FetchedProjectDetails;
donationStep: number | null;
giftDetails: SentGift | null;
giftDetails: GiftDetails | null;
isGift: boolean;
resolvedUrl?: string;
isDirectDonation: boolean;
Expand Down Expand Up @@ -79,7 +81,7 @@ function index({
setSelectedProjects,
loadselectedProjects,
setGiftDetails,
setisGift,
setIsGift,
setpaymentSetup,
setcurrency,
setContactDetails,
Expand Down Expand Up @@ -129,7 +131,7 @@ function index({
// If gift details are present, initialize gift in context
if (giftDetails && isGift) {
setGiftDetails(giftDetails);
setisGift(true);
setIsGift(true);
}
}, []);

Expand Down Expand Up @@ -215,7 +217,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {

// Variables that will be affected with Gift details
let isGift = false;
let giftDetails: SentGift | null = null;
let giftDetails: GiftDetails | null = null;
let frequency = "once";
// Variables that will be affected with context
let hideTaxDeduction = false;
Expand Down Expand Up @@ -250,7 +252,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const queryCountry = context.query.country;
const found = countriesData.some(
(country) =>
country.countryCode?.toUpperCase() === queryCountry.toUpperCase(),
country.countryCode?.toUpperCase() === queryCountry.toUpperCase()
);
if (found) {
country = queryCountry.toUpperCase();
Expand All @@ -276,18 +278,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const paymentOptionsResponse = await apiRequest(requestParams);
const paymentOptionsData: PaymentOptions = paymentOptionsResponse?.data;
if (paymentOptionsData) {
projectDetails = {
id: paymentOptionsData.id,
name: paymentOptionsData.name,
description: paymentOptionsData.description,
purpose: paymentOptionsData.purpose,
ownerName: paymentOptionsData.ownerName,
taxDeductionCountries: paymentOptionsData.taxDeductionCountries,
image: paymentOptionsData.image,
ownerAvatar: paymentOptionsData.ownerAvatar,
isApproved: paymentOptionsData.isApproved ? true : false,
isTopProject: paymentOptionsData.isTopProject ? true : false,
};
projectDetails = createProjectDetails(paymentOptionsData);
donationStep = 1;
}
} catch (err) {
Expand Down Expand Up @@ -360,26 +351,15 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
if (paymentSetupData) {
currency = paymentSetupData.currency;
paymentSetup = paymentSetupData;
projectDetails = {
id: paymentSetupData.id,
name: paymentSetupData.name,
description: paymentSetupData.description,
purpose: paymentSetupData.purpose,
ownerName: paymentSetupData.ownerName,
taxDeductionCountries: paymentSetupData.taxDeductionCountries,
image: paymentSetupData.image,
ownerAvatar: paymentSetupData.ownerAvatar,
isApproved: paymentSetupData.isApproved ? true : false,
isTopProject: paymentSetupData.isTopProject ? true : false,
};
projectDetails = createProjectDetails(paymentSetupData);
donationStep = 3;
}
} catch (err) {
// console.log(err);
}
allowTaxDeductionChange = false;
units = donation.units;
amount = donation.amount;
amount = Number(donation.amount);
// Setting contact details from donor details
if (donorData) {
contactDetails = {
Expand Down Expand Up @@ -429,29 +409,49 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
if (typeof context.query.utm_source === "string")
utmSource = context.query.utm_source;

// Set gift details if there is s (support link) in the query params
if (context.query.s) {
try {
const requestParams = {
url: `/app/profiles/${context.query.s}`,
setshowErrorCard,
tenant,
locale,
// Handle s (support link) in the query params
if (typeof context.query.s === "string" && context.query.s.length > 0) {
if (
projectDetails === null ||
projectDetails.classification === "membership" ||
NON_GIFTABLE_PROJECT_PURPOSES.includes(projectDetails.purpose)
) {
// If project cannot have direct gift, remove 's' parameter by redirecting
const pathname = context.resolvedUrl.split("?")[0];
const query = { ...context.query };
delete query.s;
const queryString = new URLSearchParams(
query as Record<string, string>
).toString();

return {
redirect: {
destination: `${pathname}${queryString ? `?${queryString}` : ""}`,
permanent: true,
},
};
const newProfile = await apiRequest(requestParams);
if (newProfile.data.type !== "tpo") {
isGift = true;
giftDetails = {
recipientName: newProfile.data.displayName,
recipientEmail: "",
message: "",
type: "direct",
recipient: newProfile.data.id,
recipientTreecounter: newProfile.data.slug,
} else {
// Set gift details if there is s (support link) in the query params for an eligible project
try {
const requestParams = {
url: `/app/profiles/${context.query.s}`,
setshowErrorCard,
tenant,
locale,
};
const newProfile = await apiRequest(requestParams);
if (newProfile.data.type !== "tpo") {
isGift = true;
giftDetails = {
recipientName: newProfile.data.displayName,
type: "direct",
recipient: newProfile.data.id,
recipientProfile: newProfile.data.slug,
};
}
} catch (err) {
console.log("Error", err);
}
} catch (err) {
console.log("Error", err);
}
}

Expand Down
1 change: 0 additions & 1 deletion public/locales/cs/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
"selectLanguage": "Zvolit jazyk",
"trees": "stromů",
"logout": "Odhlásit se",
"directGiftRecipient": "Tento dar podporuje Les od {{name}}",
"saveGiftDetails": "Uloži darovací údaje",
"giftSomeone": "Můj dar je někomu věnován ",
"or": "NEBO",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tree_other": "Bäume",
"recipientName": "Name des Empfängers",
"recipientNameRequired": "Name des Empfängers ist erforderlich",
"recipientNameTooLong": "Der Name des Empfängers darf höchstens 35 Zeichen lang sein",
"email": "E-Mail",
"recipientEmail": "E-Mail des Empfängers",
"emailRequired": "E-Mail ist erforderlich",
Expand Down Expand Up @@ -118,7 +119,7 @@
"selectLanguage": "Sprache auswählen",
"trees": "Bäume",
"logout": "Abmelden",
"directGiftRecipient": "Diese Spende unterstützt den Wald von {{name}}",
"giftDedicatedTo": "Diese Spende ist {{name}} gewidmet",
"saveGiftDetails": "Geschenkdetails speichern",
"giftSomeone": "Meine Spende ist ein Geschenk an jemanden",
"or": "ODER",
Expand All @@ -134,6 +135,7 @@
"billingAddress": "Kontaktdetails",
"treesInCountry": "{{treeCount}} Bäume, Plant-for-the-Planet",
"fundingPaymentLabel": "Spende {{amount}}, Plant-for-the-Planet",
"pcashPaymentLabel": "Laden Sie {{amount}} PlanetCash, Plant-for-the-Planet",
"bouquetPaymentLabel": "Spende {{amount}}, Plant-for-the-Planet",
"errorOccurred": "Etwas ist schief gelaufen. Bitte mache einen Screenshot und schicke ihn uns als E-Mail an [email protected].",
"dedicatedTo": "Unterstützt den Wald von",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tree_other": "trees",
"recipientName": "Recipient Name",
"recipientNameRequired": "Recipient Name is required",
"recipientNameTooLong": "Recipient Name must be 35 characters or less",
"email": "Email",
"recipientEmail": "Recipient Email",
"emailRequired": "Email is required",
Expand Down Expand Up @@ -118,7 +119,7 @@
"selectLanguage": "Select Language",
"trees": "trees",
"logout": "Logout",
"directGiftRecipient": "This donation supports {{name}}'s Forest",
"giftDedicatedTo": "This donation is dedicated to {{name}}",
"saveGiftDetails": "Save Gift Details",
"giftSomeone": "My donation is dedicated to someone",
"or": "OR",
Expand Down
1 change: 0 additions & 1 deletion public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"selectLanguage": "Seleccione el idioma",
"trees": "árboles",
"logout": "Cierre de sesión",
"directGiftRecipient": "Esta donación apoya {{name}}",
"saveGiftDetails": "Guardar detalles de los regalos",
"giftSomeone": "Mi donación es un regalo para alguien",
"or": "O",
Expand Down
1 change: 0 additions & 1 deletion public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"selectLanguage": "Sélectionnez une langue",
"trees": "arbres",
"logout": "Déconnexion",
"directGiftRecipient": "Ce don soutient {{name}}",
"saveGiftDetails": "Save Gift Details",
"giftSomeone": "Mon don est un cadeau pour quelqu'un",
"or": "OU",
Expand Down
1 change: 0 additions & 1 deletion public/locales/it/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"selectLanguage": "Seleziona la lingua",
"trees": "alberi",
"logout": "Logout",
"directGiftRecipient": "Questa donazione sostiene {{name}}",
"saveGiftDetails": "Salva i dettagli del regalo",
"giftSomeone": "La mia donazione è un regalo a qualcuno",
"or": "O",
Expand Down
1 change: 0 additions & 1 deletion public/locales/pt-BR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
"selectLanguage": "Selecione o Idioma",
"trees": "árvores",
"logout": "Sair",
"directGiftRecipient": "Esta doação apoia a Floresta {{name}}",
"saveGiftDetails": "Salvar Detalhes do Presente",
"giftSomeone": "A minha doação é um presente para alguém",
"or": "OU",
Expand Down
Loading
Loading