using MudBlazor;
using salesbook.Shared.Components.SingleElements.Modal;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;

namespace salesbook.Shared.Core.Helpers;

public class ModalHelpers
{
    public static async Task<DialogResult?> OpenActivityForm(IDialogService dialog, ActivityDTO? activity, string? id)
    {
        var modal = await dialog.ShowAsync<ActivityForm>(
            "Activity form",
            new DialogParameters<ActivityForm>
            {
                { x => x.Id, id },
                { x => x.ActivityCopied, activity }
            },
            new DialogOptions
            {
                FullScreen = true,
                CloseButton = false,
                NoHeader = true
            }
        );

        return await modal.Result;
    }

    public static async Task<DialogResult?> OpenUserForm(IDialogService dialog, ContactDTO? anag)
    {
        var modal = await dialog.ShowAsync<ContactForm>(
            "User form",
            new DialogParameters<ContactForm>
            {
                { x => x.OriginalModel, anag }
            },
            new DialogOptions
            {
                FullScreen = true,
                CloseButton = false,
                NoHeader = true
            }
        );

        return await modal.Result;
    }

    public static async Task<DialogResult?> OpenPersRifForm(IDialogService dialog, PersRifDTO? persRif, 
        ContactDTO? contactModel = null, List<PersRifDTO>? persRifList = null)
    {
        var modal = await dialog.ShowAsync<PersRifForm>(
            "Pers rif form",
            new DialogParameters<PersRifForm>
            {
                { x => x.OriginalModel, persRif },
                { x => x.ContactModel,  contactModel},
                { x => x.PersRifList, persRifList }
            },
            new DialogOptions
            {
                FullScreen = true,
                CloseButton = false,
                NoHeader = true
            }
        );

        return await modal.Result;
    }

    public static async Task<DialogResult?> OpenAddAttached(IDialogService dialog, bool canAddPosition)
    {
        var modal = await dialog.ShowAsync<AddAttached>(
            "Add attached",
            new DialogParameters<AddAttached>
            {
                { x => x.CanAddPosition,  canAddPosition}
            },
            new DialogOptions
            {
                FullScreen = false,
                CloseButton = false,
                NoHeader = true,
                BackdropClick = false
            }
        );

        return await modal.Result;
    }
}