diff --git a/assets/javascripts/discourse/discourse-subscriptions-user-route-map.js.es6 b/assets/javascripts/discourse/discourse-subscriptions-user-route-map.js.es6 index f94ffbb..34eb963 100644 --- a/assets/javascripts/discourse/discourse-subscriptions-user-route-map.js.es6 +++ b/assets/javascripts/discourse/discourse-subscriptions-user-route-map.js.es6 @@ -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"); + }); } }; diff --git a/assets/javascripts/discourse/routes/user-activity-payments.js.es6 b/assets/javascripts/discourse/routes/user-activity-payments.js.es6 deleted file mode 100644 index 928619c..0000000 --- a/assets/javascripts/discourse/routes/user-activity-payments.js.es6 +++ /dev/null @@ -1,7 +0,0 @@ -import Route from "@ember/routing/route"; - -export default Route.extend({ - model() { - console.log(999); - } -}); diff --git a/assets/javascripts/discourse/routes/user-billing-index.js.es6 b/assets/javascripts/discourse/routes/user-billing-index.js.es6 new file mode 100644 index 0000000..f424751 --- /dev/null +++ b/assets/javascripts/discourse/routes/user-billing-index.js.es6 @@ -0,0 +1,9 @@ +import Route from "@ember/routing/route"; + +export default Route.extend({ + templateName: "user/billing/index", + + redirect() { + this.transitionTo("user.billing.subscriptions"); + } +}); diff --git a/assets/javascripts/discourse/routes/user-billing-payments.js.es6 b/assets/javascripts/discourse/routes/user-billing-payments.js.es6 new file mode 100644 index 0000000..38cc6c3 --- /dev/null +++ b/assets/javascripts/discourse/routes/user-billing-payments.js.es6 @@ -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(); + } +}); diff --git a/assets/javascripts/discourse/routes/user-subscriptions.js.es6 b/assets/javascripts/discourse/routes/user-billing-subscriptions.js.es6 similarity index 82% rename from assets/javascripts/discourse/routes/user-subscriptions.js.es6 rename to assets/javascripts/discourse/routes/user-billing-subscriptions.js.es6 index a667cf8..3527115 100644 --- a/assets/javascripts/discourse/routes/user-subscriptions.js.es6 +++ b/assets/javascripts/discourse/routes/user-billing-subscriptions.js.es6 @@ -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( diff --git a/assets/javascripts/discourse/routes/user-billing.js.es6 b/assets/javascripts/discourse/routes/user-billing.js.es6 index 569ecf8..59f9f9d 100644 --- a/assets/javascripts/discourse/routes/user-billing.js.es6 +++ b/assets/javascripts/discourse/routes/user-billing.js.es6 @@ -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) { diff --git a/assets/javascripts/discourse/templates/connectors/user-main-nav/billing.hbs b/assets/javascripts/discourse/templates/connectors/user-main-nav/billing.hbs new file mode 100644 index 0000000..977d685 --- /dev/null +++ b/assets/javascripts/discourse/templates/connectors/user-main-nav/billing.hbs @@ -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}} diff --git a/assets/javascripts/discourse/templates/connectors/user-main-nav/subscriptions.hbs b/assets/javascripts/discourse/templates/connectors/user-main-nav/subscriptions.hbs deleted file mode 100644 index 3efebfb..0000000 --- a/assets/javascripts/discourse/templates/connectors/user-main-nav/subscriptions.hbs +++ /dev/null @@ -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}} diff --git a/assets/javascripts/discourse/templates/user/billing.hbs b/assets/javascripts/discourse/templates/user/billing.hbs index fc690e5..caeee34 100644 --- a/assets/javascripts/discourse/templates/user/billing.hbs +++ b/assets/javascripts/discourse/templates/user/billing.hbs @@ -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 + }} +
  • + {{#link-to 'user.billing.subscriptions'}} + {{i18n 'discourse_subscriptions.navigation.subscriptions'}} + {{/link-to}} +
  • +
  • + {{#link-to 'user.billing.payments'}} + {{i18n 'discourse_subscriptions.navigation.payments'}} + {{/link-to}} +
  • + {{/mobile-nav}} +{{/d-section}} -

    {{i18n 'discourse_subscriptions.user.billing.title'}}

    - -{{#if model}} - - - - - - - - {{#each model as |invoice|}} - - - - - - - {{/each}} -
    {{i18n 'discourse_subscriptions.user.billing.invoices.amount'}}{{i18n 'discourse_subscriptions.user.billing.invoices.number'}}{{i18n 'discourse_subscriptions.user.billing.invoices.created_at'}}
    {{invoice.amount_paid}}{{invoice.number}}{{format-unix-date invoice.created}} - - {{d-icon "download"}} - -
    -{{else}} -

    {{i18n 'discourse_subscriptions.user.billing_help'}}

    -{{/if}} +
    + {{outlet}} +
    diff --git a/assets/javascripts/discourse/templates/user/billing/index.hbs b/assets/javascripts/discourse/templates/user/billing/index.hbs new file mode 100644 index 0000000..3d5679b --- /dev/null +++ b/assets/javascripts/discourse/templates/user/billing/index.hbs @@ -0,0 +1,4 @@ + + + +BILLING INDEX diff --git a/assets/javascripts/discourse/templates/user/invoices.hbs b/assets/javascripts/discourse/templates/user/billing/payments.hbs similarity index 85% rename from assets/javascripts/discourse/templates/user/invoices.hbs rename to assets/javascripts/discourse/templates/user/billing/payments.hbs index fc690e5..e69df3a 100644 --- a/assets/javascripts/discourse/templates/user/invoices.hbs +++ b/assets/javascripts/discourse/templates/user/billing/payments.hbs @@ -1,6 +1,4 @@ -

    {{i18n 'discourse_subscriptions.user.billing.title'}}

    - {{#if model}} @@ -23,5 +21,7 @@ {{/each}}
    {{else}} -

    {{i18n 'discourse_subscriptions.user.billing_help'}}

    +
    + {{i18n 'discourse_subscriptions.user.payments_help'}} +
    {{/if}} diff --git a/assets/javascripts/discourse/templates/user/subscriptions.hbs b/assets/javascripts/discourse/templates/user/billing/subscriptions.hbs similarity index 89% rename from assets/javascripts/discourse/templates/user/subscriptions.hbs rename to assets/javascripts/discourse/templates/user/billing/subscriptions.hbs index a18ac1a..827314a 100644 --- a/assets/javascripts/discourse/templates/user/subscriptions.hbs +++ b/assets/javascripts/discourse/templates/user/billing/subscriptions.hbs @@ -1,7 +1,4 @@ - {{#d-section pageClass="user-subscriptions" class="user-content"}} -

    {{i18n 'discourse_subscriptions.user.subscriptions.title'}}

    - {{#if model}} @@ -30,6 +27,8 @@ {{/each}}
    {{else}} -

    {{i18n 'discourse_subscriptions.user.subscriptions_help'}}

    +
    + {{i18n 'discourse_subscriptions.user.subscriptions_help'}} +
    {{/if}} {{/d-section}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 870a702..4a5f460 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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 diff --git a/plugin.rb b/plugin.rb index fea1d7c..f0bcbcc 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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