Improved admin stuff
This commit is contained in:
@ -2,6 +2,7 @@ component AdminTabs
|
||||
.tabs
|
||||
Tab("Server", "server", "/admin")
|
||||
Tab("WebDev", "html5", "/admin/webdev")
|
||||
Tab("Purchases", "shopping-cart", "/admin/purchases")
|
||||
|
||||
a.tab.ajax(href="/editor", aria-label="Editor")
|
||||
Icon("pencil")
|
||||
|
36
pages/admin/purchases.go
Normal file
36
pages/admin/purchases.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"
|
||||
)
|
||||
|
||||
// PurchaseHistory ...
|
||||
func PurchaseHistory(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||
}
|
||||
|
||||
if user.Role != "admin" {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
||||
}
|
||||
|
||||
purchases, err := arn.AllPurchases()
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching shop item data", err)
|
||||
}
|
||||
|
||||
sort.Slice(purchases, func(i, j int) bool {
|
||||
return purchases[i].Date > purchases[j].Date
|
||||
})
|
||||
|
||||
return ctx.HTML(components.GlobalPurchaseHistory(purchases))
|
||||
}
|
20
pages/admin/purchases.pixy
Normal file
20
pages/admin/purchases.pixy
Normal file
@ -0,0 +1,20 @@
|
||||
component GlobalPurchaseHistory(purchases []*arn.Purchase)
|
||||
AdminTabs
|
||||
|
||||
h1.page-title All Purchases
|
||||
|
||||
table
|
||||
thead
|
||||
tr.mountable
|
||||
th User
|
||||
th Icon
|
||||
th Item
|
||||
th.history-quantity Quantity
|
||||
th.history-price Price
|
||||
th.history-date Date
|
||||
tbody
|
||||
each purchase in purchases
|
||||
tr.shop-item.mountable(data-item-id=purchase.ItemID)
|
||||
td
|
||||
a.ajax(href=purchase.User().Link())= purchase.User().Nick
|
||||
PurchaseInfo(purchase)
|
Reference in New Issue
Block a user