refactor(client): refactor clients component (#109)

* refactor(client): refactor clients component
This commit is contained in:
Anwesh Nayak
2018-07-08 05:45:46 +05:30
committed by GitHub
parent d7c098fd5c
commit c48daa2703
2 changed files with 22 additions and 5 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ import { map } from 'rxjs/operators';
export class ClientsService {
constructor(private http: Http) {} // tslint:disable-line
createAuthorizationHeader(headers: Headers) {
createAuthorizationHeader(headers: Headers) { // tslint:disable-line
const username = 'mifos';
const password = 'password';
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
@@ -12,7 +12,7 @@ import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
encapsulation: ViewEncapsulation.None
})
export class ViewClientComponent implements OnInit, OnDestroy {
id: number = undefined;
public id: number = undefined;
loanAccounts: any = undefined;
savingsAccounts: any = undefined;
shareAccounts: any = undefined;
@@ -42,7 +42,15 @@ export class ViewClientComponent implements OnInit, OnDestroy {
this.id = params['id'];
}
);
this.clientService.getClientId(this.id)
this.getClientId(this.id);
this.getClientAccounts(this.id);
this.getClientCharges(this.id);
this.getClientAddress(this.id);
}
getClientId(id: any) {
this.clientService.getClientId(id)
.subscribe(
(res => {
const groupArray = new Array;
@@ -57,7 +65,10 @@ export class ViewClientComponent implements OnInit, OnDestroy {
})
);
this.clientService.getClientAccounts(this.id)
}
getClientAccounts(id: any) {
this.clientService.getClientAccounts(id)
.subscribe(
(res => {
this.loanAccounts = res['loanAccounts'];
@@ -71,12 +82,18 @@ export class ViewClientComponent implements OnInit, OnDestroy {
this.dataSourceShares = new MatTableDataSource(this.SHARES_DATA);
})
);
this.clientService.getClientCharges(this.id)
}
getClientCharges(id: any) {
this.clientService.getClientCharges(id)
.subscribe(
(res => {
this.upcomingCharges = res['pageItems'];
})
);
}
getClientAddress(id: any) {
this.clientService.getClientAddress(this.id)
.subscribe(
(res => {