package cz.moneta.test.dsl.salesforce.pages.opportunities;

import cz.moneta.test.dsl.salesforce.components.PageHeader;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.salesforce.pages.opportunities.OpportunityDetailPage.NEW_EVENT_BUTTON;
import static cz.moneta.test.dsl.salesforce.pages.opportunities.OpportunityDetailPage.PAGE_TITLE;

@Wait(value = {NEW_EVENT_BUTTON, PAGE_TITLE}, until = Until.VISIBLE)
public interface OpportunityDetailPage extends WebFlow<OpportunityDetailPage>, PageHeader {
    String PAGE_TITLE = "//records-entity-label[text()='Příležitost']";
    String NEW_EVENT_BUTTON = "//button[text()='Nová událost']";
    String SALES_BUTTON = "//div[contains(@class,'active')]//button[contains(@title,'Obchody')]/../../a";
    String ACCOUNT_ID = "//p[@title='IČ']//following-sibling::p/slot/lightning-formatted-text[text()='%s']";
    String EVENT_TYPE_SELECT = "//span[text()='Typ']/../following-sibling::div/div/select";
    String EVENT_STATUS_SELECT = "//span[text()='Stav']/../following-sibling::div/div/select";
    String EVENT_BUSINESS_STATUS_SELECT = "//span[text()='Stav podnikání']/../following-sibling::div/div/select";
    String EVENT_DATE = "(//lightning-formatted-date-time)[1]";
    String EVENT_SAVE_BUTTON = "//button[text()='Save']";
    String MODAL_WINDOW = "//div[contains(@class,'uiModal')]";


    OpportunityDetailPage onOpportunityDetailPage();

    @CheckElementPresent(value = ACCOUNT_ID, isStringDynamicXpath = true)
    OpportunityDetailPage checkAccountId(String account);

    @Click(NEW_EVENT_BUTTON)
    OpportunityDetailPage newEvent();

    @Click(value = EVENT_SAVE_BUTTON, andWait = @Wait(value = MODAL_WINDOW, until = Until.GONE))
    OpportunityDetailPage saveEvent();

    @Click(SALES_BUTTON)
    SalesListPage clickSales();

    @Select(EVENT_TYPE_SELECT)
    OpportunityDetailPage selectEventType(String eventType);

    @Select(EVENT_STATUS_SELECT)
    OpportunityDetailPage selectEventStatus(String eventStatus);

    @Select(EVENT_BUSINESS_STATUS_SELECT)
    OpportunityDetailPage selectEventBusinessStatus(String eventBusinessStatus);

    @Click(EVENT_DATE)
    OpportunityDetailPage clickEventDate();

}
