Skip to content

Commit 5a2317f

Browse files
committed
Semantic tables for invoices
Added logic to fetch event-invoice data & filters Fix eslint issues Added date paid Fixed ESlint issues Return promises at route level used async
1 parent 928f7d1 commit 5a2317f

File tree

3 files changed

+111
-5
lines changed

3 files changed

+111
-5
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Controller from '@ember/controller';
2+
import { filterBy } from '@ember/object/computed';
3+
4+
export default Controller.extend({
5+
dueInvoices : filterBy('model.eventInvoices', 'status', 'due'),
6+
paidInvoices : filterBy('model.eventInvoices', 'status', 'paid')
7+
8+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
import Route from '@ember/routing/route';
2+
import RSVP from 'rsvp';
3+
import moment from 'moment';
24

35
export default Route.extend({
6+
async model() {
7+
let filterOptions = [];
8+
filterOptions = [
9+
{
10+
and: [
11+
{
12+
name : 'deleted-at',
13+
op : 'eq',
14+
val : null
15+
},
16+
{
17+
name : 'created-at',
18+
op : 'ge',
19+
val : moment().subtract(30, 'days').toISOString()
20+
}
21+
]
22+
}
23+
];
24+
return RSVP.hash({
25+
eventInvoices: this.store.query('event-invoice', {
26+
include: 'event'
27+
}),
28+
upcomingInvoices: this.store.query('event-invoice', {
29+
filter : filterOptions,
30+
include : 'event'
31+
})
32+
});
33+
}
434
});
Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,82 @@
11
<div class="ui grid stackable">
2-
<div class="thirteen wide column">
2+
<div class="sixteen wide column">
33
<h2 class="ui header column">{{t 'Due Invoices'}}</h2>
4+
<table class="ui stackable structured celled compact table">
5+
<thead>
6+
<tr>
7+
<th>Invoice ID</th>
8+
<th>Event Name</th>
9+
<th>Date Issued</th>
10+
<th>Amount</th>
11+
<th>View Invoice</th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
{{#each dueInvoices as |dueInvoice|}}
16+
<tr>
17+
<td>{{dueInvoice.identifier}}</td>
18+
<td>{{dueInvoice.event.name}}</td>
19+
<td>{{dueInvoice.createdAt}}</td>
20+
<td>{{dueInvoice.amount}}</td>
21+
<td><button class="ui button primary">{{t 'View Invoice'}}</button></td>
22+
</tr>
23+
{{/each}}
24+
</tbody>
25+
</table>
426
</div>
527
<div class="ui hidden divider"></div>
6-
<div class="thirteen wide column">
7-
<h2 class="ui header column">{{t 'Upcoming Invoices'}}</h2>
28+
<div class="sixteen wide column">
29+
<h2 class="ui header column">{{t 'Paid Invoices'}}</h2>
30+
<table class="ui stackable structured celled compact table">
31+
<thead>
32+
<tr>
33+
<th>Invoice ID</th>
34+
<th>Event Name</th>
35+
<th>Date Issued</th>
36+
<th>Amount</th>
37+
<th>Date Paid</th>
38+
<th>View Invoice</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
{{#each paidInvoices as |paidInvoice|}}
43+
<tr>
44+
<td>{{paidInvoice.identifier}}</td>
45+
<td>{{paidInvoice.event.name}}</td>
46+
<td>{{paidInvoice.createdAt}}</td>
47+
<td>{{dueInvoice.amount}}</td>
48+
<td><button class="ui button primary">{{t 'View Invoice'}}</button></td>
49+
<td>{{paidInvoice.completedAt}}</td>
50+
</tr>
51+
{{/each}}
52+
</tbody>
53+
</table>
854
</div>
955
<div class="ui hidden divider"></div>
10-
<div class="thirteen wide column">
11-
<h2 class="ui header column">{{t 'Paid Invoices'}}</h2>
56+
<div class="sixteen wide column">
57+
<h2 class="ui header column">{{t 'Upcoming Invoices'}}</h2>
58+
<table class="ui stackable structured celled compact table">
59+
<thead>
60+
<tr>
61+
<th>Invoice ID</th>
62+
<th>Event Name</th>
63+
<th>Date Issued</th>
64+
<th>Amount Due</th>
65+
<th>View Invoice</th>
66+
</tr>
67+
</thead>
68+
<tbody>
69+
{{#each model.upcomingInvoices as |upcomingInvoice|}}
70+
<tr>
71+
<td>{{upcomingInvoice.identifier}}</td>
72+
<td>{{upcomingInvoice.event.name}}</td>
73+
<td>{{upcomingInvoice.createdAt}}</td>
74+
<td>{{upcomingInvoice.amount}}</td>
75+
<td><button class="ui button primary">{{t 'View Invoice'}}</button></td>
76+
</tr>
77+
{{/each}}
78+
</tbody>
79+
</table>
1280
</div>
1381
<div class="ui hidden divider"></div>
1482
</div>

0 commit comments

Comments
 (0)