subscription and billing templates

This commit is contained in:
Rimian Perkins 2019-12-16 10:42:55 +11:00
parent 8264930e92
commit 55f4592033
14 changed files with 65 additions and 60 deletions

View File

@ -2,7 +2,9 @@ export default {
resource: "user",
path: "users/:username",
map() {
this.route("billing");
this.route("subscriptions");
this.route("billing", function() {
this.route("payments");
this.route("subscriptions");
});
}
};

View File

@ -1,7 +0,0 @@
import Route from "@ember/routing/route";
export default Route.extend({
model() {
console.log(999);
}
});

View File

@ -0,0 +1,9 @@
import Route from "@ember/routing/route";
export default Route.extend({
templateName: "user/billing/index",
redirect() {
this.transitionTo("user.billing.subscriptions");
}
});

View File

@ -0,0 +1,10 @@
import Route from "@ember/routing/route";
import Invoice from "discourse/plugins/discourse-subscriptions/discourse/models/invoice";
export default Route.extend({
templateName: "user/billing/payments",
model() {
return Invoice.findAll();
}
});

View File

@ -2,18 +2,12 @@ import Route from "@ember/routing/route";
import UserSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/user-subscription";
export default Route.extend({
templateName: "user/billing/subscriptions",
model() {
return UserSubscription.findAll();
},
setupController(controller, model) {
if (this.currentUser.id !== this.modelFor("user").id) {
this.replaceWith("userActivity");
} else {
controller.setProperties({ model });
}
},
actions: {
cancelSubscription(subscription) {
bootbox.confirm(

View File

@ -1,10 +1,7 @@
import Route from "@ember/routing/route";
import Invoice from "discourse/plugins/discourse-subscriptions/discourse/models/invoice";
export default Route.extend({
model() {
return Invoice.findAll();
},
templateName: "user/billing",
setupController(controller, model) {
if (this.currentUser.id !== this.modelFor("user").id) {

View File

@ -0,0 +1,3 @@
{{#if (user-viewing-self model)}}
{{#link-to 'user.billing'}}{{d-icon "credit-card"}}{{I18n 'discourse_subscriptions.navigation.billing'}}{{/link-to}}
{{/if}}

View File

@ -1,3 +0,0 @@
{{#if (user-viewing-self model)}}
{{#link-to 'user.subscriptions'}}{{d-icon "credit-card"}}{{I18n 'discourse_subscriptions.navigation.subscriptions'}}{{/link-to}}
{{/if}}

View File

@ -1,27 +1,22 @@
{{#d-section pageClass="user-billing" class="user-secondary-navigation" scrollTop="false"}}
{{#mobile-nav
class='activity-nav'
desktopClass='action-list nav-stacked'
currentPath=router._router.currentPath
}}
<li>
{{#link-to 'user.billing.subscriptions'}}
{{i18n 'discourse_subscriptions.navigation.subscriptions'}}
{{/link-to}}
</li>
<li>
{{#link-to 'user.billing.payments'}}
{{i18n 'discourse_subscriptions.navigation.payments'}}
{{/link-to}}
</li>
{{/mobile-nav}}
{{/d-section}}
<h3>{{i18n 'discourse_subscriptions.user.billing.title'}}</h3>
{{#if model}}
<table class="topic-list">
<thead>
<th>{{i18n 'discourse_subscriptions.user.billing.invoices.amount'}}</th>
<th>{{i18n 'discourse_subscriptions.user.billing.invoices.number'}}</th>
<th>{{i18n 'discourse_subscriptions.user.billing.invoices.created_at'}}</th>
<th></th>
</thead>
{{#each model as |invoice|}}
<tr>
<td>{{invoice.amount_paid}}</td>
<td>{{invoice.number}}</td>
<td>{{format-unix-date invoice.created}}</td>
<td class="td-right">
<a href="{{invoice.invoice_pdf}}" class="btn btn-icon">
{{d-icon "download"}}
</a>
</td>
</tr>
{{/each}}
</table>
{{else}}
<p>{{i18n 'discourse_subscriptions.user.billing_help'}}</p>
{{/if}}
<section class='user-content'>
{{outlet}}
</section>

View File

@ -0,0 +1,4 @@
BILLING INDEX

View File

@ -1,6 +1,4 @@
<h3>{{i18n 'discourse_subscriptions.user.billing.title'}}</h3>
{{#if model}}
<table class="topic-list">
<thead>
@ -23,5 +21,7 @@
{{/each}}
</table>
{{else}}
<p>{{i18n 'discourse_subscriptions.user.billing_help'}}</p>
<div class="alert alert-info">
{{i18n 'discourse_subscriptions.user.payments_help'}}
</div>
{{/if}}

View File

@ -1,7 +1,4 @@
{{#d-section pageClass="user-subscriptions" class="user-content"}}
<h2>{{i18n 'discourse_subscriptions.user.subscriptions.title'}}</h2>
{{#if model}}
<table class="table discourse-subscriptions-user-table">
<thead>
@ -30,6 +27,8 @@
{{/each}}
</table>
{{else}}
<p>{{i18n 'discourse_subscriptions.user.subscriptions_help'}}</p>
<div class="alert alert-info">
{{i18n 'discourse_subscriptions.user.subscriptions_help'}}
</div>
{{/if}}
{{/d-section}}

View File

@ -19,6 +19,8 @@ en:
admin_navigation: Subscriptions
optional: Optional
navigation:
billing: Billing
payments: Payments
subscriptions: Subscriptions
subscribe: Subscribe
user_activity:
@ -61,12 +63,12 @@ en:
amount: Amount
payment_intent_id: Payment ID
user:
payments_help: There are no payments
plans:
rate: Rate
product: Name
subscriptions_help: You have no subscriptions.
subscriptions_help: You have no active subscriptions.
subscriptions:
title: Subscriptions
id: Subscription ID
status: Status
created_at: Created

View File

@ -36,7 +36,7 @@ Discourse::Application.routes.append do
get '/admin/plugins/discourse-subscriptions/plans' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/plans/:plan_id' => 'admin/plugins#index'
get 'u/:username/billing' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
get 'u/:username/subscriptions' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
get 'u/:username/billing/:id' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
end
after_initialize do