From 41155c8bff4abba6bea47504a511621d29fcb46d Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 5 Oct 2017 10:26:07 +0200 Subject: [PATCH] Improved shop --- pages/charge/charge.go | 2 +- pages/charge/charge.pixy | 4 ++-- pages/inventory/inventory.go | 2 +- pages/inventory/inventory.pixy | 5 +++-- pages/paypal/success.go | 4 ++-- pages/paypal/success.pixy | 12 +++++++++--- pages/paypal/success.scarlet | 1 + pages/shop/shop.pixy | 6 +++--- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/pages/charge/charge.go b/pages/charge/charge.go index 5dc7706b..441b4563 100644 --- a/pages/charge/charge.go +++ b/pages/charge/charge.go @@ -17,5 +17,5 @@ func Get(ctx *aero.Context) string { return ctx.Error(http.StatusUnauthorized, "Not logged in", nil) } - return ctx.HTML(components.Charge()) + return ctx.HTML(components.Charge(user)) } diff --git a/pages/charge/charge.pixy b/pages/charge/charge.pixy index 3245271c..f41a0ff1 100644 --- a/pages/charge/charge.pixy +++ b/pages/charge/charge.pixy @@ -1,3 +1,3 @@ -component Charge - ShopTabs +component Charge(user *arn.User) + ShopTabs(user) p Coming soon. \ No newline at end of file diff --git a/pages/inventory/inventory.go b/pages/inventory/inventory.go index c5e11673..e7aa1904 100644 --- a/pages/inventory/inventory.go +++ b/pages/inventory/inventory.go @@ -26,5 +26,5 @@ func Get(ctx *aero.Context) string { 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)) } diff --git a/pages/inventory/inventory.pixy b/pages/inventory/inventory.pixy index ccdb7a63..22b9b911 100644 --- a/pages/inventory/inventory.pixy +++ b/pages/inventory/inventory.pixy @@ -1,5 +1,6 @@ -component Inventory(inventory *arn.Inventory, viewUser *arn.User) - ShopTabs +component Inventory(inventory *arn.Inventory, viewUser *arn.User, user *arn.User) + ShopTabs(user) + .inventory(data-api="/api/inventory/" + viewUser.ID) for index, slot := range inventory.Slots if slot.ItemID == "" diff --git a/pages/paypal/success.go b/pages/paypal/success.go index 954531db..52c57b81 100644 --- a/pages/paypal/success.go +++ b/pages/paypal/success.go @@ -73,7 +73,7 @@ func Success(ctx *aero.Context) string { } // Increase user's balance - user.Balance += payment.AnimeDollar() + user.Balance += payment.Gems() // Save in DB err = user.Save() @@ -86,7 +86,7 @@ func Success(ctx *aero.Context) string { go func() { admin, _ := arn.GetUser(adminID) 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), Icon: user.LargeAvatar(), Link: "https://" + ctx.App.Config.Domain + "/api/paypalpayment/" + payment.ID, diff --git a/pages/paypal/success.pixy b/pages/paypal/success.pixy index ee13b1d4..3b20c271 100644 --- a/pages/paypal/success.pixy +++ b/pages/paypal/success.pixy @@ -3,8 +3,14 @@ component PayPalSuccess(payment *arn.PayPalPayment) .new-payment.mountable span + - .new-payment-amount.count-up= payment.AnimeDollar() - span.new-payment-currency AD + .new-payment-amount.count-up= payment.Gems() + span.new-payment-currency + Icon("diamond") p.mountable - img.new-payment-thank-you-image(src="/images/elements/thank-you.jpg", alt="Thank you!") \ No newline at end of file + 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 \ No newline at end of file diff --git a/pages/paypal/success.scarlet b/pages/paypal/success.scarlet index ebb83b08..d528c358 100644 --- a/pages/paypal/success.scarlet +++ b/pages/paypal/success.scarlet @@ -2,6 +2,7 @@ horizontal margin 2rem auto font-size 4rem + line-height 1em color green .new-payment-currency diff --git a/pages/shop/shop.pixy b/pages/shop/shop.pixy index 554f75b4..e741f368 100644 --- a/pages/shop/shop.pixy +++ b/pages/shop/shop.pixy @@ -1,17 +1,17 @@ component Shop(user *arn.User, items []*arn.Item) h1.page-title Shop - ShopTabs + ShopTabs(user) .widgets.shop-items each item in items ShopItem(item) -component ShopTabs +component ShopTabs(user *arn.User) .tabs Tab("Shop", "shopping-cart", "/shop") Tab("Inventory", "briefcase", "/inventory") - Tab("0", "diamond", "/charge") + Tab(strconv.Itoa(user.Balance), "diamond", "/charge") component ShopItem(item *arn.Item) .widget.shop-item.mountable