Skip to content

Commit

Permalink
Merge branch 'speak-notif-5309' of https://github.com/daretobediffere…
Browse files Browse the repository at this point in the history
…nt18/open-event-frontend into speak-notif-5309
  • Loading branch information
daretobedifferent18 committed Nov 2, 2020
2 parents c641fa1 + 4204a26 commit 4c4bf22
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 156 deletions.
38 changes: 35 additions & 3 deletions app/components/forms/orders/guest-order-form.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import FormMixin from 'open-event-frontend/mixins/form';

export default Component.extend(FormMixin, {
autoScrollToErrors: false,
autoScrollToErrors : false,
showPasswordForm : false,

nextStep: computed('userExists', 'showPasswordForm', function() {
return this.userExists || this.showPasswordForm;
}),

getValidationRules() {
return {
Expand All @@ -23,12 +29,27 @@ export default Component.extend(FormMixin, {
}
]
},

password: {
identifier : 'password',
rules : [
{
type : 'empty',
prompt : this.l10n.t('Please enter your password')
},
{
type : 'minLength[8]',
prompt : this.l10n.t('Your password must have at least {ruleValue} characters')
}
]
},

passwordRepeat: {
identifier : 'password_repeat',
rules : [
{
type : 'match[password]',
prompt : this.l10n.t('Passwords do not match')
}
]
}
Expand All @@ -37,13 +58,24 @@ export default Component.extend(FormMixin, {
},
actions: {
submit() {
this.onValid(() => {
this.onValid(async() => {
if (this.userExists) {
this.loginExistingUser(this.email, this.password);
} else if (this.password) {
this.createNewUserViaEmail(this.email, this.password);
} else {
this.createNewUserViaEmail(this.email);
const result = await this.loader.post('users/check_email', { email: this.email });
this.set('userExists', result.exists);
if (!result.exists) {
this.set('showPasswordForm', true);
}
}
});
},
reset() {
this.set('userExists', false);
this.set('showPasswordForm', false);
this.set('password', null);
}
}
});
6 changes: 3 additions & 3 deletions app/controllers/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export default class IndexController extends Controller {
}

@action
async createNewUserViaEmail(email) {
async createNewUserViaEmail(email, password) {
this.set('isLoading', true);
const newUser = this.store.createRecord('user', {
email,
'password' : (Math.random() * 10).toString(16),
'wasRegisteredWithOrder' : true
password,
'wasRegisteredWithOrder': true
});
newUser.save()
.then(() => {
Expand Down
12 changes: 10 additions & 2 deletions app/routes/account/danger-zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ export default class DangerZoneRoute extends Route.extend(AuthenticatedRouteMixi
}

async model() {

const user = this.authManager.currentUser;

const filter = [{
or: ['completed', 'placed', 'pending', 'initializing'].map(val => ({
name : 'status',
op : 'eq',
val
}))
}];

const events = await user.query('events', {});
const orders = await user.query('orders', {});
const orders = await user.query('orders', { filter });

return {
user,
Expand Down
19 changes: 16 additions & 3 deletions app/templates/components/forms/orders/guest-order-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<h4 class="ui header">{{t 'Please enter your email address to continue.'}}</h4>
<div class="field">
<div class="ui icon input">
<Input @type="text" @name="email" @value={{this.email}} @disabled={{this.userExists}} placeholder={{t "Email Address"}} />
{{#if this.userExists}}
<i class="circular undo link icon" role="button" onclick={{action (mut this.userExists) false}}></i>
<Input @type="text" @name="email" @value={{this.email}} @disabled={{this.nextStep}} placeholder={{t "Email Address"}} />
{{#if this.nextStep}}
<i class="circular undo link icon" role="button" onclick={{action 'reset'}}></i>
{{/if}}
</div>
</div>
Expand All @@ -25,6 +25,19 @@
<button type="submit" class="ui blue button">
{{t 'Sign In'}}
</button>
{{else if this.showPasswordForm}}
<div class="ui text muted">{{t 'Please set up a password to continue.'}}</div>
<div class="field">
<label class="required" for="password">{{t 'Password'}}</label>
<Input @type="password" @name="password" @value={{this.password}} />
</div>
<div class="field">
<label class="required" for="password_repeat">{{t 'Confirm Password'}}</label>
<Input @type="password" @name="password_repeat" />
</div>
<button type="submit" class="ui blue button">
{{t 'Register'}}
</button>
{{else}}
<button type="submit" class="ui green button">
{{t 'Continue'}}
Expand Down
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}}
6 changes: 5 additions & 1 deletion app/templates/components/public/call-for-speakers.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
{{/unless}}
<div class="ui hidden divider"></div>
{{#if this.isNewSession}}
<p>{{t 'No session have been submitted'}}</p>
{{#if this.authManager.currentUser}}
<p>{{t 'You have not submitted any sessions.'}}</p>
{{else}}
<p>{{t 'You need to login to submit and view sessions.'}}</p>
{{/if}}
{{/if}}
{{#if this.data.speakersCall.isOpen}}
{{#if this.isNewSpeaker}}
Expand Down
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@glimmer/tracking": "^1.0.2",
"@open-event/theme": "^0.2.2",
"@sentry/browser": "^5.27.2",
"@sentry/integrations": "^5.27.1",
"@sentry/tracing": "^5.27.1",
"@sentry/integrations": "^5.27.2",
"@sentry/tracing": "^5.27.2",
"@types/ember": "^3.16.2",
"@types/ember-data": "^3.16.6",
"@types/ember-qunit": "^3.4.13",
Expand Down Expand Up @@ -109,7 +109,7 @@
"ember-href-to": "4.1.0",
"ember-infinity": "^2.1.2",
"ember-l10n": "^4.3.1",
"ember-link-action": "2.0.0",
"ember-link-action": "2.0.2",
"ember-load-initializers": "^2.1.1",
"ember-math-helpers": "^2.15.0",
"ember-maybe-import-regenerator": "^0.1.6",
Expand Down Expand Up @@ -146,7 +146,7 @@
"pre-commit": "^1.2.2",
"query-string": "^6.13.6",
"qunit-dom": "^1.5.0",
"sass": "^1.27.1",
"sass": "^1.28.0",
"semantic-ui-calendar": "^0.0.8",
"semantic-ui-ember": "3.0.4",
"string_decoder": "^1.3.0",
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');
});
});
Loading

0 comments on commit 4c4bf22

Please sign in to comment.