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

import cz.moneta.test.dsl.hypos.components.Menu;
import cz.moneta.test.dsl.hypos.pages.HyposPageFlow;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.hypos.pages.contract.withdrawal.WithdrawalRequestsPage.PAGE_TITLE;

@Wait(PAGE_TITLE)
public interface WithdrawalRequestsPage extends HyposPageFlow<WithdrawalRequestsPage>, Menu {
    String PAGE_TITLE = "//h1[text()='Žádosti o čerpání']";
    String NEW_REQUEST_TABLE = "//table[@id='novazadost']";
    String DRAW_REQUEST_DATE_INPUT = NEW_REQUEST_TABLE + "//input[@id='draw-request-date']";
    String ADD_DECISION_DATE_LINK = NEW_REQUEST_TABLE + "//a[@id='add-decision-date']";
    String INVOICES_TABLE = "//table[@id='faktury']";
    String SET_CLIENT_ACCOUNT_INPUT = INVOICES_TABLE + "//input[contains(@class,'bu')]";
    String SET_CLIENT_NAME_SELECT = INVOICES_TABLE + "//select[@name='faktura_na_jmeno_select[]']";
    String WITHDRAWAL_AMOUNT_INPUT = INVOICES_TABLE + "//input[@name='faktura_castka[]']";
    String SAVE_BUTTON = "//form[@id='formZadost']//input[@value='Uložit']";

    @TypeInto(DRAW_REQUEST_DATE_INPUT)
    WithdrawalRequestsPage fillDrawDate(String date);

    @Click(value = ADD_DECISION_DATE_LINK, andWait = @Wait(value = LOADER, until = Until.GONE))
    WithdrawalRequestsPage clickAddDecisionDate();

    @Click(SET_CLIENT_ACCOUNT_INPUT)
    WithdrawalRequestsPage clickClientAccountCheckbox();

    @Select(SET_CLIENT_NAME_SELECT)
    WithdrawalRequestsPage selectCurrentAccountOwner(String clientName);

    @TypeInto(WITHDRAWAL_AMOUNT_INPUT)
    WithdrawalRequestsPage fillLoanAmount(int loanAmount);

    @Click(SAVE_BUTTON)
    WithdrawalRequestsPage clickSaveButton();
}
