From b5f3e1238a450ac0b4191f5c4a0b502e5f65aded Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:27:39 +0530 Subject: [PATCH 1/3] feat: allow gift query param for more project types --- pages/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/index.tsx b/pages/index.tsx index 1824b14b..2726a1f1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -456,7 +456,11 @@ export const getServerSideProps: GetServerSideProps = async (context) => { } // Set gift details if gift = true in the query params (only for tree projects) - if (context.query.gift === "true" && projectDetails?.purpose === "trees") { + if ( + context.query.gift === "true" && + projectDetails !== null && + !NON_GIFTABLE_PROJECT_PURPOSES.includes(projectDetails.purpose) + ) { isGift = true; giftDetails = { type: "invitation", From fc5c24528f4ac3bf57b61f03b6dd12621abd9fc4 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:50:00 +0530 Subject: [PATCH 2/3] refactor: change DirectGiftDetails and InvitationGiftDetails to interfaces --- src/Common/Types/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Common/Types/index.tsx b/src/Common/Types/index.tsx index 18a9ce45..49789d3b 100644 --- a/src/Common/Types/index.tsx +++ b/src/Common/Types/index.tsx @@ -14,11 +14,11 @@ import { } from "@planet-sdk/common"; /** planet-donations only allows direct or invitation gifts */ -export type DirectGiftDetails = SentDirectGift & { +export interface DirectGiftDetails extends SentDirectGift { recipientName?: string; recipientProfile?: string; -}; -export type InvitationGiftDetails = SentInvitationGift; +} +export interface InvitationGiftDetails extends SentInvitationGift {} export type SentGift = SentDirectGift | SentInvitationGift; From 68c040a4813f62f82930ae75b7d2e3b1e474c9d9 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:50:54 +0530 Subject: [PATCH 3/3] fix: prevent use of `gift=true` query param if direct gift is set --- pages/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/index.tsx b/pages/index.tsx index 2726a1f1..90bbed4d 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -455,8 +455,9 @@ export const getServerSideProps: GetServerSideProps = async (context) => { } } - // Set gift details if gift = true in the query params (only for tree projects) + // Set gift details if gift = true in the query params if ( + giftDetails?.type !== "direct" && context.query.gift === "true" && projectDetails !== null && !NON_GIFTABLE_PROJECT_PURPOSES.includes(projectDetails.purpose)