package cz.moneta.test.dsl.newib.settings.communication.contacts;

import cz.moneta.test.dsl.newib.NewIbPageFlow;
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.communication.contacts.ContactsPage.*;

@Wait(value = {CONTACTS_TITLE_XPATH, NEW_CONTACT_BTN_XPATH}, waitSecondsForElement = 30)
public interface ContactsPage extends NewIbPageFlow<ContactsPage> {
    String CONTACTS_TITLE_XPATH = "//h1[@class='t-title t-title--h3'][text()='Kontakty']";
    String NEW_CONTACT_BTN_XPATH = "//button[@data-testid='create-contact-button']";
    String DELETE_CONTACT_BTN_XPATH = "//tr[.//h2[normalize-space()='%s']]//button[@aria-label='Smazat']";
    String EDIT_CONTACT_BTN_XPATH = "//tr[.//h2[normalize-space()='%s']]//button[@aria-label='Upravit']";
    String CREATED_CONTACT_NAME_XPATH = "//h2[@class='t-title t-title--h6 c-contentTableRow__title'][text()='%s']";
    String CONFIRM_DELETE_BTN_XPATH = "//button[@data-testid='button-confirm'][text()='Smazat']";
    String CONTACT_DELETED_CONFIRM_SCREEN_VICTORY_TEXT = "//h2[@class='t-title t-title--h3 c-modal__title'][text()='Kontakt je smazaný']";
    String CLOSE_DELETED_CONFIRM_MODAL_BTN_XPATH = "//button[@data-testid='confirm-close-and-reload'][text()='Zavřít']";
    String CONTACT_FOR_MOBILE_KEY_XPATH = "//h2[@class='t-title t-title--h6 c-contentTableRow__title'][text()='Telefon pro mobilní klíč IB']";

    @Click(NEW_CONTACT_BTN_XPATH)
    CreateNewContactPage createNewContact();

    @CheckElementPresent(value = CREATED_CONTACT_NAME_XPATH, isStringDynamicXpath = true)
    ContactsPage checkCreatedContactName(String createdContactName);

    @Click(value = DELETE_CONTACT_BTN_XPATH, isStringDynamicXpath = true)
    ContactsPage deleteContact(String createdContactName);

    @Click(CONFIRM_DELETE_BTN_XPATH)
    ContactsPage confirmDeleteContact();

    @CheckElementPresent(CONTACT_DELETED_CONFIRM_SCREEN_VICTORY_TEXT)
    ContactsPage checkContactDeletedVictoryTextIsPresent();

    @Click(CLOSE_DELETED_CONFIRM_MODAL_BTN_XPATH)
    ContactsPage closeDeletedContactConfirmationModal();

    @CheckElementPresent(CONTACT_FOR_MOBILE_KEY_XPATH)
    ContactsPage checkContactForMobileKeyExist();

    @Click(value = EDIT_CONTACT_BTN_XPATH, isStringDynamicXpath = true)
    CreateNewContactPage editContact(String createdContactName);
}
