package com.example;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;

public class LoginController {

    @FXML
    private Label mainTitle;

    @FXML
    private Button cartBtn;

    @FXML
    private Button loginBtn;

    @FXML
    private TextField usernameInput;

    @FXML
    private PasswordField passwordInput;

    @FXML
    private Button loginButton;

    @FXML
    private Label footerCopyText;

    @FXML
    private void handleCartButtonClick(MouseEvent event) {
        System.out.println("Cart button clicked.");
        // Logic to navigate to the cart page
    }

    @FXML
    private void handleLoginButtonClick(MouseEvent event) {
        String username = usernameInput.getText();
        String password = passwordInput.getText();

        if (validateCredentials(username, password)) {
            System.out.println("Login successful!");
            // Navigate to the main page or user dashboard
        } else {
            System.out.println("Invalid username or password.");
        }
    }

    private boolean validateCredentials(String username, String password) {
        // Replace this with actual authentication logic
        return "user".equals(username) && "password".equals(password);
    }
}
