@using salesbook.Shared.Core.Entity

<MudDialog OnBackdropClick="Cancel">
    <DialogContent>
        @if (!ActivityTypers.IsNullOrEmpty())
        {
            <MudList T="string" SelectedValueChanged="OnClickItem">
                @foreach (var item in ActivityTypers!)
                {
                    <MudListItem Text="@item.ActivityTypeDescription" Value="item.ActivityTypeDescription"/>
                }
            </MudList>
        }
        else
        {
            <div class="spinner-container">
                <MudIcon Size="Size.Large" Color="Color.Error" Icon="@Icons.Material.Rounded.Close"/>
                <MudText>Nessuna descrizione consigliata</MudText>
            </div>
        }
    </DialogContent>
</MudDialog>

@code {
    [CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
    [Parameter] public List<StbActivityTyper>? ActivityTypers { get; set; }

    private void Cancel() => MudDialog.Cancel();

    private void OnClickItem(string? selectedValue) =>
        MudDialog.Close(DialogResult.Ok(selectedValue));
}