package api

import (
	"gadmin/internal/admin/forms"
	"gadmin/internal/admin/service"
	"github.com/gin-gonic/gin"
)

func RetrofitGroupAddPlayer(c *gin.Context) {
	var req forms.RetrofitGroupAddPlayerReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.AddPlayer(c, req))
}

func RetrofitGroupOptions(c *gin.Context) {
	c.JSON(200, service.Retrofit.GroupOptions(c))
}

func RetrofitGroupList(c *gin.Context) {
	var req forms.RetrofitGroupListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.GroupList(c, req))
}

func RetrofitGroupEdit(c *gin.Context) {
	var req forms.RetrofitGroupEditReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.GroupEdit(c, req))
}

func RetrofitGroupDelete(c *gin.Context) {
	var req forms.RetrofitGroupDeleteReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.GroupDelete(c, req))
}

func RetrofitList(c *gin.Context) {
	var req forms.RetrofitListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.List(c, req))
}

func RetrofitEdit(c *gin.Context) {
	var req forms.RetrofitEditReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.Edit(c, req))
}

func RetrofitDelete(c *gin.Context) {
	var req forms.RetrofitDeleteReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Retrofit.Delete(c, req))
}
