Skip to content

Commit

Permalink
DON-1108 – surface recently_confirmed_tips_total; don't propose a n…
Browse files Browse the repository at this point in the history
…ew Donation Funds tip when it's >£0
  • Loading branch information
NoelLH committed Dec 19, 2024
1 parent f397af6 commit 43bf233
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/app/person.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export interface Person {
*/
pending_tip_balance?: { [currencyCode: string]: number };

/**
* The total of donor fund form-created succeeded tips for the given Person, set up in the past 10 days, counted in minor-currency units i.e. pence
*/
recently_confirmed_tips_total?: { [currencyCode: string]: number };

/**
* These 3 expected on first update.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/app/transfer-funds/transfer-funds.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ <h3 class="b-rh-1 b-bold">Transfer Donation Funds</h3>
and then optionally make a new one.
</div>
}
@if (donorHasRecentlyTipped) {
<div>
<p>Thank you for tipping Big Give {{ (recentlyConfirmedTipsTotal / 100) | exactCurrency:"GBP" }} </p>
<p>This was confirmed from your balance when you transferred funds.</p>
</div>
}
<!-- All tip bits are shown iff the pending bank-funded tip balance in GBP is £0 or undefined -->
@if (!donor.pending_tip_balance?.gbp) {
@if (!donorHasPendingTipBalance && !donorHasRecentlyTipped) {
<div>
<p><strong>Tip Big Give</strong></p>
<p class="tip-text">Big Give has a 0% platform fee. That means we're able to continue offering our services thanks to donors who leave an optional tip amount here:</p>
Expand Down
14 changes: 11 additions & 3 deletions src/app/transfer-funds/transfer-funds.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class TransferFundsComponent implements AfterContentInit, OnInit {
return false;
}

if (this.donor?.pending_tip_balance?.gbp) {
if (this.donorHasPendingTipBalance || this.donorHasRecentlyTipped) {
return false;
}

Expand Down Expand Up @@ -355,6 +355,14 @@ export class TransferFundsComponent implements AfterContentInit, OnInit {
return this.pendingTipBalance > 0;
}

get recentlyConfirmedTipsTotal(): number {
return this.donor?.recently_confirmed_tips_total?.gbp || 0;
}

get donorHasRecentlyTipped(): boolean {
return this.recentlyConfirmedTipsTotal > 0;
}

private loadPerson() {
const idAndJWT = this.identityService.getIdAndJWT();
if (idAndJWT !== undefined) {
Expand All @@ -373,7 +381,7 @@ export class TransferFundsComponent implements AfterContentInit, OnInit {

this.setConditionalValidators();

if (this.donorHasPendingTipBalance) {
if (this.donorHasPendingTipBalance || this.donorHasRecentlyTipped) {
this.amountsGroup.patchValue({
customTipAmount: 0,
tipPercentage: 0,
Expand Down Expand Up @@ -422,7 +430,7 @@ export class TransferFundsComponent implements AfterContentInit, OnInit {

// If user didn't tip, OR if an existing tip's detected but we somehow have tip numbers
// set, do not create a new tip.
if (donationAmount <= 0 || this.donorHasPendingTipBalance) {
if (donationAmount <= 0 || this.donorHasPendingTipBalance || this.donorHasRecentlyTipped) {
return;
}

Expand Down

0 comments on commit 43bf233

Please sign in to comment.