// Mock user credentials
const mockUsers = [
  { username: "gva.server@gmail.com", password: "romanos12:2" },
  { username: "fernanda@vilarkptl.com", password: "Mxfe!200301" },
  { username: "andre@vilarkptl.com", password: "Variousq7!" },
  { username: "hector@vilarkptl.com", password: "Soyhector1" },
  
  
];

// Function to handle form submission
function handleLogin(event) {
  event.preventDefault();

  const usernameInput = document.getElementById("username");
  const passwordInput = document.getElementById("password");
  const loginMessage = document.getElementById("loginMessage");

  const enteredUsername = usernameInput.value;
  const enteredPassword = passwordInput.value;

  // Simulating login check
  const user = mockUsers.find(
    (user) =>
      user.username === enteredUsername && user.password === enteredPassword
  );

  if (user) {
    loginMessage.textContent = "Login exitoso. Redirigiendo a Dashboard...";
    // Redirect to the dashboard page after a brief delay (for demo purposes)
    setTimeout(() => {
      window.location.href = "pages/masterDB.html";
    }, 2000);
  } else {
    loginMessage.textContent = "Invalid username or password. Please try again.";
  }
}

// Attach event listener to the form
const loginForm = document.getElementById("loginForm");
loginForm.addEventListener("submit", handleLogin);
