using ReAct_PME.ViewModels;
using Services;
using System.Windows;

namespace ReAct_PME
{
    /// <summary>
    /// Logique d'interaction pour RechercheCVDetail.xaml
    /// </summary>
    public partial class RechercheCVDetail : Window, IToastNotifier
    {
        private ReponseRechercheCV SelectedItem;
        private RechercheCV_VM _VM;

        public RechercheCVDetail(ReponseRechercheCV selectedItem)
        {
            InitializeComponent();
            SelectedItem = selectedItem;
            _VM = new RechercheCV_VM(SelectedItem, this);
            this.DataContext = _VM;
        }

        private void OnFermerClick(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        #region Implémentation de IToastNotifier
        public void ShowToast(string message, int durationMs = 10000)
        {
            Dispatcher.Invoke(() =>
            {
                ToastMessage.Text = message;
                ToastPopup.IsOpen = true;
            });

            Task.Delay(durationMs).ContinueWith(_ =>
            {
                Dispatcher.Invoke(() => ToastPopup.IsOpen = false);
            });
        }

        #endregion
    }
}
