Skip to content
Merged
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
46 changes: 23 additions & 23 deletions app/components/forms/user-payment-info-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import Component from '@ember/component';
import FormMixin from 'open-event-frontend/mixins/form';
import { validPhoneNumber } from 'open-event-frontend/utils/validators';
import { pick, orderBy } from 'lodash-es';
import { action, computed } from '@ember/object';
import { computed } from '@ember/object';
import { countries } from 'open-event-frontend/utils/dictionary/demography';

export default class extends Component.extend(FormMixin) {
export default Component.extend(FormMixin, {
didInsertElement() {
super.didInsertElement(...arguments);
this._super(...arguments);
this.set('userBillingInfo', pick(this.authManager.currentUser, ['billingContactName', 'billingCity', 'billingPhone', 'company', 'billingTaxInfo', 'billingCountry', 'billingState', 'billingAddress', 'billingZipCode', 'billingAdditionalInfo']));
}
},

getValidationRules() {
return {
Expand Down Expand Up @@ -88,26 +88,26 @@ export default class extends Component.extend(FormMixin) {
}
}
};
}
},

@computed()
get countries() {
countries: computed(function() {
return orderBy(countries, 'name');
}
}),

@action
submit() {
this.onValid(async() => {
this.set('isLoading', true);
try {
this.authManager.currentUser.setProperties(this.userBillingInfo);
await this.authManager.currentUser.save();
this.notify.success(this.l10n.t('Your billing details has been updated'));
} catch (error) {
this.authManager.currentUser.rollbackAttributes();
this.notify.error(this.l10n.t('An unexpected error occurred'));
}
this.set('isLoading', false);
});
actions: {
submit() {
this.onValid(async() => {
this.set('isLoading', true);
try {
this.authManager.currentUser.setProperties(this.userBillingInfo);
await this.authManager.currentUser.save();
this.notify.success(this.l10n.t('Your billing details has been updated'));
} catch (error) {
this.authManager.currentUser.rollbackAttributes();
this.notify.error(this.l10n.t('An unexpected error occurred'));
}
this.set('isLoading', false);
});
}
}
}
});