@using Shared.DTOs
@inject HttpClient _hc
@inject NavigationManager Navigation

<div class="tp-faq-area pt-50" id="Question">
    <div class="container p-0">
        <div class="row g-0">
            <div class="col-xl-12">
              
                <div class="popular-blog-title mb-40">
                    <h4>سوالات پر تکرار</h4>
                </div>
                <div class="tp-custom-accordion">
                    <div class="accordion tp-inner-font" id="accordionExample">
                        @for (int i = 0; i < request?.list.Count; i++)
                        {
                            <ItemQuestion qitem="request?.list[i]" />
                        }
                        @*
                        @foreach (var item in request?.list)
                        {
                        <ItemQuestion Item="item" />
                        } *@

                    </div>
                </div>
            </div>
        </div>
       
    </div>
    <br />
    <div class="container">
        <nav aria-label="Page navigation">
            <ul class="pagination justify-content-center">
                @for (int page = 1; page <= request?.PageCount; page++)
                {
                    if (page == PageIndex)
                    {
                        <li class="page-item disabled">
                            <a class="page-link" href="@Navigation.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
                        </li>
                    }
                    else
                    {
                        <li class="page-item">
                            <a class="page-link" href="@Navigation.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
                        </li>
                    }
                }

            </ul>
        </nav>
    </div>
</div>

@code {
    [Parameter]
    public int PageIndex { get; set; }



    public Shared.DTOs.PagingDto<QuestionDto>? request { get; set; }

    protected override async Task OnParametersSetAsync()
    {
        request = await _hc.GetFromJsonAsync<PagingDto<QuestionDto>>($"Base/LastQuestion?PageIndex={PageIndex}&PageSize=6");
        await base.OnParametersSetAsync();
    }
}
