From 7be0d10d0f1abf2f87702cb46b987eec221ce66c Mon Sep 17 00:00:00 2001 From: Barney Laurance Date: Wed, 4 Oct 2023 11:49:24 +0100 Subject: [PATCH] DON-819: Use snackbar to show errors in stepper recieve updates step --- .../donation-start-form.component.html | 14 +++++------ .../donation-start-form.component.ts | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) 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 ab07394eb..4731135ff 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 @@ -449,8 +449,8 @@

How does Big Give u -

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

+ {{errorMessagesForMarketingStep().optInCharityEmailRequired}}.

@@ -482,8 +482,8 @@

How does Big Give u -

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

+ {{errorMessagesForMarketingStep().optInTbgEmailRequired}}

@@ -508,8 +508,8 @@

How does Big Give u -

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

+ {{errorMessagesForMarketingStep().optInChampionEmailRequired}}

@@ -525,7 +525,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 b01f15c29..ea9a09004 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 @@ -1027,6 +1027,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.'