Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMBCESS-5266 EMBCESS-5267 self serve eligibility, support detail form bug fixes #2123

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
38879cd
WIP Setup Self serve support stepper form
Apr 22, 2024
1c3ebef
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
Apr 22, 2024
570e3e5
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
Apr 22, 2024
960f40f
working eligible self serve confirmation screen
Apr 23, 2024
a092978
format files
Apr 23, 2024
4958771
fix lint issues
Apr 23, 2024
797bfd3
download images to show in the app
Apr 23, 2024
cacc59f
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
Apr 23, 2024
d21128f
wip
Apr 24, 2024
834c7b8
Refactor support forms
Apr 25, 2024
87b0a48
Merge remote-tracking branch 'bcgov/release/R3.2.0' into hemanth/reba…
Apr 25, 2024
1c9e826
Merge remote-tracking branch 'bcgov/release/R3.2.0' into hemanth/reba…
Apr 26, 2024
6b37cba
Upgrade ng-opengen-api
Apr 29, 2024
be2c372
setup types forms for self serve support details form
Apr 29, 2024
6e3d97e
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
Apr 29, 2024
4039ca5
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
Apr 29, 2024
f360cc5
Get draft data and show it in the forms
Apr 30, 2024
5f9eb21
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 1, 2024
3960f8c
Setup optout dialog component
May 2, 2024
99a7bbf
Setup etransfer and review steps
May 2, 2024
c26f9da
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 2, 2024
1caccd5
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 3, 2024
1952424
Fix loading screen
May 3, 2024
f91fad5
Merge branch 'stories/EMBCESS-5136' into stories/EMBCESS-5139-self-se…
May 3, 2024
e79a256
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 5, 2024
300efbf
Fix etransfer and review forms steps
May 7, 2024
ab1c8ca
setup submission dialog
May 7, 2024
bf30936
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 7, 2024
a64386c
fix lint issues
May 7, 2024
acc4dbf
fix formating
May 7, 2024
5bac4f0
Refactor and rename files to follow the project conventions
May 8, 2024
7b27728
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 8, 2024
b386e35
fix css and formatting
May 8, 2024
0b6b5bc
fix typo
May 8, 2024
b7dcfbd
Fix goto previous page from evacuation details
May 8, 2024
fdd79b0
Merge remote-tracking branch 'bcgov/release/R3.2.0' into stories/EMBC…
May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2 class="highlightText">
Proceed With e-Transfer
</button>
<div>
<a class="highlightText" style="cursor: pointer" (click)="optOutSelfServe()">
<a class="highlightText" style="cursor: pointer; text-decoration: none" (click)="optOutSelfServe()">
Opt-out and Receive Supports via Referrals
</a>
<button mat-icon-button (click)="openInteracOptOutDialog()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
SelfServeFoodRestaurantSupport,
SelfServeIncidentalsSupport,
SelfServeShelterAllowanceSupport,
SelfServeSupportType
SelfServeSupportType,
SupportDayMeals
} from 'src/app/core/api/models';
import * as moment from 'moment';

Expand Down Expand Up @@ -117,10 +118,76 @@ export class SelfServeSupportDetailsFormComponent {
);
});

const originalMealSupportsDraft: Record<string, SupportDayMeals> = {};

