package adshttp

import (
	adssvc "legalgo-BE-go/internal/services/ads"
	"legalgo-BE-go/internal/utilities/response"
	"net/http"

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

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

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