package controllers_join

import (
	"encoding/json"
	"net/http"
	"syncscan-go/locals"
	models_join "syncscan-go/models/join"

	"github.com/dabory/abango-rest"
	"github.com/labstack/echo"
)

type SlipSearchPageReq struct {
	QueryVars        locals.QueryVars
	SlipSearchVars   locals.SlipSearchVars
	SlipSearchFields locals.SlipSearchFields
	PageVars         locals.PageVars
}

func SlipSearchPage(c echo.Context) error {

	v := c.Get("receiver").(SlipSearchPageReq)
	y := c.Get("abango").(abango.Controller)

	vRet := &struct {
		models_join.SlipSearchPageRet
	}{}

	vRet.QueryVars = v.QueryVars
	vRet.SlipSearchVars = v.SlipSearchVars
	vRet.SlipSearchFields = v.SlipSearchFields
	vRet.PageVars = v.PageVars

	// fmt.Println(y.Gtb.UserId)

	if err := vRet.GetSlipSearchPage(&y); err != nil {
		return c.String(607, err.Error())
	}

	ret, _ := json.Marshal(vRet)
	return c.JSONBlob(http.StatusOK, ret)

}
