Improved inventory
This commit is contained in:
@ -14,22 +14,17 @@ import (
|
||||
// Get inventory page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
viewUser := user
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||
}
|
||||
|
||||
inventory, err := arn.GetInventory(user.ID)
|
||||
inventory, err := arn.GetInventory(viewUser.ID)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching inventory data", err)
|
||||
}
|
||||
|
||||
// TEST
|
||||
inventory.AddItem("anime-support-ticket", 35)
|
||||
inventory.AddItem("pro-account-24", 20)
|
||||
inventory.AddItem("anime-support-ticket", 15)
|
||||
inventory.AddItem("pro-account-24", 10)
|
||||
|
||||
return ctx.HTML(components.Inventory(inventory))
|
||||
return ctx.HTML(components.Inventory(inventory, viewUser))
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
component Inventory(inventory *arn.Inventory)
|
||||
component Inventory(inventory *arn.Inventory, viewUser *arn.User)
|
||||
ShopTabs
|
||||
.inventory
|
||||
.inventory(data-api="/api/inventory/" + viewUser.ID)
|
||||
for index, slot := range inventory.Slots
|
||||
if slot.ItemID == ""
|
||||
.inventory-slot.mountable(draggable="false", data-index=index)
|
||||
else
|
||||
.inventory-slot.mountable(title=slot.Item().Name, draggable="true", data-index=index)
|
||||
.inventory-slot.mountable(title=slot.Item().Name, draggable="true", data-index=index, data-item-id=slot.ItemID, data-consumable=slot.Item().Consumable)
|
||||
Icon(slot.Item().Icon)
|
||||
if slot.Quantity > 1
|
||||
.inventory-slot-quantity= slot.Quantity
|
Reference in New Issue
Block a user