Skip to content

Commit 0eb0ead

Browse files
committed
wip
1 parent f7c5d3d commit 0eb0ead

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

app/components/public/ticket-list.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,26 @@ export default Component.extend(FormMixin, {
3939

4040
invalidPromotionalCode: false,
4141

42-
tickets: computed(function() {
43-
return this.data.sortBy('position');
42+
tickets: computed('orderAmount', function() {
43+
const ticketMap = {};
44+
if (this.orderAmount) {
45+
this.orderAmount.tickets.forEach(ticket => {
46+
ticketMap[ticket.id] = ticket;
47+
});
48+
}
49+
50+
return this.data.sortBy('position').map(ticket => {
51+
const ticketExtra = ticketMap[ticket.id];
52+
53+
if (ticketExtra) {
54+
ticket.set('subTotal', ticketExtra.sub_total);
55+
ticket.set('discountInfo', ticketExtra.discount);
56+
}
57+
58+
return ticket;
59+
});
4460
}),
61+
4562
hasTicketsInOrder: computed('[email protected]', function() {
4663
return sumBy(this.tickets.toArray(),
4764
ticket => (ticket.orderQuantity || 0)
@@ -103,7 +120,6 @@ export default Component.extend(FormMixin, {
103120
this.tickets.removeObject(ticket);
104121
});
105122
this.discountedTickets.forEach(ticket => {
106-
let taxRate = ticket.get('event.tax.rate');
107123
ticket.set('discount', 0);
108124
});
109125
this.accessCodeTickets.clear();
@@ -164,8 +180,9 @@ export default Component.extend(FormMixin, {
164180
this.set('promotionalCode', 'Promotional code applied successfully');
165181
}
166182
this.order.set('amount', this.total);
167-
183+
this.send('updateOrderAmount');
168184
},
185+
169186
async updateOrder(ticket, count) {
170187
ticket.set('orderQuantity', count);
171188
this.order.set('amount', this.total);
@@ -179,8 +196,15 @@ export default Component.extend(FormMixin, {
179196
this.order.tickets.removeObject(ticket);
180197
}
181198
}
199+
200+
this.send('updateOrderAmount');
201+
},
202+
203+
async updateOrderAmount() {
182204
console.log(this.orderAmountInput);
183-
this.orderAmount = await this.loader.post('/orders/calculate-amount', this.orderAmountInput);
205+
206+
this.set('orderAmount', await this.loader.post('/orders/calculate-amount', this.orderAmountInput));
207+
184208
console.log(this.orderAmount);
185209
},
186210

app/templates/components/public/ticket-list.hbs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,7 @@
9393
</div>
9494
</td>
9595
<td id='{{ticket.id}}_subtotal' class="ui right aligned">
96-
{{#if this.taxInfo}}
97-
{{currency-symbol this.eventCurrency}}
98-
{{format-number (mult (sub ticket.ticketPriceWithTax ticket.discount) ticket.orderQuantity)}}
99-
{{else}}
100-
{{currency-symbol this.eventCurrency}} {{format-number (mult (sub ticket.price ticket.discount) ticket.orderQuantity)}}
101-
{{/if}}
96+
{{currency-symbol this.eventCurrency}} {{format-number ticket.subTotal}}
10297
</td>
10398
</tr>
10499
{{/unless}}

0 commit comments

Comments
 (0)