Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Show "Free" instead of $0.00 in ticket price #5369

Merged
merged 8 commits into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/templates/components/orders/order-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@
{{ticket.name}}
</div>
</td>
<td>{{currency-symbol this.eventCurrency}} {{format-money ticket.price}}</td>
<td>
<Orders::TicketPrice
@ticket={{ticket}}
@currency={{this.eventCurrency}}
@amount={{ticket.price}} />
</td>
{{#if this.data.discountCode}}
<td>{{currency-symbol this.eventCurrency}} {{format-money ticket.discount}}</td>
{{/if}}
Expand All @@ -107,7 +112,10 @@
</td>
{{/if}}
<td>
{{currency-symbol this.eventCurrency}} {{format-money (mult (sub ticket.price ticket.discount) (ticket-attendees this.data.attendees ticket.attendees))}}
<Orders::TicketPrice
@ticket={{ticket}}
@currency={{this.eventCurrency}}
@amount={{mult (sub ticket.price ticket.discount) (ticket-attendees this.data.attendees ticket.attendees)}} />
</td>
{{/if}}

Expand Down
5 changes: 5 additions & 0 deletions app/templates/components/orders/ticket-price.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{#if (eq @ticket.type 'free')}}
{{t "Free"}}
{{else}}
{{currency-symbol @currency}} {{format-money @amount}}
{{/if}}
10 changes: 8 additions & 2 deletions app/templates/components/public/ticket-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
</div>
{{else}}
<div class="{{if ticket.discount 'strike text'}}">
{{currency-symbol this.eventCurrency}} {{format-money ticket.price}}
<Orders::TicketPrice
@ticket={{ticket}}
@currency={{this.eventCurrency}}
@amount={{ticket.price}} />
</div>
{{#if ticket.discount}}
<div>
Expand Down Expand Up @@ -96,7 +99,10 @@
</div>
</td>
<td id='{{ticket.id}}_subtotal' class="ui right aligned">
{{currency-symbol this.eventCurrency}} {{format-money ticket.subTotal}}
<Orders::TicketPrice
@ticket={{ticket}}
@currency={{this.eventCurrency}}
@amount={{ticket.subTotal}} />
</td>
</tr>
{{/unless}}
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/components/orders/ticket-price-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
import { setupIntegrationTest } from 'open-event-frontend/tests/helpers/setup-integration-test';
import { render } from '@ember/test-helpers';

module('Integration | Component | orders/ticket price', function(hooks) {
setupIntegrationTest(hooks);

test('it renders', async function(assert) {
this.set('ticket', { type: 'free' });
this.set('currency', 'USD');
this.set('amount', 53.432);
await render(hbs`{{orders/ticket-price ticket=ticket currency=currency amount=amount}}`);
assert.equal(this.element.textContent?.trim(), 'Free');

this.set('ticket', { type: 'paid' });
assert.equal(this.element.textContent?.trim(), '$ 53.43');

this.set('currency', 'GBP');
assert.equal(this.element.textContent?.trim(), '£ 53.43');
});
});