package cz.moneta.test.dsl.ib.account.saving;

import cz.moneta.test.dsl.ib.IbPageFlow;
import cz.moneta.test.dsl.ib.components.MainMenu;
import cz.moneta.test.dsl.ib.components.SavingMenu;
import cz.moneta.test.harness.support.web.CheckElementPresent;
import cz.moneta.test.harness.support.web.CheckElementsPresent;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.ib.account.saving.TransferOfFoundsCheckPage.*;

@Wait({PAGE_ID, IMG_NAME_OF_PAGE, SECOND_STEP_IN_PROGRESS_IMG})
public interface TransferOfFoundsCheckPage extends IbPageFlow<TransferOfFoundsCheckPage>, MainMenu, SavingMenu {
    String PAGE_ID = "//div[@id='parentform']";
    String IMG_NAME_OF_PAGE = "//img[@alt='Převod prostředků']";
    String SECOND_STEP_IN_PROGRESS_IMG = PAGE_ID + "//img[@src='images_new/top_step2.gif']";
    String WITHOUT_SIGN_BUTTON = PAGE_ID + "//a[@id='sendNoSign' and contains(text(),'BEZ PODPISU')]";
    String SAVE_TO_SIGN_BUTTON = PAGE_ID + "//a[@id='sendToWaitingRoom' and contains(text(),'ULOŽIT K PODPISU')]";

    //Transaction to saving account
    String FROM_ACCOUNT_CA_XPATH = PAGE_ID + "//td[contains(text(),'Z účtu')]/following-sibling::td[contains(text(),'Běžný účet CZK')]";
    String TO_ACCOUNT_SA_XPATH = PAGE_ID + "//td[contains(text(),'Na účet')]/following-sibling::td[contains(text(),'Spořicí účet CZK')]";
    String VALUE = PAGE_ID + "//td[contains(text(),'Částka')]/following-sibling::td[contains(text(),'%s')]";

    //Transaction to current account
    String FROM_ACCOUNT_SA_XPATH = PAGE_ID + "//td[contains(text(),'Z účtu')]/following-sibling::td[contains(text(),'Spořicí účet CZK')]";
    String TO_ACCOUN_CA_XPATH = PAGE_ID + "//td[contains(text(),'Na účet')]/following-sibling::td[contains(text(),'Běžný účet CZK')]";

    @CheckElementsPresent({
            @CheckElementPresent(value = FROM_ACCOUNT_CA_XPATH),
            @CheckElementPresent(value = TO_ACCOUNT_SA_XPATH),
            @CheckElementPresent(value = VALUE, isStringDynamicXpath = true)
    })
    TransferOfFoundsCheckPage checkValuesToTransactionToSavingAccount(String valueOfAmount);

    @Click(WITHOUT_SIGN_BUTTON)
    TransferOfFoundsConfirmPage clickToWithoutSignButton();

    @CheckElementsPresent({
            @CheckElementPresent(value = FROM_ACCOUNT_SA_XPATH),
            @CheckElementPresent(value = TO_ACCOUN_CA_XPATH),
            @CheckElementPresent(value = VALUE, isStringDynamicXpath = true)
    })
    TransferOfFoundsCheckPage checkValuesToTransactionFromSavingAccount(String valueOfAmount);

    @Click(SAVE_TO_SIGN_BUTTON)
    TransferOfFoundsConfirmPage clickSaveToSignButton();
}
