Skip to content
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
9 changes: 8 additions & 1 deletion app/components/events/view/publish-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface Event extends DS.Model { // eslint-disable-line ember-suave/no-direct-
identifier: string | null,
state: string,
name: string | null,
tickets: any[]
tickets: any[],
isStripeConnectionValid: boolean
}

interface EventsViewPublishBarArgs {
Expand Down Expand Up @@ -58,6 +59,12 @@ export default class EventsViewPublishBar extends Component<EventsViewPublishBar
id: 'event_tickets'
});
return;
} else if (!event.isStripeConnectionValid) {
this.notify.error(this.l10n.t('You need to connect to your Stripe account, if you choose Stripe as a payment gateway.'),
{
id: 'event_stripe'
});
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate logic. Move in the event model

}
}
this.isLoading = true;
Expand Down
20 changes: 15 additions & 5 deletions app/mixins/event-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,19 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
actions: {
saveDraft() {
this.onValid(() => {
preSaveActions.call(this);
this.set('data.event.state', 'draft');
this.sendAction('save');
const valid = preSaveActions.call(this);
if (valid) {
this.set('data.event.state', 'draft');
this.sendAction('save');
}
});
},
saveForm() {
this.onValid(() => {
preSaveActions.call(this);
this.sendAction('save', this.data);
const valid = preSaveActions.call(this);
if (valid) {
this.sendAction('save', this.data);
}
});
},
move(direction) {
Expand Down Expand Up @@ -284,4 +288,10 @@ function preSaveActions() {
this.set('data.event.locationName', null);
}
}

if (!this.data.event.isStripeConnectionValid) {
this.notify.error('You need to connect to your Stripe account, if you choose Stripe as a payment gateway.');
}

return this.data.event.isStripeConnectionValid;
}
4 changes: 4 additions & 0 deletions app/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {

sessionsByState: computed('sessions', function() {
return groupBy(this.sessions.toArray(), 'data.state');
}),

isStripeConnectionValid: computed('canPayByStripe', 'stripeAuthorization.stripeAuthCode', 'stripeAuthorization.stripePublishableKey', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is isStripeConnectionValid and returns true when the connection is invalid 😲

return this.canPayByStripe && this.stripeAuthorization?.stripeAuthCode && this.stripeAuthorization?.stripePublishableKey;
})

}) {}
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
@checked={{this.data.event.canPayByStripe}} />
<label for="payment_by_stripe">
<span>{{t 'YES, accept payment through Stripe'}}</span>
<div class="ui hidden divider"></div>
<br>
<span class="text muted">
{{t 'Stripe accepts Visa, Master and Amex. Find out more about Stripe '}}
<a href="https://stripe.com/docs" target="_blank" rel="noopener noreferrer">{{t 'here'}}</a>.
Expand Down