diff --git a/app/controllers/admin/donations_controller.rb b/app/controllers/admin/donations_controller.rb index 51ea4e3..bdfff93 100644 --- a/app/controllers/admin/donations_controller.rb +++ b/app/controllers/admin/donations_controller.rb @@ -5,6 +5,7 @@ class Admin::DonationsController < Admin::BaseController # GET /donations def index @pagy, @donations = pagy(Donation.completed.order('paid_at desc')) + @pending_donations = Donation.incomplete.order('paid_at desc') @stats = { overall_sats: @donations.sum("amount_sats"), diff --git a/app/models/donation.rb b/app/models/donation.rb index b319259..f3e585c 100644 --- a/app/models/donation.rb +++ b/app/models/donation.rb @@ -17,6 +17,7 @@ class Donation < ApplicationRecord scope :pending, -> { where(payment_status: "pending") } scope :processing, -> { where(payment_status: "processing") } scope :completed, -> { where(payment_status: "settled") } + scope :incomplete, -> { where.not(payment_status: "settled") } aasm column: :payment_status do state :pending, initial: true diff --git a/app/views/admin/donations/_list.html.erb b/app/views/admin/donations/_list.html.erb new file mode 100644 index 0000000..8a75699 --- /dev/null +++ b/app/views/admin/donations/_list.html.erb @@ -0,0 +1,32 @@ +
User | +Sats | +Fiat Amount | +Public name | +Date | ++ |
---|---|---|---|---|---|
<%= link_to donation.user.cn, admin_user_path(donation.user.cn), class: 'ks-text-link' %> | +<% if donation.amount_sats.present? %><%= number_with_delimiter donation.amount_sats %><% end %> | +<% if donation.fiat_amount.present? %><%= number_to_currency donation.fiat_amount.to_f / 100, unit: "" %> <%= donation.fiat_currency %><% end %> | +<%= donation.public_name %> | +<%= donation.paid_at ? donation.paid_at.strftime("%Y-%m-%d (%H:%M UTC)") : donation.created_at.strftime("%Y-%m-%d (%H:%M UTC)") %> | ++ <%= link_to 'Show', admin_donation_path(donation), class: 'btn btn-sm btn-gray' %> + <%= link_to 'Edit', edit_admin_donation_path(donation), class: 'btn btn-sm btn-gray' %> + <%= link_to 'Destroy', admin_donation_path(donation), class: 'btn btn-sm btn-red', + data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } %> + | +
User | -Sats | -Fiat Amount | -Public name | -Date | -- |
---|---|---|---|---|---|
<%= link_to donation.user.cn, admin_user_path(donation.user.cn), class: 'ks-text-link' %> | -<% if donation.amount_sats.present? %><%= number_with_delimiter donation.amount_sats %><% end %> | -<% if donation.fiat_amount.present? %><%= number_to_currency donation.fiat_amount.to_f / 100, unit: "" %> <%= donation.fiat_currency %><% end %> | -<%= donation.public_name %> | -<%= donation.paid_at ? donation.paid_at.strftime("%Y-%m-%d (%H:%M UTC)") : "" %> | -- <%= link_to 'Show', admin_donation_path(donation), class: 'btn btn-sm btn-gray' %> - <%= link_to 'Edit', edit_admin_donation_path(donation), class: 'btn btn-sm btn-gray' %> - <%= link_to 'Destroy', admin_donation_path(donation), class: 'btn btn-sm btn-red', - data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } %> - | -
- No donations yet. + No donations received yet.
<% end %>