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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.components.HorizontalMainMenu;
import cz.moneta.test.dsl.newib.components.VerticalMainMenu;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.CheckElementPresent;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.settings.payments.templates.TemplatesPage.*;

@Wait(value = {TEMPLATES_TITLE_XPATH, CREATE_TEMPLATE_BTN_XPATH}, waitSecondsForElement = 30)
public interface TemplatesPage extends NewIbPageFlow<TemplatesPage>, HorizontalMainMenu, VerticalMainMenu, StoreAccessor {

    String TEMPLATES_TITLE_XPATH = "//h2[@class='t-title t-title--h3'][text()='Šablony']";
    String CREATE_TEMPLATE_BTN_XPATH = "//button[@data-testid='create-template-button']";
    String FOREIGN_TAB_XPATH = "//div[@class='c-tabs__text']//div[text()='Zahraniční']";
    String DESTINATION_ACC_NUMBER = "//div[@data-testid='TextComponent']//small[text()='%s']";
    String TEMPLATE_NAME_XPATH = "//td[contains(@class, 'c-contentTableRow__titleColumn')]//h2[text()='%s']";
    String DELETE_BTN_XPATH = "//span[contains(@class, 'c-avatar') and contains(@class, 'c-avatar--bin') and contains(@class, 'c-avatar--transparent')]";
    String DELETE_CONFIRMATION_BTN_XPATH = "//button[@data-testid='button-confirm'][text()='Smazat']";
    String CONFIRMATION_TITLE_FOR_DELETE_XPATH = "//h2[@class='t-title t-title--h3 c-modal__title'][text()='Šablona je smazána.']";
    String CLOSE_BTN_XPATH = "//button[@data-testid='confirm-close-and-reload'][text()='Zavřít']";

    @Click(CREATE_TEMPLATE_BTN_XPATH)
    CreateNewTemplatePage createTemplate();

    @Click(DELETE_BTN_XPATH)
    TemplatesPage deleteTemplate();

    @Click(DELETE_CONFIRMATION_BTN_XPATH)
    TemplatesPage confirmDeleteTemplate();

    @Click(CLOSE_BTN_XPATH)
    TemplatesPage closeModal();

    @CheckElementPresent(value = TEMPLATE_NAME_XPATH, isStringDynamicXpath = true)
    TemplatesPage checkTemplateName(String templateName);

    @CheckElementPresent(value = DESTINATION_ACC_NUMBER, isStringDynamicXpath = true)
    TemplatesPage checkDestinationAccNumber(String destinationAccNumber);

    @CheckElementPresent(CONFIRMATION_TITLE_FOR_DELETE_XPATH)
    TemplatesPage checkDeleteConfirmationTitleIsPresent();

    @Click(FOREIGN_TAB_XPATH)
    TemplatesPage clickOnForeignTab();
}
