From a3388b56a909f3bfba573b1e00df16e33d5d2d94 Mon Sep 17 00:00:00 2001 From: Hemanth Kona Date: Mon, 3 Jun 2024 17:12:50 -0400 Subject: [PATCH] EMBCESSMOD-5511, 5516 Fix showing UnavailableOneTimeuse message - Fix hasActiveSupports to not include cancelled or void supports --- ...-serve-support-details-form.component.html | 40 +++++++++++++++--- ...lf-serve-support-details-form.component.ts | 42 +++++++++---------- .../evacuation-file-data.service.ts | 7 +++- 3 files changed, 60 insertions(+), 29 deletions(-) diff --git a/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.html b/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.html index bbd2c4a72..aff84c7f8 100644 --- a/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.html +++ b/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.html @@ -1,7 +1,11 @@ @if (supportDraftForm) {

Please review the following and make any necessary edits. Required fields are marked with a red asterisk.

- @if (showSelfServeShelterAllowanceSupport) { + + @if ( + supportEligibilityStateSettings[SelfServeSupportType.ShelterAllowance] === + SelfServeSupportEligibilityState.UnavailableOneTimeUsed + ) { + +
Shelter Allowance
-
+
@@ -211,7 +221,10 @@ } - @if (showSelfServeClothingSupport) { + @if ( + supportEligibilityStateSettings[SelfServeSupportType.Clothing] === + SelfServeSupportEligibilityState.UnavailableOneTimeUsed + ) { + +
Clothing
-
+
@@ -249,7 +268,10 @@ } - @if (showSelfServeIncidentsSupport) { + @if ( + supportEligibilityStateSettings[SelfServeSupportType.Incidentals] === + SelfServeSupportEligibilityState.UnavailableOneTimeUsed + ) { + +
Incidentals
-
+
diff --git a/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.ts b/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.ts index 18cfccc65..7bc8a9de5 100644 --- a/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.ts +++ b/registrants/src/UI/embc-registrant/src/app/feature-components/self-serve-support/self-serve-support-details-form/self-serve-support-details-form.component.ts @@ -69,6 +69,26 @@ export class SelfServeSupportDetailsFormComponent { @Input() set draftSupports(draftSupports: DraftSupports) { + this.supportEligibilityStateSettings[SelfServeSupportType.ShelterAllowance] = this.getEligibilityState( + SelfServeSupportType.ShelterAllowance + ); + + this.supportEligibilityStateSettings[SelfServeSupportType.FoodGroceries] = this.getEligibilityState( + SelfServeSupportType.FoodGroceries + ); + + this.supportEligibilityStateSettings[SelfServeSupportType.FoodRestaurant] = this.getEligibilityState( + SelfServeSupportType.FoodRestaurant + ); + + this.supportEligibilityStateSettings[SelfServeSupportType.Clothing] = this.getEligibilityState( + SelfServeSupportType.Clothing + ); + + this.supportEligibilityStateSettings[SelfServeSupportType.Incidentals] = this.getEligibilityState( + SelfServeSupportType.Incidentals + ); + draftSupports.items.forEach((support) => { switch (support.type) { case SelfServeSupportType.ShelterAllowance: @@ -124,15 +144,11 @@ export class SelfServeSupportDetailsFormComponent { selfServeSupportFormGroup.controls.totalAmount.setValue(selfServeSupport.totalAmount ?? 0); - this.supportEligibilityStateSettings[SelfServeSupportType.ShelterAllowance] = this.getEligibilityState( - SelfServeSupportType.ShelterAllowance - ); - this.showSelfServeShelterAllowanceSupport = true; } getEligibilityState(type: SelfServeSupportType) { - return this.evacuationFileDataService.selfServeEligibilityCheck.supportSettings.find((s) => s.type === type).state; + return this.evacuationFileDataService.selfServeEligibilityCheck.supportSettings.find((s) => s.type === type)?.state; } private createSelfServeFoodGroceriesSupportForm( @@ -148,10 +164,6 @@ export class SelfServeSupportDetailsFormComponent { selfServeSupportFormGroup.controls.totalAmount.setValue(selfServeSupport.totalAmount ?? 0); - this.supportEligibilityStateSettings[SelfServeSupportType.FoodGroceries] = this.getEligibilityState( - SelfServeSupportType.FoodGroceries - ); - this.showSelfServeFoodSupport = true; this.hasSelfServeFoodGroceriesSupport = true; @@ -298,10 +310,6 @@ export class SelfServeSupportDetailsFormComponent { this.foodRestaurantDates = [...dates]; - this.supportEligibilityStateSettings[SelfServeSupportType.FoodRestaurant] = this.getEligibilityState( - SelfServeSupportType.FoodRestaurant - ); - this.showSelfServeFoodSupport = true; this.hasSelfServiceFoodRestaurantSupport = true; @@ -323,10 +331,6 @@ export class SelfServeSupportDetailsFormComponent { selfServeSupportFormGroup.controls.totalAmount.setValue(selfServeSupport.totalAmount ?? 0); - this.supportEligibilityStateSettings[SelfServeSupportType.Clothing] = this.getEligibilityState( - SelfServeSupportType.Clothing - ); - this.showSelfServeClothingSupport = true; } @@ -340,10 +344,6 @@ export class SelfServeSupportDetailsFormComponent { selfServeSupportFormGroup.controls.totalAmount.setValue(selfServeSupport.totalAmount ?? 0); - this.supportEligibilityStateSettings[SelfServeSupportType.Incidentals] = this.getEligibilityState( - SelfServeSupportType.Incidentals - ); - this.showSelfServeIncidentsSupport = true; } diff --git a/registrants/src/UI/embc-registrant/src/app/sharedModules/components/evacuation-file/evacuation-file-data.service.ts b/registrants/src/UI/embc-registrant/src/app/sharedModules/components/evacuation-file/evacuation-file-data.service.ts index b0f2ceb50..17b608ebd 100644 --- a/registrants/src/UI/embc-registrant/src/app/sharedModules/components/evacuation-file/evacuation-file-data.service.ts +++ b/registrants/src/UI/embc-registrant/src/app/sharedModules/components/evacuation-file/evacuation-file-data.service.ts @@ -7,7 +7,8 @@ import { EvacuationFileStatus, NeedsAssessment, Support, - SupportMethod + SupportMethod, + SupportStatus } from 'src/app/core/api/models'; import { EvacuationsService, ProfileService, SupportsService } from 'src/app/core/api/services'; import { RegAddress } from 'src/app/core/model/address'; @@ -130,7 +131,9 @@ export class EvacuationFileDataService { hasActiveSupports(supports?: Array): boolean { // if at least one support has support.to date time greater than now, then hasActiveSupports is true - return supports.some((s) => moment(s.to).diff(moment()) > 0); + return supports.some( + (s) => ![SupportStatus.Void, SupportStatus.Cancelled].includes(s.status) && moment(s.to).diff(moment()) > 0 + ); } hasNoSupports(supports: Array): boolean {