using System.Windows;
using ComputerShopWpf.Services;

namespace ComputerShopWpf.Views
{
    public partial class LoginWindow : Window
    {
        public LoginWindow()
        {
            InitializeComponent();
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            AuthService authService = new AuthService();
            string errorMessage;

            if (authService.Login(LoginTextBox.Text, UserPasswordBox.Password, out errorMessage))
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                Close();
                return;
            }

            ErrorTextBlock.Text = errorMessage;
        }
    }
}
