package adminkindboxreqservice

import (
	"context"

	paginationparam "git.gocasts.ir/ebhomengo/niki/param"
	param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (s Service) GetAllAwaitingDelivery(ctx context.Context, req param.DeliveryAwaitingGetAllRequest) (param.DeliveryAwaitingGetAllResponse, error) {
	const op = "adminkindboxreqservice.GetAllAwaitingDelivery"

	allAwaitingKindBoxReq, total, err := s.repo.GetAllKindBoxReq(ctx, req.Filter, req.Pagination, req.Sort)
	if err != nil {

		return param.DeliveryAwaitingGetAllResponse{}, richerror.New(op).WithErr(err)
	}

	return param.DeliveryAwaitingGetAllResponse{
		AllAwaitingKindBoxReq: allAwaitingKindBoxReq,
		Pagination: paginationparam.PaginationResponse{
			PageSize:   req.Pagination.GetPageSize(),
			PageNumber: req.Pagination.GetPageNumber(),
			Total:      total,
		},
	}, nil
}