this.supportDraftForm.controls.food.controls.restaurant.controls.mealTypes.valueChanges.subscribe({
next: () => {
// get all unchecked and undisabled control
const unCheckedControls: Record<string, FormControl[]> = {
breakfast: [],
lunch: [],
dinner: []
};

const checkedCount: Record<string, number> = {
breakfast: 0,
lunch: 0,
dinner: 0
};

this.supportDraftForm.controls.food.controls.restaurant.controls.mealTypes.controls.forEach((meal) => {
if (meal.controls.breakfast.value === true) checkedCount.breakfast++;
else if (
originalMealSupportsDraft[meal.controls.date.value.format('YYYY-MM-DD')].breakfast === true ||
originalMealSupportsDraft[meal.controls.date.value.format('YYYY-MM-DD')].breakfast === false
)
unCheckedControls.breakfast.push(meal.controls.breakfast);

if (meal.controls.lunch.value === true) checkedCount.lunch++;
else if (
originalMealSupportsDraft[meal.controls.date.value.format('YYYY-MM-DD')].lunch === true ||
originalMealSupportsDraft[meal.controls.date.value.format('YYYY-MM-DD')].lunch === false
)
unCheckedControls.lunch.push(meal.controls.lunch);

if (meal.controls.dinner.value === true) checkedCount.dinner++;
else if (
originalMealSupportsDraft[meal.controls.date.value.format('YYYY-MM-DD')].dinner === true ||
originalMealSupportsDraft[meal.controls.date.value.format('YYYY-MM-DD')].dinner === false
)
unCheckedControls.dinner.push(meal.controls.dinner);
});

// @Note: Only 3 dates can be checked per meal type
// check count of selected checkboxes are 3 then disable the first unchecked
if (checkedCount.breakfast >= 3) {
unCheckedControls.breakfast.forEach((c) => c.disable({ emitEvent: false }));
} else {
unCheckedControls.breakfast.forEach((c) => c.enable({ emitEvent: false }));
}

if (checkedCount.lunch >= 3) {
unCheckedControls.lunch.forEach((c) => c.disable({ emitEvent: false }));
} else {
unCheckedControls.lunch.forEach((c) => c.enable({ emitEvent: false }));
}

if (checkedCount.dinner >= 3) {
unCheckedControls.dinner.forEach((c) => c.disable({ emitEvent: false }));
} else {
unCheckedControls.dinner.forEach((c) => c.enable({ emitEvent: false }));
}
}
});

