groceries/Groceries/Components/TablePaginator.razor

35 lines
927 B
Plaintext

@inject NavigationManager Navigation
<div class="table__paginator">
<span>
Showing @FirstItem to @LastItem of @Model.Total results
</span>
<nav class="button-group">
@if (Model.Page == 1)
{
<span class="link link--disabled">Previous</span>
}
else
{
<a class="link" href="@Navigation.GetUriWithQueryParameter("page", Model.Page - 1)">Previous</a>
}
@if (Model.Page == Model.LastPage)
{
<span class="link link--disabled">Next</span>
}
else
{
<a class="link" href="@Navigation.GetUriWithQueryParameter("page", Model.Page + 1)">Next</a>
}
</nav>
</div>
@code {
[Parameter]
public required IListPageModel Model { get; set; }
private int FirstItem => Model.Count > 0 ? Model.Offset + 1 : 0;
private int LastItem => Model.Offset + Model.Count;
}