package cz.moneta.test.dsl.newib.components;

import cz.moneta.test.dsl.newib.accounts.NewForeignAccountPromoPage;
import cz.moneta.test.dsl.newib.mainpage.*;
import cz.moneta.test.dsl.newib.payments.NewPaymentDomesticPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.Builder;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.components.VerticalMainMenu.*;

@Wait(value = {VERTICAL_MENU_XPATH, OVERVIEW_ITEM_XPATH, ACCOUNTS_ITEM_XPATH, SAVINGS_ITEM_XPATH, CARDS_ITEM_XPATH, INVESTMENTS_ITEM_XPATH, EXCHANGE_ITEM_XPATH}, waitSecondsForElement = 30)
public interface VerticalMainMenu extends Builder, StoreAccessor {
    String VERTICAL_MENU_XPATH = "//nav[@data-testid='Menu']/following::ul[@data-testid='MenuList']";
    String NEW_PAYMENT_BUTTON_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Zaplatit']/parent::button";

    // Menu button items
    String OVERVIEW_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Přehled']/parent::button";
    String ACCOUNTS_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Účty']/parent::button";
    String SAVINGS_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Spoření']/parent::button";
    String LOANS_AND_MORTGAGES_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Půjčky a hypotéky']/parent::button";
    String CARDS_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Karty']/parent::button";
    String INSURANCE_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Pojištění']/parent::button";
    String INVESTMENTS_ITEM_XPATH = VERTICAL_MENU_XPATH + "//li[@data-testid='investments-link']/button[@aria-disabled='false' and not(@disabled)]";
    String EXCHANGE_ITEM_XPATH = VERTICAL_MENU_XPATH + "//span[text()='Směnárna']/parent::button";

    @Click(NEW_PAYMENT_BUTTON_XPATH)
    NewPaymentDomesticPage clickPayment();

    @Click(OVERVIEW_ITEM_XPATH)
    DashboardPage goToDashboard();

    @Click(ACCOUNTS_ITEM_XPATH)
    AccountsPage goToAccounts();

    @Click(SAVINGS_ITEM_XPATH)
    SavingsPage goToSavings();

    @Click(LOANS_AND_MORTGAGES_ITEM_XPATH)
    LoansAndMortgagesPage goToLoansAndMortgages();

    @Click(CARDS_ITEM_XPATH)
    CardsPage goToCards();

    @Click(INSURANCE_ITEM_XPATH)
    InsurancePage goToInsurance();

    @Wait(value = INVESTMENTS_ITEM_XPATH, until = Until.CLICKABLE)
    @Click(INVESTMENTS_ITEM_XPATH)
    InvestmentsPage goToInvestments();

    @Click(EXCHANGE_ITEM_XPATH)
    ExchangePage goToExchange();

    @Click(EXCHANGE_ITEM_XPATH)
    NewForeignAccountPromoPage goToForeignCurrencyAccountFromExchange();
}