selfServeSupport.meals.forEach((m) => {
const date = moment(m.date, 'YYYY-MM-DD');

originalMealSupportsDraft[date.format('YYYY-MM-DD')] = m;

this.supportDraftForm.controls.food.controls.restaurant.controls.mealTypes.push(
new FormGroup<SelfServeSupportDayMealForm>({
date: new FormControl(moment(m.date, 'YYYY-MM-DD')),
date: new FormControl(date),
breakfast: new FormControl({ value: m.breakfast, disabled: m.breakfast !== true && m.breakfast !== false }),
lunch: new FormControl({ value: m.lunch, disabled: m.lunch !== true && m.lunch !== false }),
dinner: new FormControl({ value: m.dinner, disabled: m.dinner !== true && m.dinner !== false })
Expand All @@ -132,9 +199,9 @@ export class SelfServeSupportDetailsFormComponent {
next: (includedHouseholdMembers) => {
if (includedHouseholdMembers.every((m) => !m.isSelected)) {
this.supportDraftForm.controls.food.controls.restaurant.controls.mealTypes.controls.forEach((m) => {
if (m.controls.breakfast.value === true) m.controls.breakfast.setValue(false);
if (m.controls.lunch.value === true) m.controls.lunch.setValue(false);
if (m.controls.dinner.value === true) m.controls.dinner.setValue(false);
if (m.controls.breakfast.value === true) m.controls.breakfast.setValue(false, { emitEvent: false });
if (m.controls.lunch.value === true) m.controls.lunch.setValue(false, { emitEvent: false });
if (m.controls.dinner.value === true) m.controls.dinner.setValue(false, { emitEvent: false });
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { AppLoaderComponent } from 'src/app/core/components/app-loader/app-loade
import { tap } from 'rxjs';
import { MatSelectModule } from '@angular/material/select';
import { CustomValidationService } from 'src/app/core/services/customValidation.service';
import { IMaskDirective } from 'angular-imask';
import { ProfileDataService } from '../profile/profile-data.service';
import { ETransferNotificationPreference } from 'src/app/core/model/e-transfer-notification-preference.model';
import {
Expand All @@ -41,7 +40,7 @@ import {
SupportPersonForm,
SelfServeIncidentsSupportForm,
ETransferDetailsForm,
SelfServeSupportDayMealForm
SelfServeFoodGroceriesSupportForm
} from './self-serve-support.model';
import { SelfServeSupportDetailsFormComponent } from './self-serve-support-details-form/self-serve-support-details-form.component';
import { SelfServeSupportInteracETransfterFormComponent } from './self-serve-interac-e-transfer-form/self-serve-support-interac-e-transfer-form.component';
Expand Down Expand Up @@ -296,8 +295,10 @@ export class SelfServeSupportFormComponent implements OnInit {
}
}

processShelterAllowanceData(): SelfServeShelterAllowanceSupport | null {
const supportFormValue = this.supportDraftForm.value.shelterAllowance;
processShelterAllowanceData(
supportForm: FormGroup<SelfServeShelerAllowanceSupportForm>
): SelfServeShelterAllowanceSupport | null {
const supportFormValue = supportForm.value;

const data: SelfServeShelterAllowanceSupport & { $type: 'SelfServeShelterAllowanceSupport' } = {
$type: 'SelfServeShelterAllowanceSupport',
Expand All @@ -314,61 +315,56 @@ export class SelfServeSupportFormComponent implements OnInit {
return data;
}

processFoodGroceriesData(): SelfServeFoodGroceriesSupport | null {
const supportFormValue = this.supportDraftForm.value.food;
processFoodGroceriesData(
supportForm: FormGroup<SelfServeFoodGroceriesSupportForm>
): SelfServeFoodGroceriesSupport | null {
const supportFormValue = supportForm.value;

if (supportFormValue.fundsFor === SelfServeSupportType.FoodGroceries) {
const data: SelfServeFoodGroceriesSupport & { $type: 'SelfServeFoodGroceriesSupport' } = {
$type: 'SelfServeFoodGroceriesSupport',
type: SelfServeSupportType.FoodGroceries,
totalAmount: 34
};
const data: SelfServeFoodGroceriesSupport & { $type: 'SelfServeFoodGroceriesSupport' } = {
$type: 'SelfServeFoodGroceriesSupport',
type: SelfServeSupportType.FoodGroceries,
totalAmount: supportFormValue.totalAmount
};

const supportDays: Record<string, SupportDay> = this.getSupportDays(
this.supportDraftForm.controls.food.controls.groceries.controls.nights
);
const supportDays: Record<string, SupportDay> = this.getSupportDays(supportForm.controls.nights);

data.nights = Object.values(supportDays);
data.nights = Object.values(supportDays);

return data;
}

return null;
return data;
}

processFoodRestaurantData(): SelfServeFoodRestaurantSupport | null {
const supportFormValue = this.supportDraftForm.value.food;

if (supportFormValue.fundsFor === SelfServeSupportType.FoodRestaurant) {
const data: SelfServeFoodRestaurantSupport & { $type: 'SelfServeFoodRestaurantSupport' } = {
$type: 'SelfServeFoodRestaurantSupport',
type: SelfServeSupportType.FoodRestaurant,
totalAmount: 234,
includedHouseholdMembers: [],
meals: []
};

data.includedHouseholdMembers = supportFormValue.restaurant.includedHouseholdMembers
.filter((p) => p.isSelected)
.map((p) => p.personId);

data.meals = supportFormValue.restaurant.mealTypes
.filter((m) => m.breakfast || m.lunch || m.dinner)
.map((m) => ({
breakfast: m.breakfast,
lunch: m.lunch,
dinner: m.dinner,
date: m.date.format('YYYY-MM-DD')
}));

return data;
}
processFoodRestaurantData(
supportForm: FormGroup<SelfServeFoodRestaurantSupportForm>
): SelfServeFoodRestaurantSupport | null {
const supportFormValue = supportForm.value;

const data: SelfServeFoodRestaurantSupport & { $type: 'SelfServeFoodRestaurantSupport' } = {
$type: 'SelfServeFoodRestaurantSupport',
type: SelfServeSupportType.FoodRestaurant,
totalAmount: supportFormValue.totalAmount,
includedHouseholdMembers: [],
meals: []
};

data.includedHouseholdMembers = supportFormValue.includedHouseholdMembers
.filter((p) => p.isSelected)
.map((p) => p.personId);

data.meals = supportFormValue.mealTypes
.filter((m) => m.breakfast || m.lunch || m.dinner)
.map((m) => ({
breakfast: m.breakfast,
lunch: m.lunch,
dinner: m.dinner,
date: m.date.format('YYYY-MM-DD')
}));

return null;
return data;
}

processClothing() {
const supportFormValue = this.supportDraftForm.value.clothing;
processClothing(supportForm: FormGroup<SelfServeClothingSupportForm>) {
const supportFormValue = supportForm.value;

const data: SelfServeClothingSupport & { $type: 'SelfServeClothingSupport' } = {
$type: 'SelfServeClothingSupport',
type: SelfServeSupportType.Clothing,
Expand All @@ -382,8 +378,9 @@ export class SelfServeSupportFormComponent implements OnInit {
return data;
}

processIncidents() {
const supportFormValue = this.supportDraftForm.value.incidents;
processIncidents(supportForm: FormGroup<SelfServeIncidentsSupportForm>) {
const supportFormValue = supportForm.value;

const data: SelfServeIncidentalsSupport & { $type: 'SelfServeIncidentalsSupport' } = {
$type: 'SelfServeIncidentalsSupport',
type: SelfServeSupportType.Incidentals,
Expand Down Expand Up @@ -422,27 +419,37 @@ export class SelfServeSupportFormComponent implements OnInit {
this.draftSupports.items.forEach((support) => {
switch (support.type) {
case SelfServeSupportType.ShelterAllowance:
const processShelterAllowance = this.processShelterAllowanceData();
const processShelterAllowance = this.processShelterAllowanceData(
this.supportDraftForm.controls.shelterAllowance
);
if (processShelterAllowance) selfServeSupportRequest.supports.push(processShelterAllowance);
break;

case SelfServeSupportType.FoodGroceries:
const processFoodGroceries = this.processFoodGroceriesData();
if (processFoodGroceries) selfServeSupportRequest.supports.push(processFoodGroceries);
if (this.supportDraftForm.controls.food.controls.fundsFor.value === SelfServeSupportType.FoodGroceries) {
const processFoodGroceries = this.processFoodGroceriesData(
this.supportDraftForm.controls.food.controls.groceries
);
if (processFoodGroceries) selfServeSupportRequest.supports.push(processFoodGroceries);
}
break;

case SelfServeSupportType.FoodRestaurant:
const processFoodRestaurant = this.processFoodRestaurantData();
if (processFoodRestaurant) selfServeSupportRequest.supports.push(processFoodRestaurant);
if (this.supportDraftForm.controls.food.controls.fundsFor.value === SelfServeSupportType.FoodRestaurant) {
const processFoodRestaurant = this.processFoodRestaurantData(
this.supportDraftForm.controls.food.controls.restaurant
);
if (processFoodRestaurant) selfServeSupportRequest.supports.push(processFoodRestaurant);
}
break;

case SelfServeSupportType.Clothing:
const processClothing = this.processClothing();
const processClothing = this.processClothing(this.supportDraftForm.controls.clothing);
if (processClothing) selfServeSupportRequest.supports.push(processClothing);
break;

case SelfServeSupportType.Incidentals:
const processIncidents = this.processIncidents();
const processIncidents = this.processIncidents(this.supportDraftForm.controls.incidents);
if (processIncidents) selfServeSupportRequest.supports.push(processIncidents);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export class DashboardComponent implements OnInit {
const registrationResult = this.needsAssessmentService.getVerifiedEvacuationFileNo();

if (registrationResult !== null) {
const { selfServe, supportData } = this.router.lastSuccessfulNavigation.extras.state;
const { selfServe = null, supportData = null } = this.router.lastSuccessfulNavigation.extras?.state ?? {
selfServe: false,
supportData: null
};

if (selfServe) {
this.dialog
.open(SelfServeSubmissionDialogComponent, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { MatCardModule } from '@angular/material/card';
})
export class EvacuationDetailsComponent implements OnInit, AfterViewInit {
@Input() allExpandState = false;
previousUrl: string;
evacuationFileTab: string;
backArrowImgSrc = '/assets/images/back_arrow.svg';
type = 'need';
Expand All @@ -48,14 +47,10 @@ export class EvacuationDetailsComponent implements OnInit, AfterViewInit {
public evacuationFileDataService: EvacuationFileDataService,
private datePipe: DatePipe,
private cd: ChangeDetectorRef
) {
this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => {
this.previousUrl = event.url;
});
}
) {}

ngOnInit(): void {
if (this.previousUrl?.includes('current')) {
if (this.router.url?.includes('current')) {
this.evacuationFileTab = 'Current';
} else {
this.evacuationFileTab = 'Past';
Expand All @@ -82,7 +77,7 @@ export class EvacuationDetailsComponent implements OnInit, AfterViewInit {
}

goToCurrent(): void {
if (this.previousUrl.includes('current')) {
if (this.router.url.includes('current')) {
this.router.navigate(['/verified-registration/dashboard/current']);
} else {
this.router.navigate(['/verified-registration/dashboard/past']);
Expand Down