@using MongoDB.Bson;

<MudDrawer @bind-Open="_visible" Anchor="Anchor.End" Elevation="0" Variant="@DrawerVariant.Temporary" ClipMode="DrawerClipMode.Always" Width="400px" Style="max-width:auto;">
    <MudDrawerHeader>
        <MudText Typo="Typo.h6">
            Customer
        </MudText>
    </MudDrawerHeader>
    <MudStack Class="px-6">
        @if (_model is not null)
        {
            @if (_model.Customer is not null)
            {
                <MudStack Justify="Justify.Center">
                    <MudButton Href="@Navigation.Management.Customers.DetailsHref(_model.Customer)" Variant="Variant.Filled" Size="Size.Large" Color="Color.Info" DisableElevation="true">
                        Select
                    </MudButton>
                    <MudButton OnClick="UnassignAsync" Variant="Variant.Filled" DisableElevation Size="Size.Large" Color="Color.Error">
                        Unassign
                    </MudButton>
                    <MudButton OnClick="()=>_visible = false" Variant="Variant.Outlined" DisableElevation Size="Size.Large" Color="Color.Surface">
                        Cancel
                    </MudButton>
                </MudStack>
            }
            else
            {
                <MudStack Justify="Justify.Center">
                    <MudButton Href="@Navigation.Management.Hosts.CustomerAssingHref(_model.Id)" Variant="Variant.Filled" DisableElevation Size="Size.Large" Color="Color.Error">
                        Assign
                    </MudButton>
                    <MudButton OnClick="()=>_visible = false" Variant="Variant.Outlined" DisableElevation Size="Size.Large" Color="Color.Surface">
                        Cancel
                    </MudButton>
                </MudStack>
            }
        }
    </MudStack>
</MudDrawer>

@code {
    private bool _visible;
}