package pagination 

import "strconv"
import "cpone/component/customtextfield"
import "cpone/models"

templ PaginationV2(length int,
	currentPage int,
	link string,
	paginationID string,
	hxInclude string,
	hxTarget string,
	hxSwap string,
	hxIndicator string,
	hxSwapOob string) {
	// hx-on::before-request={ HideContent(contentID) }
	// hx-on::after-request="alert('Done making a request!')"
	<div class="d-flex justify-content-between align-items-center flex-wrap" id={ paginationID } hx-swap-oob={ hxSwapOob }>
		<div class="d-flex flex-wrap py-2 mr-3">
			for i:=0; i<length; i++ {
				if (i+1) == currentPage {
					<a
						hx-get={ link + "?" + "page=" + strconv.Itoa(i+1) }
						class="btn btn-icon btn-sm border-0 btn-light btn-hover-primary active mr-2 my-1"
						hx-swap={ hxSwap }
						hx-indicator={ hxIndicator }
						hx-trigger="click"
						hx-target={ hxTarget }
						hx-include={ hxInclude }
					>{ strconv.Itoa(i+1) }</a>
				} else {
					<a
						hx-get={ link + "?" + "page=" + strconv.Itoa(i+1) }
						class="btn btn-icon btn-sm border-0 btn-light mr-2 my-1 btneditug"
						hx-swap={ hxSwap }
						hx-indicator={ hxIndicator }
						hx-trigger="click"
						hx-target={ hxTarget }
						hx-include={ hxInclude }
					>{ strconv.Itoa(i+1) }</a>
				}
			}
		</div>
		@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{
			ID:    "currpage" + paginationID,
			Name:  "currpage" + paginationID,
			Type:  "hidden",
			Value: strconv.Itoa(currentPage)})
	</div>
}
