package categoryhttp

import (
	categorysvc "legalgo-BE-go/internal/services/category"
	"legalgo-BE-go/internal/utilities/response"
	"net/http"

	"github.com/go-chi/chi/v5"
)

func GetAll(
	router chi.Router,
	categorySvc categorysvc.Category,
) {
	router.Get("/category", func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()
		subsPlan, err := categorySvc.GetAll()
		if err != nil {
			response.ResponseWithErrorCode(
				ctx,
				w,
				err,
				response.ErrBadRequest.Code,
				response.ErrBadRequest.HttpCode,
				err.Error(),
			)
			return
		}

		response.RespondJsonSuccess(ctx, w, subsPlan)
	})
}
