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

import cz.moneta.test.dsl.hypos.components.Menu;
import cz.moneta.test.dsl.hypos.pages.HyposPageFlow;
import cz.moneta.test.harness.support.web.AcceptAlert;
import cz.moneta.test.harness.support.web.Click;
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.loan.LoanPage.PAGE_TITLE;

@Wait({PAGE_TITLE})
public interface LoanPage extends HyposPageFlow<LoanPage>, Menu {
    String PAGE_TITLE = "//h1[text()='Úvěr']";
    String NEW_TRANSACTION_LINK = "//a[text()='Nová tranše...']";
    String EDIT_DRAWING_CONDITIONS_LINK = "//a[text()='Editace...']";
    String SET_CURRENT_ACCOUNT_LINK = "//a[text()='Vybrat BÚ...']";
    String CONDITIONS_APPROVAL_LINK = "//following::strong/a[text()='Odsouhlasení podmínek...']";
    String DRAWING_CONDITIONS_APPROVAL_LINK = "//td/strong[text()='Podmínky čerpání']" + CONDITIONS_APPROVAL_LINK;
    String MORGTAGE_CONDITIONS_APPROVAL_LINK = "//td/strong[text()='Podmínky pro generování zástavní smlouvy']" + CONDITIONS_APPROVAL_LINK;
    String NEW_DRAW_LINK = "//a[contains(text(),'Nové čerpání...')]";
    String APPROVE_NEW_DRAW_LINK = "//a[contains(text(),'Schválit')]";
    String DO_DRAW_IN_ICBS_LINK = "//span[@id='doDraw']/a[contains(text(),'VYČERPAT V ICBS')]";

    @Click(NEW_TRANSACTION_LINK)
    NewTransactionPage clickAddNewTransaction();

    @Click(EDIT_DRAWING_CONDITIONS_LINK)
    DrawingConditionsPage clickSetDrawingConditions();

    @Click(SET_CURRENT_ACCOUNT_LINK)
    ClientCurrentAcountPage clickSetCurrentAccount();

    @Click(DRAWING_CONDITIONS_APPROVAL_LINK)
    DrawingConditionsApprovalPage clickApproveDrawingConditions();

    @Click(MORGTAGE_CONDITIONS_APPROVAL_LINK)
    DrawingConditionsApprovalPage clickApproveMortgageConditions();

    @Click(NEW_DRAW_LINK)
    NewDrawPage clickNewDraw();

    @Click(APPROVE_NEW_DRAW_LINK)
    @AcceptAlert(waitSecondsForAlert = 10)
    LoanPage clickApproveNewDraw();

    @Click(DO_DRAW_IN_ICBS_LINK)
    @AcceptAlert(waitSecondsForAlert = 30)
    LoanPage clickDoDrawInIcbs();

    @Wait(value = LOADER, waitSecondsForElement = 60, until = Until.GONE)
    LoanPage waitDrawInIcbs();
}