Skip to content

Commit

Permalink
revert: rename projectDetails category to classification for cons…
Browse files Browse the repository at this point in the history
…istency
  • Loading branch information
mohitb35 committed Nov 18, 2024
1 parent dd2b8e3 commit e84df9b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
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
Expand Down
8 changes: 4 additions & 4 deletions src/Common/Types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
8 changes: 5 additions & 3 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion src/Donations/Micros/GiftForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function GiftForm(): ReactElement {
)}
</div>

{projectDetails?.category !== "membership" && (
{projectDetails?.classification !== "membership" && (
<>
{showEmail ? (
<div>
Expand Down
6 changes: 3 additions & 3 deletions src/Utils/createProjectDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
};

0 comments on commit e84df9b

Please sign in to comment.