@using salesbook.Shared.Core.Dto
@inject IDialogService Dialog

<div class="contact-card" @onclick="OpenPersRifForm">
    <div class="contact-left-section">
        <MudIcon Color="Color.Default" Icon="@Icons.Material.Filled.PersonOutline" Size="Size.Large"/>

        <div class="contact-body-section">
            <div class="title-section">
                <MudText Class="contact-title" Typo="Typo.body1" HtmlTag="h3">@UtilityString.FormatString(Contact.PersonaRif).TitleCase</MudText>
            </div>

            @if (Contact.Mansione is not null)
            {
                <MudText Class="contact-subtitle" Typo="Typo.body1" HtmlTag="p">@UtilityString.FormatString(Contact.Mansione).SentenceCase</MudText>
            }
        </div>
    </div>
    <div class="contact-right-section">
        @if (!Contact.NumCellulare.IsNullOrEmpty())
        {
            <a href="@($"tel:{Contact.NumCellulare}")">
                <MudIcon Color="Color.Success" Size="Size.Large" Icon="@Icons.Material.Outlined.Phone"/>
            </a>
        }

        @if (!Contact.EMail.IsNullOrEmpty())
        {
            <a href="@($"mailto:{Contact.EMail}")">
                <MudIcon Color="Color.Info" Size="Size.Large" Icon="@Icons.Material.Filled.MailOutline"/>
            </a>
        }
    </div>
</div>

@code {
    [Parameter] public PersRifDTO Contact { get; set; } = new();

    private async Task OpenPersRifForm()
    {
        var result = await ModalHelpers.OpenPersRifForm(Dialog, Contact);
    }
}