package utils

import "math"

type PageViewModel struct {
	Total       int  `json:"total"`
	PageNumber  int  `json:"pageNumber"`
	PageSize    int  `json:"pageSize"`
	TotalPages  int  `json:"totalPages"`
	HasPrevious bool `json:"hasPrevious"`
	HasNext     bool `json:"hasNext"`
}

// NewPageViewModel creates a new PageViewModel with calculated fields
func NewPageViewModel(count, pageNumber, pageSize int) *PageViewModel {
	totalPages := int(math.Ceil(float64(count) / float64(pageSize)))

	return &PageViewModel{
		Total:       count,
		PageNumber:  pageNumber,
		PageSize:    pageSize,
		TotalPages:  totalPages,
		HasPrevious: pageNumber > 1,
		HasNext:     pageNumber < totalPages,
	}
}
