This commit is contained in:
@@ -472,11 +472,25 @@ func (rc *shopItemController) EditItemView(c *gin.Context) {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
|
||||
}
|
||||
|
||||
priceBW := ""
|
||||
priceColored := ""
|
||||
for _, variant := range shopItem.Variants {
|
||||
if variant.Name == "B/W" {
|
||||
priceBW = fmt.Sprintf("%.2f", variant.Price)
|
||||
}
|
||||
|
||||
if variant.Name == "Colored" {
|
||||
priceColored = fmt.Sprintf("%.2f", variant.Price)
|
||||
}
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": "",
|
||||
"success": "",
|
||||
"shopItem": shopItem,
|
||||
"tags": tags,
|
||||
"error": "",
|
||||
"success": "",
|
||||
"shopItem": shopItem,
|
||||
"tags": tags,
|
||||
"priceBW": priceBW,
|
||||
"priceColored": priceColored,
|
||||
})
|
||||
|
||||
c.HTML(http.StatusOK, "edititem.html", data)
|
||||
@@ -525,13 +539,28 @@ func (rc *shopItemController) EditItemHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
priceBW := ""
|
||||
priceColored := ""
|
||||
|
||||
for _, variant := range newShopItem.Variants {
|
||||
if variant.Name == "B/W" {
|
||||
priceBW = fmt.Sprintf("%.2f", variant.Price)
|
||||
}
|
||||
|
||||
if variant.Name == "Colored" {
|
||||
priceColored = fmt.Sprintf("%.2f", variant.Price)
|
||||
}
|
||||
}
|
||||
|
||||
_, err = repositories.ShopItems.Update(newShopItem)
|
||||
if err != nil {
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": err,
|
||||
"success": "",
|
||||
"shopItem": newShopItem,
|
||||
"tags": tags,
|
||||
"error": err,
|
||||
"success": "",
|
||||
"shopItem": newShopItem,
|
||||
"tags": tags,
|
||||
"priceBW": priceBW,
|
||||
"priceColored": priceColored,
|
||||
})
|
||||
|
||||
c.HTML(http.StatusOK, "edititem.html", data)
|
||||
@@ -539,10 +568,12 @@ func (rc *shopItemController) EditItemHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": "",
|
||||
"success": fmt.Sprintf("Item '%s' Updated", newShopItem.Name),
|
||||
"shopItem": newShopItem,
|
||||
"tags": tags,
|
||||
"error": "",
|
||||
"success": fmt.Sprintf("Item '%s' Updated", newShopItem.Name),
|
||||
"shopItem": newShopItem,
|
||||
"tags": tags,
|
||||
"priceBW": priceBW,
|
||||
"priceColored": priceColored,
|
||||
})
|
||||
|
||||
c.HTML(http.StatusOK, "edititem.html", data)
|
||||
|
||||
Reference in New Issue
Block a user