Skip to content

Commit

Permalink
add: IndexOrders and ShowOrder handler
Browse files Browse the repository at this point in the history
  • Loading branch information
abbasfisal committed Nov 25, 2024
1 parent 55758e7 commit 85ad52a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions internal/modules/admin/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1897,3 +1897,40 @@ func (a AdminHandler) UpdateProductFeature(c *gin.Context) {
return

}

func (a AdminHandler) IndexOrders(c *gin.Context) {
paginate, err := a.orderSrv.GetOrderPaginate(c)
if err != nil {
c.JSON(200, gin.H{
"err": err,
})
return
}
c.JSON(200, gin.H{
"data": paginate,
})
return
}

func (a AdminHandler) ShowOrder(c *gin.Context) {
orderID, err := strconv.Atoi(c.Param("id"))
if err != nil {
sessions.Set(c, "message", "ID سفارش صحیح نمی باشد.")
c.Redirect(http.StatusFound, "/admins/orders")
}

//result, err := a.orderSrv.GetOrderBy(c, orderID)
orderRes, customerRes, err := a.orderSrv.GetOrderBy(c, orderID)
if err != nil {
sessions.Set(c, "message", err.Error())
c.Redirect(http.StatusFound, "/admins/orders")
return
}

html.Render(c, http.StatusOK, "show-brand", gin.H{
"TITLE": "جزییات سفارش",
"Customer": customerRes,
"Data": orderRes,
})
return
}

0 comments on commit 85ad52a

Please sign in to comment.