@page "/chapters"
@using Blazor.ViewClasses;
@using Blazorise.DataGrid
@using Blazored.Modal;
<h3>Chapters</h3>

<div>
    <NavLink class="btn btn-primary" href="addChapter" Match="NavLinkMatch.All">
        <i class="fa fa-plus"></i> Ajouter
    </NavLink>
    <NavLink class="btn btn-primary" @onclick="Export">
        <i class="fa fa-plus"></i> Exporter
    </NavLink>
    <InputFile OnChange="@SingleUpload"/>
</div>

<DataGrid TItem="Chapter"
          Data="@chapters"
          ReadData="@OnReadData"
          TotalItems="@totalChapter"
          PageSize="10"
          ShowPager
          Responsive>
    <DataGridColumn TItem="Chapter" Field="@nameof(Chapter.Id)" Caption="#" />
    <DataGridColumn TItem="Chapter" Field="@nameof(Chapter.Name)" Caption="Display name" />
    <DataGridColumn TItem="Chapter" Field="@nameof(Chapter.Id)" Caption="Action">
        <DisplayTemplate>
            <a href="editChapter/@(context.Id)" class="btn btn-primary"><i class="fa fa-edit"></i> Editer</a>
            <button type="button" class="btn btn-primary" @onclick="() => OnDelete(context.Id)"><i class="fa fa-trash"></i> Supprimer</button>
        </DisplayTemplate>
    </DataGridColumn>
</DataGrid>
