From 5c332684777b70393bc1db03431c649150209066 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Sat, 14 Sep 2019 14:20:16 +1000 Subject: [PATCH] created at and url --- app/serializers/payment_serializer.rb | 6 +++++- .../discourse/helpers/stripe-payment-link.js.es6 | 5 +++++ .../routes/admin-plugins-discourse-patrons.js.es6 | 7 +------ .../templates/admin/plugins-discourse-patrons.hbs | 8 ++++---- config/locales/client.en.yml | 5 ++--- 5 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 assets/javascripts/discourse/helpers/stripe-payment-link.js.es6 diff --git a/app/serializers/payment_serializer.rb b/app/serializers/payment_serializer.rb index 6fd251d..eb4d4b6 100644 --- a/app/serializers/payment_serializer.rb +++ b/app/serializers/payment_serializer.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true class PaymentSerializer < ApplicationSerializer - attributes :payment_intent_id, :receipt_email, :url, :amount + attributes :payment_intent_id, :receipt_email, :url, :created_at_age, :amount + + def created_at_age + Time.now - object.created_at + end end diff --git a/assets/javascripts/discourse/helpers/stripe-payment-link.js.es6 b/assets/javascripts/discourse/helpers/stripe-payment-link.js.es6 new file mode 100644 index 0000000..e038903 --- /dev/null +++ b/assets/javascripts/discourse/helpers/stripe-payment-link.js.es6 @@ -0,0 +1,5 @@ +export default Ember.Helper.helper(function(params) { + const payment = params[0]; + + return `${payment.payment_intent_id}`; +}); diff --git a/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 index 6f2ffc5..e70c91b 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 @@ -5,11 +5,6 @@ export default Discourse.Route.extend({ return ajax("/patrons/admin", { method: "get" }) - .then(results => { - - console.log(12, results); - - return results; - }); + .then(results => results); } }); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs index 132fcdd..229ccaa 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs @@ -5,18 +5,18 @@ {{i18n 'discourse_patrons.admin.table.head.user'}} - {{i18n 'discourse_patrons.admin.table.head.payment_intent_id'}} + {{i18n 'discourse_patrons.admin.table.head.payment_intent'}} {{i18n 'discourse_patrons.admin.table.head.receipt_email'}} - {{i18n 'discourse_patrons.admin.table.head.url'}} + {{i18n 'created'}} {{i18n 'discourse_patrons.admin.table.head.amount'}} {{#each model as |payment|}} {{payment.user_id}} - {{payment.payment_intent_id}} + {{{stripe-payment-link payment}}} {{payment.receipt_email}} - {{payment.url}} + {{{format-duration payment.created_at_age}}} {{payment.amount}} {{/each}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 3829c01..551602e 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -39,8 +39,7 @@ en: admin: table: head: - url: User - payment_intent_id: Payment Intent Id + user: User + payment_intent: Payment Intent receipt_email: Receipt Email - url: URL amount: Amount