package cz.moneta.test.dsl.hypos.pages.contract.realty;

import cz.moneta.test.dsl.hypos.pages.HyposPageFlow;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Select;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.hypos.pages.contract.realty.AcquireApprovedSupervisionPage.APPRAISER_COMPANY_SELECT;
import static cz.moneta.test.dsl.hypos.pages.contract.realty.AcquireApprovedSupervisionPage.PAGE_TITLE;
import static cz.moneta.test.dsl.hypos.pages.contract.realty.AcquireApprovedSupervisionPage.SEND_BUTTON;

@Wait({PAGE_TITLE, APPRAISER_COMPANY_SELECT, SEND_BUTTON})
public interface AcquireApprovedSupervisionPage extends HyposPageFlow<AcquireApprovedSupervisionPage> {
    String PAGE_TITLE = "//h1[contains(text(),'Pořízení: Schválená supervize k celku č.')]";
    String APPRAISER_COMPANY_SELECT = "//select[@id='appraiser_house']";
    String APPRAISER_NAME_SELECT = "//select[@id='appraiserId']";
    String APPRAISER_NAME_FIRST_SELECT = APPRAISER_NAME_SELECT + "/option[2]";
    String APPRAISAL_DATE_INPUT = "//input[@name='toDate']";
    String REPRODUCTION_PRICE_INPUT = "//input[@id='reproPrice']";
    String CURRENT_PRICE_INPUT = "//input[@id='currentPrice']";
    String SEND_BUTTON = "//input[@value='Odeslat']";

    @Select(value = APPRAISER_COMPANY_SELECT, andWait = @Wait(value = APPRAISER_NAME_FIRST_SELECT, until = Until.VISIBLE))
    AcquireApprovedSupervisionPage selectAppraiserCompany(String companyName);

    @Select(APPRAISER_NAME_SELECT)
    AcquireApprovedSupervisionPage selectAppraiserName(String name);

    @Select(value = APPRAISER_NAME_SELECT, selectByOrder = true)
    AcquireApprovedSupervisionPage selectAppraiserNameByOrder(int order);

    @TypeInto(APPRAISAL_DATE_INPUT)
    AcquireApprovedSupervisionPage fillAppraisalDate(String date);

    @TypeInto(REPRODUCTION_PRICE_INPUT)
    AcquireApprovedSupervisionPage fillReproductionPrice(int price);

    @TypeInto(CURRENT_PRICE_INPUT)
    AcquireApprovedSupervisionPage fillCurrentPrice(int price);

    @Click(SEND_BUTTON)
    ApprovedSupervisionCreatedPage clickSendButton();
}