@using Insight.Web.Pages.Management.Customers;
@inherits ComponentBase

<TableContainer T="CustomerEntity"
                @ref="Container"
                @bind-Search="Search"
                Title="@Title"
                Breadcrumbs="@Breadcrumbs"
                Data="LoadDataAsync"
                OnAdd="()=>_createDialog?.ToggleAsync()">
    <Header>
        <MudTh>
            <MudTableSortLabel SortLabel="Name" T="CustomerEntity">
                Name
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Tag" T="CustomerEntity">
                Tag
            </MudTableSortLabel>
        </MudTh>
    </Header>
    <RowTemplate>
        <MudTd DataLabel="Name">
            <MudLink Href="@Navigation.Management.Customers.DetailsHref(context?.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Tag">
            @context?.Tag
        </MudTd>
    </RowTemplate>
    <ActionTemplate>
        <MudMenuItem OnClick="@(()=>OnAssignAsync(context))">
            Assign
        </MudMenuItem>
    </ActionTemplate>
</TableContainer>

<CustomerCreateDialog @ref="_createDialog" OnChanges="OnRefreshAsync" />

@code {
    private CustomerCreateDialog? _createDialog;
}