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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.components.HorizontalMainMenu;
import cz.moneta.test.dsl.newib.settings.payments.standingorders.StandingOrdersPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.newib.payments.StandingOrderChangePage.AMOUNT_INPUT_XPATH;
import static cz.moneta.test.dsl.newib.payments.StandingOrderChangePage.CONTINUE_BUTTON_XPATH;

@Wait(value = {StandingOrderChangePage.STANDING_ORDERS_CHANGE_TITLE_XPATH, CONTINUE_BUTTON_XPATH, AMOUNT_INPUT_XPATH}, waitSecondsForElement = 30)
public interface StandingOrderChangePage extends NewIbPageFlow<StandingOrderChangePage>, HorizontalMainMenu, StoreAccessor {
    String AMOUNT_INPUT_XPATH = "(//input[@name='amount' and not(@disabled) and not(contains(@class,'hidden'))])[last()]";
    String STANDING_ORDERS_CHANGE_TITLE_XPATH = "//h2[@class='t-title t-title--h3'][text()='Upravit trvalý příkaz']";
    String CONTINUE_BUTTON_XPATH = "(//button[@data-testid='submit' and not(@disabled) and not(contains(@class,'hidden'))])[last()]";
    String CONFIRM_BUTTON_XPATH = "//button[@data-testid='submit']";
    String MOBILE_KEY_INPUT_XPATH = "//label[@for='mobileKey']//following-sibling::div//input[@id='mobileKey']";
    String MOBILE_KEY_SEND_BTN_XPATH = "//button[@data-testid='secondFactorSend']";
    String STANDING_ORDER_CHANGE_VICTORY_TITLE_PAGE_XPATH = "//h1[contains(., 'Trvalý příkaz byl úspěšně upraven')]";
    String BACK_TO_STANDINGS_ORDERS_BUTTON_XPATH = "//button[@data-testid='standing-orders']";

    @Wait(value = AMOUNT_INPUT_XPATH, until = Until.VISIBLE)
    @TypeInto(value = AMOUNT_INPUT_XPATH, clear = true)
    StandingOrderChangePage setAmount(String amount);

    @Wait(value = CONTINUE_BUTTON_XPATH, until = Until.VISIBLE)
    @Click(CONTINUE_BUTTON_XPATH)
    StandingOrderChangePage clickOnContinue();

    @TypeInto(MOBILE_KEY_INPUT_XPATH)
    StandingOrderChangePage setMobileKey(String mobileKey);

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    StandingOrderChangePage clickOnContinueMobileKey();

    @CheckElementPresent(STANDING_ORDER_CHANGE_VICTORY_TITLE_PAGE_XPATH)
    StandingOrderChangePage checkStandingOrderChangeVictoryText();

    @Click(BACK_TO_STANDINGS_ORDERS_BUTTON_XPATH)
    StandingOrdersPage clickOnBackToStandingOrders();
}