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

Giftable donations #470

Merged
merged 28 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 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
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
Prev Previous commit
Next Next commit
revert: rename projectDetails category to classification for cons…
…istency
mohitb35 committed Nov 18, 2024
commit e84df9b43c41d14194f8708f2c26e6d0901168cb
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
@@ -210,36 +210,36 @@

export default index;

export const getServerSideProps: GetServerSideProps = async (context) => {
let donationStep = 0;
let showErrorCard = false;
let projectDetails: FetchedProjectDetails | null = null;

// Variables that will be affected with Gift details
let isGift = false;
let giftDetails: GiftDetails | null = null;
let frequency = "once";
// Variables that will be affected with context
let hideTaxDeduction = false;
let isTaxDeductible = false;
let donationID = null;
let shouldCreateDonation = false;
let country = "";
let isDirectDonation = false;
let contactDetails: ContactDetails | null = null;
let units: number | null = 50;
let allowTaxDeductionChange = true;
let currency = "EUR";
let paymentSetup: PaymentOptions | null = null;
let amount = 0;
let tenant = "ten_I9TW3ncG";
let callbackUrl = "";
let callbackMethod = "";
let utmCampaign = "";
let utmMedium = "";
let utmSource = "";
const locale = context.locale || "en";

Check warning on line 242 in pages/index.tsx

codefactor.io / CodeFactor

pages/index.tsx#L213-L242

Very Complex Method
function setshowErrorCard() {
showErrorCard = true;
}
@@ -413,7 +413,7 @@
if (typeof context.query.s === "string" && context.query.s.length > 0) {
if (
projectDetails === null ||
projectDetails.category === "membership" ||
projectDetails.classification === "membership" ||
NON_GIFTABLE_PROJECT_PURPOSES.includes(projectDetails.purpose)
) {
// If project cannot have direct gift, remove 's' parameter by redirecting
8 changes: 4 additions & 4 deletions src/Common/Types/index.tsx
Original file line number Diff line number Diff line change
@@ -135,25 +135,25 @@ export interface FetchedBaseProjectDetails {
ownerName: string | null;
image?: string | null;
purpose: ProjectPurpose;
category: Nullable<ProjectClassification>;
classification: Nullable<ProjectClassification>;
taxDeductionCountries?: Array<string>;
isApproved: boolean;
isTopProject: boolean;
}

export interface FetchedTreeProjectDetails extends FetchedBaseProjectDetails {
purpose: "trees";
category: TreeProjectClassification;
classification: TreeProjectClassification;
}

export interface FetchedFundsProjectDetails extends FetchedBaseProjectDetails {
purpose: "funds";
category: FundsProjectClassification;
classification: FundsProjectClassification;
}

export interface FetchedOtherProjectDetails extends FetchedBaseProjectDetails {
purpose: "conservation" | "reforestation" | "bouquet" | "planet-cash";
category: null;
classification: null;
}

export type FetchedProjectDetails =
8 changes: 5 additions & 3 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
@@ -133,16 +133,18 @@ function DonationsForm(): ReactElement {

const canSendDirectGift =
projectDetails !== null &&
projectDetails.category !== "membership" &&
projectDetails.classification !== "membership" &&
!NON_GIFTABLE_PROJECT_PURPOSES.includes(projectDetails.purpose);

const hasDirectGift = giftDetails.type === "direct";
const canSendInvitationGift =
projectDetails !== null &&
!NON_GIFTABLE_PROJECT_PURPOSES.includes(projectDetails.purpose) &&
!hasDirectGift &&
((projectDetails?.category !== "membership" && frequency === "once") ||
(projectDetails?.category === "membership" && frequency !== "once"));
((projectDetails?.classification !== "membership" &&
frequency === "once") ||
(projectDetails?.classification === "membership" &&
frequency !== "once"));

//Only used for native pay. Is this still applicable, or should this be removed?
const onPaymentFunction = async (
2 changes: 1 addition & 1 deletion src/Donations/Micros/GiftForm.tsx
Original file line number Diff line number Diff line change
@@ -23,30 +23,30 @@
type: null,
};

export default function GiftForm(): ReactElement {
const { t } = useTranslation("common");
const [showEmail, setShowEmail] = React.useState(false);
const { giftDetails, setGiftDetails, isGift, setIsGift, projectDetails } =
React.useContext(QueryParamContext);

const defaultDetails: GiftFormData = {
recipientName: giftDetails.recipientName || "",
recipientEmail:
(giftDetails.type === "invitation" && giftDetails.recipientEmail) || "",
message:
(giftDetails.type === "invitation" && giftDetails.recipientName) || "",
};

const {
handleSubmit,
reset,
control,
formState: { errors },
} = useForm<GiftFormData>({
mode: "all",
defaultValues: defaultDetails,
});

Check notice on line 49 in src/Donations/Micros/GiftForm.tsx

codefactor.io / CodeFactor

src/Donations/Micros/GiftForm.tsx#L26-L49

Complex Method
React.useEffect(() => {
if (isGift && giftDetails) {
if (giftDetails.type !== "direct") {
@@ -117,7 +117,7 @@
)}
</div>

{projectDetails?.category !== "membership" && (
{projectDetails?.classification !== "membership" && (
<>
{showEmail ? (
<div>
6 changes: 3 additions & 3 deletions src/Utils/createProjectDetails.ts
Original file line number Diff line number Diff line change
@@ -20,19 +20,19 @@ export const createProjectDetails = (
return {
...baseDetails,
purpose: "trees",
category: paymentOptions.category,
classification: paymentOptions.classification,
};
case "funds":
return {
...baseDetails,
purpose: "funds",
category: paymentOptions.category,
classification: paymentOptions.classification,
};
default:
return {
...baseDetails,
purpose: paymentOptions.purpose,
category: null,
classification: null,
};
}
};
Loading