@inherits ComponentBase

<TableContainer T="ViewModel"
                @ref="Container"
                @bind-Search="Search"
                Title="@Title"
                Breadcrumbs="@Breadcrumbs"
                Data="LoadDataAsync">
    <Header>
        <MudTh>
            <MudTableSortLabel SortLabel="Customer" T="ViewModel">
                Customer
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Host" T="ViewModel">
                Host
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Name" T="ViewModel">
                Name
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Description" T="ViewModel">
                Adapter
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Mac" T="ViewModel">
                Mac
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Suffix" T="ViewModel">
                Suffix
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Status" T="ViewModel">
                Status
            </MudTableSortLabel>
        </MudTh>
    </Header>
    <RowTemplate>
        <MudTd DataLabel="Customer">
            <MudLink Href="@Navigation.Management.Customers.DetailsHref(@context?.Customers?.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Customers?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Host">
            <MudLink Href="@Navigation.Management.Hosts.DetailsHref(@context?.Hosts?.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Hosts?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Name">
            <MudLink Href="@Navigation.Management.Hosts.Network.Interfaces.DetailsHref(@context?.Hosts?.Id, context?.Id?.ToString())" Typo="Typo.inherit" Underline="Underline.None">
                @{
                    var value = context?.Name;

                    if (string.IsNullOrWhiteSpace(value)) value = "N/A";

                    @value
                }
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Description">
            @context?.Description
        </MudTd>
        <MudTd DataLabel="Mac">
            @context?.Mac
        </MudTd>
        <MudTd DataLabel="Suffix">
            @context?.Suffix
        </MudTd>
        <MudTd DataLabel="Status">
            @if (context?.Status is not null && Enum.TryParse<System.Net.NetworkInformation.OperationalStatus>(context.Status, true, out var operationalStatus))
            {
                var color = operationalStatus == System.Net.NetworkInformation.OperationalStatus.Up ? Color.Success : Color.Error;

                        <MudText Color="color" Typo="Typo.inherit">
                    @context?.Status
                        </MudText>
            }
            else
            {
                @("Unknown")
            }
        </MudTd>
    </RowTemplate>
</TableContainer>