using System;
using Microsoft.AspNetCore.Components;
using TestDialogManager.Components;
using TestDialogManager.Interfaces;

namespace TestDialogManager.Dialogs
{
    public partial class FmMessageDialog : DialogComponentBase
    {
        [Parameter] public string HeaderText { get; set; }
        [Parameter] public string MessageText { get; set; }
        [Parameter] public DialogButtons DialogButtons { get; set; }
        [Parameter] public bool CloseWhenOverlayClicked { get; set; }
        [Parameter] public Action<DialogResult> Callback { get; set; }
        [Parameter] public DialogImage DialogImage { get; set; }
        [Parameter] public object Parameter { get; set; }

        public void OverlayClicked()
        {
            if (CloseWhenOverlayClicked)
            {
                Close(DialogButtonResult.None);
            }
        }

        public void Close(DialogButtonResult dialogButtonResult)
        {
            Console.WriteLine("DialogComponentBase.Close()");
            Close();
            Callback?.Invoke(new DialogResult(dialogButtonResult, Parameter));
        }

        private string GetDialogImage()
        {
            switch (DialogImage)
            {
                case DialogImage.Info:
                    return "far fa-info-circle";
                case DialogImage.Question:
                    return "fal fa-question-circle";
                case DialogImage.Warn:
                    return "far fa-exclamation-triangle";
                case DialogImage.Error:
                    return "far fa-times-circle";
                default:
                    return string.Empty;
            }
        }
        private string GetColor()
        {
            switch (DialogImage)
            {
                case DialogImage.Info:
                case DialogImage.Question:
                    return "White";
                case DialogImage.Warn:
                    return "Yellow";
                case DialogImage.Error:
                    return "#ff4d4d";
                default:
                    return "Inherit";
            }
        }
    }
}

