using DevExpress.Blazor;
using DevExpress.Blazor.Internal;

namespace FruitBankHybrid.Shared.Extensions;

public static class DevexpressComponentExtensions
{
    public static async Task ShowMessageBoxAsync(this IDialogService messageBox, string title, string text, MessageBoxRenderStyle messageBoxRenderStyle)
    {
        var messageBoxOptions = CreateMessageBoxOptions(title, text, messageBoxRenderStyle);

        await messageBox.AlertAsync(messageBoxOptions);
    }

    public static async Task<bool> ShowConfirmBoxAsync(this IDialogService messageBox, string title, string text, MessageBoxRenderStyle messageBoxRenderStyle)
    {
        var messageBoxOptions = CreateMessageBoxOptions(title, text, messageBoxRenderStyle);

        return await messageBox.ConfirmAsync(messageBoxOptions);
    }

    private static MessageBoxOptions CreateMessageBoxOptions(string title, string text, MessageBoxRenderStyle messageBoxRenderStyle)
    {
        var messageBoxOptions = new MessageBoxOptions
        {
            Title = title,
            Text = text,
            RenderStyle = messageBoxRenderStyle,
            ShowIcon = false
        };
        return messageBoxOptions;
    }
}