2018-10-18 01:15:06 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-10-18 01:15:06 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
// PaymentHistory ...
|
2019-06-01 04:55:49 +00:00
|
|
|
func PaymentHistory(ctx aero.Context) error {
|
2018-10-18 01:15:06 +00:00
|
|
|
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))
|
|
|
|
}
|