WEB-745: Fix unable to assign staff to active savings account (#3179)
This commit is contained in:
@@ -11,10 +11,14 @@ import { Injectable, inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable, forkJoin } from 'rxjs';
|
||||
import { Observable, forkJoin, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from '../savings.service';
|
||||
import { ClientsService } from 'app/clients/clients.service';
|
||||
import { GroupsService } from 'app/groups/groups.service';
|
||||
import { OrganizationService } from 'app/organization/organization.service';
|
||||
|
||||
/**
|
||||
* Savings Account Actions data resolver.
|
||||
@@ -22,6 +26,9 @@ import { SavingsService } from '../savings.service';
|
||||
@Injectable()
|
||||
export class SavingsAccountActionsResolver {
|
||||
private savingsService = inject(SavingsService);
|
||||
private clientsService = inject(ClientsService);
|
||||
private groupsService = inject(GroupsService);
|
||||
private organizationService = inject(OrganizationService);
|
||||
|
||||
/**
|
||||
* Returns the Savings account actions data.
|
||||
@@ -34,7 +41,23 @@ export class SavingsAccountActionsResolver {
|
||||
route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId');
|
||||
switch (actionName) {
|
||||
case 'Assign Staff':
|
||||
return this.savingsService.getSavingsAccountAndTemplate(savingAccountId, true);
|
||||
return this.savingsService.getSavingsAccountData(savingAccountId).pipe(
|
||||
switchMap((account: any) => {
|
||||
if (!account.clientId && !account.groupId) {
|
||||
return of({ ...account, fieldOfficerOptions: [] });
|
||||
}
|
||||
const entityObs = account.clientId
|
||||
? this.clientsService.getClientData(account.clientId)
|
||||
: this.groupsService.getGroupData(account.groupId);
|
||||
return entityObs.pipe(
|
||||
switchMap((entity: any) => this.organizationService.getStaff(entity.officeId, true)),
|
||||
map((staff: any) => ({
|
||||
...account,
|
||||
fieldOfficerOptions: staff
|
||||
}))
|
||||
);
|
||||
})
|
||||
);
|
||||
case 'Add Charge':
|
||||
return this.savingsService.getSavingsChargeTemplateResource(savingAccountId);
|
||||
case 'Withdrawal':
|
||||
|
||||
Reference in New Issue
Block a user