package http

import (
	"net/http"

	"git.gocasts.ir/ebhomengo/niki/salesreportapp/param"
	"github.com/labstack/echo/v4"
)

func (s *Server) GetReportData(c echo.Context) error {
	var data param.GetReportDataRequest
	err := c.Bind(&data)
	if err != nil {
		return err
	}

	reportsData, err := s.SalesReportSvc.GetReportData(data.Filters)

	if err != nil {
		return c.JSON(http.StatusInternalServerError, err)
	}
	return c.JSON(http.StatusOK, echo.Map{
		"status":  200,
		"message": "success",
		"headers": reportsData.Header,
		"data":    reportsData.Data,
	})
}
