Added payment overview for administrators
This commit is contained in:
parent
5956b82d9d
commit
9ad99995c3
@ -5,6 +5,7 @@ component AdminTabs
|
||||
Tab("Client errors", "exclamation", "/admin/errors/client")
|
||||
Tab("Registrations", "user-plus", "/admin/registrations")
|
||||
Tab("Purchases", "shopping-cart", "/admin/purchases")
|
||||
Tab("Payments", "paypal", "/admin/payments")
|
||||
|
||||
.corner-buttons
|
||||
a.button(href="/editor", aria-label="Editor")
|
||||
|
36
pages/admin/payments.go
Normal file
36
pages/admin/payments.go
Normal file
@ -0,0 +1,36 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// PaymentHistory ...
|
||||
func PaymentHistory(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
}
|
||||
|
||||
if user.Role != "admin" {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||
}
|
||||
|
||||
payments, err := arn.AllPayPalPayments()
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching shop item data", err)
|
||||
}
|
||||
|
||||
sort.Slice(payments, func(i, j int) bool {
|
||||
return payments[i].Created > payments[j].Created
|
||||
})
|
||||
|
||||
return ctx.HTML(components.GlobalPaymentHistory(payments))
|
||||
}
|
20
pages/admin/payments.pixy
Normal file
20
pages/admin/payments.pixy
Normal file
@ -0,0 +1,20 @@
|
||||
component GlobalPaymentHistory(payments []*arn.PayPalPayment)
|
||||
AdminTabs
|
||||
|
||||
h1.page-title All Payments
|
||||
|
||||
table
|
||||
thead
|
||||
tr.mountable
|
||||
th User
|
||||
th Amount
|
||||
th Currency
|
||||
th.history-date Date
|
||||
tbody
|
||||
each payment in payments
|
||||
tr.mountable
|
||||
td
|
||||
a(href=payment.User().Link())= payment.User().Nick
|
||||
td= payment.Amount
|
||||
td= payment.Currency
|
||||
td.utc-date(data-date=payment.Created)
|
@ -78,4 +78,5 @@ func Register(l *layout.Layout) {
|
||||
l.Page("/admin/registrations", admin.UserRegistrations)
|
||||
l.Page("/admin/errors/client", admin.ClientErrors)
|
||||
l.Page("/admin/purchases", admin.PurchaseHistory)
|
||||
l.Page("/admin/payments", admin.PaymentHistory)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user