@using BlazorApp.Components;
@using BlazorApp.Pages;
@using BlazorApp.Models;

<CascadingValue Value="@this">
    <div class="container">
        <div class="row">
            <div class="col-6">

                <h3>@Localizer["Inventory"]</h3>

                    <div class="css-grid">

                        @for(int i=0; i<InventorySize; i++)
                         {
                            <InventoryItem Index="@i" Item="@InventoryItems[i].Item" NbItem="@InventoryItems[i].NbItem"/>
                         }

                    </div>

            </div>

            <div class="col-6">
                
                <div>@Localizer["AvailableItems"]</div>

                <div class="css-dataGrid">

                    <div class="bar">
                        <input type="text" oninput="@OnInput"/>
                        <Button type="submit" @onclick="() => SortByName()">@Localizer["Sort"]</Button>
                    </div>
                    <DataGrid TItem="Item"
                              Data="@Items"
                              ReadData="@OnReadData"
                              TotalItems="@totalItem"
                              PageSize="10"
                              ShowPager>


                        <DataGridColumn TItem="Item" Field="@nameof(Item.Id)">
                            <DisplayTemplate>
                                <InventoryItem Item="@context" NoDrop="true" />
                            </DisplayTemplate>
                        </DataGridColumn>
                        <DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" />
                    </DataGrid>

                </div>

            </div>

         </div>
        
    </div>
</CascadingValue>