diff --git a/src/app/donation-start/donation-start-form/donation-start-form.component.html b/src/app/donation-start/donation-start-form/donation-start-form.component.html index 665d31e9b..d17aa6869 100644 --- a/src/app/donation-start/donation-start-form/donation-start-form.component.html +++ b/src/app/donation-start/donation-start-form/donation-start-form.component.html @@ -469,8 +469,8 @@

How does Big Give u -

- Please choose whether you wish to receive updates from {{ campaign.charity.name }}. +

+ {{errorMessagesForMarketingStep().optInCharityEmailRequired}}.

@@ -502,8 +502,8 @@

How does Big Give u -

- Please choose whether you wish to receive updates from Big Give. +

+ {{errorMessagesForMarketingStep().optInTbgEmailRequired}}

@@ -528,8 +528,8 @@

How does Big Give u -

- Please choose whether you wish to receive updates from {{ campaign.championName }}. +

+ {{errorMessagesForMarketingStep().optInChampionEmailRequired}}

@@ -545,7 +545,7 @@

How does Big Give u class="continue b-w-100 b-rt-0" mat-raised-button color="primary" - (click)="triedToLeaveMarketing = true; next()" + (click)="progressFromStepReceiveUpdates()" >Continue diff --git a/src/app/donation-start/donation-start-form/donation-start-form.component.ts b/src/app/donation-start/donation-start-form/donation-start-form.component.ts index d3d876cb6..4c3c8ff40 100644 --- a/src/app/donation-start/donation-start-form/donation-start-form.component.ts +++ b/src/app/donation-start/donation-start-form/donation-start-form.component.ts @@ -1065,6 +1065,31 @@ export class DonationStartFormComponent implements AfterContentChecked, AfterCon this.next() } + progressFromStepReceiveUpdates(): void { + this.triedToLeaveMarketing = true; + const errorMessages = Object.values(this.errorMessagesForMarketingStep()).filter(Boolean) + if (errorMessages.length > 0 && this.don819FlagEnabled) { + this.showErrorToast(errorMessages.join(" ")); + return; + } + + this.next() + } + + public errorMessagesForMarketingStep = () => { + return { + optInChampionEmailRequired: this.marketingGroup.get('optInChampionEmail')?.hasError('required') ? + `Please choose whether you wish to receive updates from ${this.campaign.championName}.` : null, + + optInTbgEmailRequired: this.marketingGroup.get('optInTbgEmail')?.hasError('required') ? + 'Please choose whether you wish to receive updates from Big Give.' : null, + + optInCharityEmailRequired: this.marketingGroup.get('optInCharityEmail')?.hasError('required') ? + `Please choose whether you wish to receive updates from ${this.campaign.charity.name}.` : null + }; + } + + public giftAidRequiredRadioError = (): string => { if (this.giftAidGroup.get('giftAid')?.hasError('required')) { return 'Please choose whether you wish to claim Gift Aid.'