package member

import (
	"net/http"

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

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

func GetListByBpjsNumber(w http.ResponseWriter, r *http.Request) {
	dto := e.ReadListDto{}
	pValue1 := rw.ValidateString(w, "cardNumber", r.PathValue("cardNumber"))
	if pValue1 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "cardNumber is required"}, nil)
	}
	pValue2 := rw.ValidateString(w, "sepDate", r.PathValue("sepDate"))
	if pValue2 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "sepDate is required"}, nil)
	}
	dto.ReferenceType = e.RTBpjs
	dto.PathValue1 = pValue1
	dto.PathValue2 = pValue2
	res, err := u.ReadList(dto)
	rw.DataResponse(w, res, err)
}

func GetListByNik(w http.ResponseWriter, r *http.Request) {
	dto := e.ReadListDto{}
	pValue1 := rw.ValidateString(w, "nik", r.PathValue("nik"))
	if pValue1 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "nik is required"}, nil)
	}
	pValue2 := rw.ValidateString(w, "sepDate", r.PathValue("sepDate"))
	if pValue2 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "sepDate is required"}, nil)
	}
	dto.ReferenceType = e.RTNik
	dto.PathValue1 = pValue1
	dto.PathValue2 = pValue2
	res, err := u.ReadList(dto)
	rw.DataResponse(w, res, err)
}
