-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathcollection-list.component.ts
75 lines (70 loc) · 2.25 KB
/
collection-list.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Component, OnInit, ViewChild } from '@angular/core';
import { HttpService } from '../../services/http.service';
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
import { UtilsService } from '../../services/utils.service';
@Component({
selector: 'app-collection-list',
templateUrl: './collection-list.component.html',
styleUrls: ['./collection-list.component.scss']
})
export class CollectionListComponent implements OnInit {
customerDetailsPage = 'paymentCustomerDetails';
paymentDetailsPage = 'paymentDetails';
collectionData = [];
displayedColumns: string[] = [
'customer_name',
'total',
'grant_total',
'paid',
'edit',
'history'
];
dataSource;
@ViewChild(MatPaginator)
paginator: MatPaginator;
@ViewChild(MatSort)
sort: MatSort;
constructor(private http: HttpService, private _utils: UtilsService) {}
ngOnInit() {
this.collectionList();
}
collectionList() {
// const sheetParams =
// 'action=read&sheet_name=' +
// this.customerDetailsPage +
// '&page=' +
// this.paymentDetailsPage;
const sheetParams = {
action: 'read',
sheet_name: this.customerDetailsPage,
page: this.paymentDetailsPage
};
this.http.apiGet(sheetParams).subscribe(data => {
this.collectionData = data['records'];
this.dataSource = new MatTableDataSource();
this.dataSource.data = this.collectionData;
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
console.log(this.dataSource);
});
}
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
}
updateAmount(amountValue: number, currentPayment) {
console.log(amountValue, currentPayment);
currentPayment['payment_id'] = this._utils.generateUUID();
currentPayment['paid'] = amountValue;
currentPayment['is_paid'] = true;
currentPayment['action'] = 'insert';
currentPayment['sheet_name'] = this.paymentDetailsPage;
console.log({ currentPayment });
// this.http.apiGet()
this.http.apiGet(currentPayment).subscribe(data => {
console.log('Return data : ', data);
});
}
}