Skip to content

Commit

Permalink
feat: update GiftForm display logic
Browse files Browse the repository at this point in the history
- based on project classification and frequency
  • Loading branch information
mohitb35 committed Nov 12, 2024
1 parent 330aeda commit 4827176
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ function DonationsForm(): ReactElement {
!(isGift && giftDetails.recipientName === "") &&
!(onBehalf && onBehalfDonor.firstName === "");

const canSendInvitationGift =
(projectDetails?.classification !== "membership" && frequency === "once") ||
(projectDetails?.classification === "membership" && frequency !== "once");

const canSendDirectGift = projectDetails?.classification !== "membership";
const hasDirectGift = giftDetails.type === "direct";

//Only used for native pay. Is this still applicable, or should this be removed?
const onPaymentFunction = async (
paymentMethod: PaymentMethod,
Expand Down Expand Up @@ -359,16 +366,13 @@ function DonationsForm(): ReactElement {
)}
{/* show PlanetCashSelector only if user is signed up and have a planetCash account */}
{canPayWithPlanetCash && <PlanetCashSelector />}
{!(onBehalf && onBehalfDonor.firstName === "") &&
(projectDetails.purpose === "trees" &&
(paymentSetup?.unitType !== "m2" ||
giftDetails.type === "direct") ? (
<div className="donations-gift-container mt-10">
<GiftForm />
</div>
) : (
<></>
))}
{(canSendDirectGift && hasDirectGift) || canSendInvitationGift ? (
<div className="donations-gift-container mt-10">
<GiftForm />
</div>
) : (
<></>
)}
{process.env.RECURRENCY &&
showFrequencyOptions &&
paymentSetup &&
Expand Down

0 comments on commit 4827176

Please sign in to comment.