import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class AccountSettingsPage {
  WebDriver driver;
  WebDriverWait waiter;

  @FindBy(how = How.ID, using = "input-firstName")
  WebElement firstNameInput;

  @FindBy(how = How.ID, using = "input-lastName")
  WebElement lastNameInput;

  @FindBy(how = How.ID, using = "emailIdaccount")
  WebElement emailInput;

  @FindBy(how = How.ID, using = "phoneNumber")
  WebElement phoneInput;


  public AccountSettingsPage(WebDriver driver) {
    this.driver = driver;
//    this.waiter = new WebDriverWait(this.driver, 5);
    PageFactory.initElements(driver, this);
  }

  public void confirmLogin(String firstName, String lastName, String email, String phone) {

//    this.waiter.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Account Settings")));

    assertAll("First name, last name, and email should match account props",
            () -> assertEquals(firstName, firstNameInput.getAttribute("value")),
            () -> assertEquals(lastName, lastNameInput.getAttribute("value")),
            () -> assertEquals(email, emailInput.getAttribute("value")),
            () -> assertEquals(phone, phoneInput.getAttribute("value"))

//            () -> assertEquals(email, firstName) // should fail
    );
  }

}
