using Connected.Components;
using Connected.Models.Modal;
using Microsoft.AspNetCore.Components;

namespace Connected.Services;
public class ModalDialogService
{
	public event Action<string, RenderFragment, List<ModalButton>, ModalOptions> OnShow;
	public event Action OnClose;

	public void ShowDialog(string title, RenderFragment content, List<ModalButton> buttons, ModalOptions options)
	{
		OnShow?.Invoke(title, content, buttons, options);
	}

	public void ShowDialog(string title, MarkupString contentMarkup, List<ModalButton> buttons, ModalOptions options)
	{
		var content = new RenderFragment(x => x.AddContent(1, contentMarkup));
		OnShow?.Invoke(title, content, buttons, options);
	}

	public void Close()
	{
		OnClose?.Invoke();
	}


}
