@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.QueryPublisher.QueryResultViewModel>
@using Dynamicweb
@using Dynamicweb.Core
@using System.Net

@{
	var querystring = System.Web.HttpUtility.ParseQueryString(Dynamicweb.Context.Current?.Request.Url?.Query ?? string.Empty);
	querystring.Remove("PageNum");
	string baseUrl = (Dynamicweb.Context.Current?.Request.Url?.AbsolutePath ?? "/") + (querystring.Count > 0 ? "?" + querystring : string.Empty);
}

@if (Model.PageCount > 1)
{
	<div class="hstack justify-content-between mt-3">
		<div class="text-muted fs-7">
			@Translate("Showing page") @(Model.CurrentPage) @Translate("of") @(Model.PageCount)
		</div>

		<div class="hstack gap-2">
			<button type="button" class="btn btn-outline-secondary text-body hstack p-2" data-dw-button
				hx-get="@baseUrl"
				hx-vals='{"PageNum": @(Model.CurrentPage - 1)}'
				hx-swap="outerHTML"
				hx-replace-url="true"
				hx-select="[data-swift-posts-list]"
				hx-target="[data-swift-posts-list]"
				disabled="@(Model.CurrentPage == 1)">
				<span class="icon-2">
					@ReadFile("/Files/Images/Icons/chevron-left.svg")
				</span>
			</button>
			<button type="button" class="btn btn-outline-secondary text-body hstack p-2" data-dw-button
				hx-get="@baseUrl"
				hx-vals='{"PageNum": @(Model.CurrentPage + 1)}'
				hx-swap="outerHTML"
				hx-replace-url="true"
				hx-select="[data-swift-posts-list]"
				hx-target="[data-swift-posts-list]"
				disabled="@(Model.CurrentPage == Model.PageCount)">
				<span class="icon-2">
					@ReadFile("/Files/Images/Icons/chevron-right.svg")
				</span>
			</button>
		</div>
	</div>
}
