Skip to content

Commit

Permalink
EMBCESSMOD-5511, 5516 Fix showing UnavailableOneTimeuse message
Browse files Browse the repository at this point in the history
- Fix hasActiveSupports to not include cancelled or void supports
  • Loading branch information
Hemanth Kona authored and Hemanth Kona committed Jun 3, 2024
1 parent 837e24a commit a3388b5
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@if (supportDraftForm) {
<form class="support-details-form">
<p>Please review the following and make any necessary edits. Required fields are marked with a red asterisk.</p>
@if (showSelfServeShelterAllowanceSupport) {

@if (
supportEligibilityStateSettings[SelfServeSupportType.ShelterAllowance] ===
SelfServeSupportEligibilityState.UnavailableOneTimeUsed
) {
<mat-card
appearance="outlined"
[class.support-one-time-used]="
Expand All @@ -16,8 +20,14 @@
<p><b>Shelter Allowance is only provided once during the evacuation period.</b></p>
<p>Your household has already been provided support for Shelter Allowance</p>
</div>
</mat-card-content>
</mat-card>
} @else if (showSelfServeShelterAllowanceSupport) {
<mat-card appearance="outlined">
<mat-card-content>
<div class="card-heading">Shelter Allowance</div>

<div class="question-box hide-on-one-time-used">
<div class="question-box">
<div class="card-question">
<label>Which <b>days</b> does your household require <b>Shelter Allowance</b>?</label>
</div>
Expand Down Expand Up @@ -211,7 +221,10 @@
</mat-card>
}

@if (showSelfServeClothingSupport) {
@if (
supportEligibilityStateSettings[SelfServeSupportType.Clothing] ===
SelfServeSupportEligibilityState.UnavailableOneTimeUsed
) {
<mat-card
appearance="outlined"
[class.support-one-time-used]="
Expand All @@ -226,8 +239,14 @@
<p><b>Clothing is only provided once during the evacuation period.</b></p>
<p>Your household has already been provided support for Clothing</p>
</div>
</mat-card-content>
</mat-card>
} @else if (showSelfServeClothingSupport) {
<mat-card appearance="outlined">
<mat-card-content>
<div class="card-heading">Clothing</div>

<div class="question-box hide-on-one-time-used">
<div class="question-box">
<div class="card-question">
<label>Which <b>people</b> in your household require <b>Clothing</b>?</label>
</div>
Expand All @@ -249,7 +268,10 @@
</mat-card>
}

@if (showSelfServeIncidentsSupport) {
@if (
supportEligibilityStateSettings[SelfServeSupportType.Incidentals] ===
SelfServeSupportEligibilityState.UnavailableOneTimeUsed
) {
<mat-card
appearance="outlined"
[class.support-one-time-used]="
Expand All @@ -264,8 +286,14 @@
<p><b>Incidents is only provided once during the evacuation period.</b></p>
<p>Your household has already been provided support for Incidents</p>
</div>
</mat-card-content>
</mat-card>
} @else if (showSelfServeIncidentsSupport) {
<mat-card appearance="outlined">
<mat-card-content>
<div class="card-heading">Incidentals</div>

<div class="question-box hide-on-one-time-used">
<div class="question-box">
<div class="card-question">
<label>Which <b>people</b> in your household require <b>Incidentals</b>?</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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;

Expand Down Expand Up @@ -298,10 +310,6 @@ export class SelfServeSupportDetailsFormComponent {

this.foodRestaurantDates = [...dates];

this.supportEligibilityStateSettings[SelfServeSupportType.FoodRestaurant] = this.getEligibilityState(
SelfServeSupportType.FoodRestaurant
);

this.showSelfServeFoodSupport = true;
this.hasSelfServiceFoodRestaurantSupport = true;

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -130,7 +131,9 @@ export class EvacuationFileDataService {

hasActiveSupports(supports?: Array<Support>): 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<Support>): boolean {
Expand Down

0 comments on commit a3388b5

Please sign in to comment.