package controlplan

import (
	"net/http"

	e "simrs-vx/internal/domain/bpjs-entities/control-plan"
	u "simrs-vx/internal/use-case/bpjs-use-case/control-plan"

	d "github.com/karincake/dodol"
	rw "github.com/karincake/risoles"
)

func GetList(w http.ResponseWriter, r *http.Request) {
	dto := e.ReadListDto{}
	pValue1 := rw.ValidateString(w, "controlType", r.PathValue("controlType"))
	if pValue1 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "controlType is required"}, nil)
	}
	pValue2 := rw.ValidateString(w, "polyCode", r.PathValue("polyCode"))
	if pValue2 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "polyCode is required"}, nil)
	}
	pValue3 := rw.ValidateString(w, "date", r.PathValue("date"))
	if pValue3 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "date is required"}, nil)
	}
	dto.PathValue1 = pValue1
	dto.PathValue2 = pValue2
	dto.PathValue3 = pValue3
	res, err := u.ReadList(dto)
	rw.DataResponse(w, res, err)
}
