package subscribeplanhttp

import (
	"net/http"

	subscribeplansvc "legalgo-BE-go/internal/services/subscribe_plan"
	"legalgo-BE-go/internal/utilities/response"

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

func GetAllPlan(
	router chi.Router,
	subsPlanSvc subscribeplansvc.SubscribePlan,
) {
	router.Get("/subscribe-plan", func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()
		subsPlan, err := subsPlanSvc.GetAllPlan()
		if err != nil {
			response.ResponseWithErrorCode(
				ctx,
				w,
				err,
				response.ErrBadRequest.Code,
				response.ErrBadRequest.HttpCode,
				response.ErrBadRequest.Message,
			)
			return
		}

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