cannot subscribe to a product twice

This commit is contained in:
Rimian Perkins 2019-11-28 20:11:48 +11:00
parent 1429bf116f
commit e5753095d8
3 changed files with 21 additions and 16 deletions

View File

@ -6,6 +6,7 @@ export default Discourse.Route.extend({
model(params) {
const product_id = params["subscription-id"];
const product = Product.find(product_id);
const subscription = Subscription.create();
const plans = Plan.findAll({ product_id: product_id }).then(results =>
results.map(p => ({ id: p.id, name: p.subscriptionRate }))

View File

@ -9,7 +9,7 @@
{{#if currentUser}}
<div class="pull-right">
{{#link-to "patrons.subscribe.show" product.id class="btn btn-primary"}}
{{#link-to "patrons.subscribe.show" product.id disabled=product.subscribed class="btn btn-primary"}}
{{i18n 'discourse_patrons.subscribe.title'}}
{{/link-to}}
</div>

View File

@ -9,25 +9,29 @@
</p>
</div>
<div class="section-column">
{{combo-box valueAttribute="id" content=model.plans value=model.product.plan}}
{{#unless model.product.subscribed}}
{{#d-button
disabled=loading
action="stripePaymentHandler"
class="btn btn-primary btn-payment btn-discourse-patrons"}}
{{i18n 'discourse_patrons.subscribe.buttons.subscribe'}}
{{/d-button}}
{{combo-box valueAttribute="id" content=model.plans value=model.product.plan}}
<hr>
{{#d-button
disabled=loading
action="stripePaymentHandler"
class="btn btn-primary btn-payment btn-discourse-patrons"}}
{{i18n 'discourse_patrons.subscribe.buttons.subscribe'}}
{{/d-button}}
<h4>
{{i18n 'discourse_patrons.subscribe.card.title'}}
</h4>
<hr>
{{subscribe-card cardElement=cardElement}}
<h4>
{{i18n 'discourse_patrons.subscribe.card.title'}}
</h4>
{{#if loading}}
{{loading-spinner}}
{{/if}}
{{subscribe-card cardElement=cardElement}}
{{#if loading}}
{{loading-spinner}}
{{/if}}
{{/unless}}
</div>
</div>