using ReAct_PME.ViewModels;
using Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ReAct_PME
{
    /// <summary>
    /// Logique d'interaction pour DetailEmailSentRelance.xaml
    /// </summary>
    public partial class DetailEmailSentRelance : Window
    {
        private ThreadItem? SelectedItem;
        private DetailEmailSentRelance_VM _VM;

        public DetailEmailSentRelance(ThreadItem selectedItem)
        {
            InitializeComponent();
            _VM = new DetailEmailSentRelance_VM(selectedItem);
            this.DataContext = _VM;
            SelectedItem = selectedItem;

        }

        private async void OnGenerateAgainClick(object sender, RoutedEventArgs e)
        {
            bool b = await _VM.GenerateAgainReponse();
        }

        private async void OnEnvoyerClick(object sender, RoutedEventArgs e)
        {
            bool b = await _VM.EnvoyerReponse();
            if (b)
            {
                StatusText.Text = "Relance envoyée avec succès !";
                StatusText.Foreground = System.Windows.Media.Brushes.Green;
            }
            else
            {
                StatusText.Text = $"Erreur dans l'envoi de la relance.";
                StatusText.Foreground = System.Windows.Media.Brushes.Red;
            }
        }

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