Improved shop

This commit is contained in:
Eduard Urbach 2017-10-05 10:26:07 +02:00
parent 43317fd3da
commit 41155c8bff
8 changed files with 22 additions and 14 deletions

View File

@ -17,5 +17,5 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil) return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
} }
return ctx.HTML(components.Charge()) return ctx.HTML(components.Charge(user))
} }

View File

@ -1,3 +1,3 @@
component Charge component Charge(user *arn.User)
ShopTabs ShopTabs(user)
p Coming soon. p Coming soon.

View File

@ -26,5 +26,5 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusInternalServerError, "Error fetching inventory data", err) return ctx.Error(http.StatusInternalServerError, "Error fetching inventory data", err)
} }
return ctx.HTML(components.Inventory(inventory, viewUser)) return ctx.HTML(components.Inventory(inventory, viewUser, user))
} }

View File

@ -1,5 +1,6 @@
component Inventory(inventory *arn.Inventory, viewUser *arn.User) component Inventory(inventory *arn.Inventory, viewUser *arn.User, user *arn.User)
ShopTabs ShopTabs(user)
.inventory(data-api="/api/inventory/" + viewUser.ID) .inventory(data-api="/api/inventory/" + viewUser.ID)
for index, slot := range inventory.Slots for index, slot := range inventory.Slots
if slot.ItemID == "" if slot.ItemID == ""

View File

@ -73,7 +73,7 @@ func Success(ctx *aero.Context) string {
} }
// Increase user's balance // Increase user's balance
user.Balance += payment.AnimeDollar() user.Balance += payment.Gems()
// Save in DB // Save in DB
err = user.Save() err = user.Save()
@ -86,7 +86,7 @@ func Success(ctx *aero.Context) string {
go func() { go func() {
admin, _ := arn.GetUser(adminID) admin, _ := arn.GetUser(adminID)
admin.SendNotification(&arn.Notification{ admin.SendNotification(&arn.Notification{
Title: user.Nick + " bought " + strconv.Itoa(payment.AnimeDollar()) + " AD", Title: user.Nick + " bought " + strconv.Itoa(payment.Gems()) + " AD",
Message: user.Nick + " paid " + payment.Amount + " " + payment.Currency + " making his new balance " + strconv.Itoa(user.Balance), Message: user.Nick + " paid " + payment.Amount + " " + payment.Currency + " making his new balance " + strconv.Itoa(user.Balance),
Icon: user.LargeAvatar(), Icon: user.LargeAvatar(),
Link: "https://" + ctx.App.Config.Domain + "/api/paypalpayment/" + payment.ID, Link: "https://" + ctx.App.Config.Domain + "/api/paypalpayment/" + payment.ID,

View File

@ -3,8 +3,14 @@ component PayPalSuccess(payment *arn.PayPalPayment)
.new-payment.mountable .new-payment.mountable
span + span +
.new-payment-amount.count-up= payment.AnimeDollar() .new-payment-amount.count-up= payment.Gems()
span.new-payment-currency AD span.new-payment-currency
Icon("diamond")
p.mountable p.mountable
img.new-payment-thank-you-image(src="/images/elements/thank-you.jpg", alt="Thank you!") img.new-payment-thank-you-image(src="/images/elements/thank-you.jpg", alt="Thank you!")
.buttons
a.button.ajax(href="/shop")
Icon("shopping-cart")
span Return to the shop

View File

@ -2,6 +2,7 @@
horizontal horizontal
margin 2rem auto margin 2rem auto
font-size 4rem font-size 4rem
line-height 1em
color green color green
.new-payment-currency .new-payment-currency

View File

@ -1,17 +1,17 @@
component Shop(user *arn.User, items []*arn.Item) component Shop(user *arn.User, items []*arn.Item)
h1.page-title Shop h1.page-title Shop
ShopTabs ShopTabs(user)
.widgets.shop-items .widgets.shop-items
each item in items each item in items
ShopItem(item) ShopItem(item)
component ShopTabs component ShopTabs(user *arn.User)
.tabs .tabs
Tab("Shop", "shopping-cart", "/shop") Tab("Shop", "shopping-cart", "/shop")
Tab("Inventory", "briefcase", "/inventory") Tab("Inventory", "briefcase", "/inventory")
Tab("0", "diamond", "/charge") Tab(strconv.Itoa(user.Balance), "diamond", "/charge")
component ShopItem(item *arn.Item) component ShopItem(item *arn.Item)
.widget.shop-item.mountable .widget.shop-item.mountable