11import Controller from '@ember/controller' ;
22import { filterBy } from '@ember/object/computed' ;
33import { computed } from '@ember/object' ;
4+ import EmberTableMixin from 'open-event-frontend/mixins/ember-table' ;
5+
6+ export default class extends Controller . extend ( EmberTableMixin ) {
7+ // queryParams = ['page', 'per_page'];
8+ // page = 1;
9+ // per_page = 10;
10+ // search = null;
11+ // sort_dir = null;
12+ // sort_by = null;
13+ @filterBy ( 'model.eventInvoices' , 'status' , 'due' )
14+ dueInvoices ;
415
5- export default class extends Controller {
6- queryParams = [ 'page' , 'per_page' ] ;
7- page = 1 ;
8- per_page = 10 ;
9- search = null ;
10- sort_dir = null ;
11- sort_by = null ;
12- dueInvoices = filterBy ( 'model.eventInvoices' , 'status' , 'due' ) ;
13- paidInvoices = filterBy ( 'model.eventInvoices' , 'status' , 'paid' ) ;
16+ @filterBy ( 'model.eventInvoices' , 'status' , 'paid' )
17+ paidInvoices ;
1418
1519 @computed ( )
16- get columns ( ) {
20+ get dueInvoiceColumns ( ) {
1721 return [
1822 {
1923 name : 'Invoice ID' ,
20- valuePath : 'id'
24+ valuePath : 'invoiceId'
2125 } ,
2226 {
2327 name : 'Event Name' ,
@@ -34,9 +38,54 @@ export default class extends Controller {
3438 {
3539 name : 'View Invoice' ,
3640 valuePath : 'invoiceLink'
37- } ,
41+ }
42+
43+ ] ;
44+ }
3845
46+ @computed ( 'dueInvoices' )
47+ get dueInvoiceRows ( ) {
48+ const rows = [ ] ;
49+ this . dueInvoices . forEach ( row => {
50+ rows . pushObject ( {
51+ invoiceId : row . identifier ,
52+ eventName : row . event . name ,
53+ dateIssued : row . createdAt ,
54+ amount : row . amount ,
55+ invoiceLink : row . invoicePdfUrl
56+ } ) ;
57+ } ) ;
58+ return rows ;
59+ }
60+
61+ @computed ( 'paidInvoices' )
62+ get paidInvoiceRows ( ) {
63+ const rows = [ ] ;
64+ this . paidInvoices . forEach ( row => {
65+ rows . pushObject ( {
66+ invoiceId : row . identifier ,
67+ eventName : row . event . name ,
68+ dateIssued : row . createdAt ,
69+ amount : row . amount ,
70+ datePaid : row . completedAt ,
71+ invoiceLink : row . invoicePdfUrl
72+ } ) ;
73+ } ) ;
74+ return rows ;
75+ }
3976
40- ]
77+ @computed ( 'upcomingInvoices' )
78+ get upcomingInvoiceRows ( ) {
79+ const rows = [ ] ;
80+ this . upcomingInvoices . forEach ( row => {
81+ rows . pushObject ( {
82+ invoiceId : row . identifier ,
83+ eventName : row . event . name ,
84+ dateIssued : row . createdAt ,
85+ amount : row . amount ,
86+ invoiceLink : row . invoicePdfUrl
87+ } ) ;
88+ } ) ;
89+ return rows ;
4190 }
4291}
0 commit comments