package cz.moneta.test.dsl.ufo.cb.landing;

import cz.moneta.test.dsl.ufo.cb.landing.proposal.pages.*;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;

@Wait(value = KOM401_S001_ProposalParameters.AMOUNT_FIELD, until = Until.VISIBLE)
public interface KOM401_S001_ProposalParameters extends WebFlow<KOM401_S001_ProposalParameters>, StoreAccessor {
    String SIGNPOST = "KOM401_S001_S002";
    String AMOUNT_FIELD = "KOM401_S001_E005";
    String CHARACTER_TYPE = "KOM401_S001_C005";
    String PROPOSAL_TYPE = "KOM401_S001_C001";
    String LOAN_TYPE = "KOM401_S001_C003";
    String PRODUCT_TYPE = "KOM401_S001_C011";
    String LOAN_PURPOSE = "KOM401_S001_C007";
    String SIGN_DATE = "KOM401_S001_E004";
    String LAST_DRAWING_DATE = "KOM401_S001_E008";
    String SUPPORT = "KOM401_S001_C006";
    String INSURANCE = "KOM401_S001_C009";
    String RWA_FLAG = "KOM401_S001_C017";
    String COMMITTED = "KOM401_S001_C010";
    String MATURITY = "KOM401_S001_C012";

    String SAVE_BUTTON = "KOM401_S001_B001";

    String SELECT_OPTION = "//select/option[text()='%s']";
    String SELECT_OPTION_PRODUCT_TYPE = "//select[@id='" + PRODUCT_TYPE + "']/option[text()='%s']";
    String RELATIONS = "//td[contains(text(),'Vazby')]";
    String CLIENT = "//td[contains(text(),'Klient žadatel')]";
    String FV = "//td[contains(text(),'FV a přiřazení souborů výkazů')]";
    String RATING = "//td[contains(text(),'Rating a LGD')]";
    String KO = "//td[contains(text(),'KO kritéria')]";
    String CRU = "//td[contains(text(),'CRÚ')]";
    String MODELATION = "//td[contains(text(),'Zajištění - navrhované/schválené')]";
    String PLEDGE_BONDS = "//td[contains(text(),'Navrhovaní avalisté a zástavové vazby')]";
    String BLACK_LISTS = "//td[contains(text(),'Black listy a souhlasy GDPR')]";
    String PRICING = "//td[contains(text(),'Pricing a splátkový kalendář')]";
    String NRKI_BRKI = "//td[contains(text(),'NRKI/BRKI')]";
    String DESCRIPTION = "//td[contains(text(),'Popis transakce')]";
    String BASIC_INFORMATION = "//td[contains(text(),'Základní info o firmě/Zemědělec')]";
    String RESOURCES_MONETA = "//td[contains(text(),'Zdroje MONETA')]";
    String RESOURCES = "//td[contains(text(),'Cizí zdroje')]";
    String SALES_EMPLOYEE = "//td[contains(text(),'Struktura tržeb a zaměstnanci')]";
    String RISK = "//td[contains(text(),'Rizika')]";
    String CLIENT_ACCOUNTS = "//td[contains(text(),'Účty klienta')]";
    String COVENANTS = "//td[contains(text(),'Kovenanty')]";
    String CONDITIONS_FULFILMENT = "//td[contains(text(),'Plnění podmínek')]";
    String DEAL_CONDITIONS = "//td[contains(text(),'Podmínky obchodu')]";
    String CHECKLISTS = "//td[contains(text(),'Checklist Sales/Risk')]";
    String SEND_PROPOSAL = "//td[contains(text(),'Odeslání návrhu')]";
    String NAVIGATION_PANEL = "KOM401_S001_J001";

    @Click(SAVE_BUTTON)
    KOM481_S001_ProposalList clickSave();

    @Click(SAVE_BUTTON)
    KOM402_S001_ProposalSignpost clickSaveSignPost();

    @Click(value = SIGNPOST, andWait = @Wait(value = NAVIGATION_PANEL, until = Until.VISIBLE))
    KOM401_S001_ProposalParameters clickSignPost();

    @Click(value = RELATIONS, by = Lookup.XPATH)
    VST403_S001_Relations clickRelations();

    @Click(value = CLIENT, by = Lookup.XPATH)
    ZKL421_S001_ClientCard clickClient();

    @Click(value = FV, by = Lookup.XPATH)
    JAN451_S001_FinancialSheetsSignPost clickFv();

    @Click(value = RATING, by = Lookup.XPATH)
    KOM461_S001_Rating clickRating();

    @Click(value = CRU, by = Lookup.XPATH)
    DEL401_S001_Cru clickCru();

    @Click(value = MODELATION, by = Lookup.XPATH)
    MOD402_S001_Modelation clickModelation();

    @Click(value = PLEDGE_BONDS, by = Lookup.XPATH)
    VST407_S001_PledgeBonds clickPledgeBonds();

    @Click(value = BLACK_LISTS, by = Lookup.XPATH)
    SOU401_S001_BlackLists clickBlackLists();

    @Click(value = PRICING, by = Lookup.XPATH)
    PRC401_S002_Pricing clickPricing();

    @Click(value = NRKI_BRKI, by = Lookup.XPATH)
    ECB401_S001_Registers clickNrkiBrki();

    @Click(value = DESCRIPTION, by = Lookup.XPATH)
    KOM424_S001_TransactionDescriptionPage clickDescription();

    @Click(value = BASIC_INFORMATION, by = Lookup.XPATH)
    KOM425_S001_BasicCompanyInformation clickBasicInformation();

    @Click(value = RESOURCES_MONETA, by = Lookup.XPATH)
    KOM446_S001_ResourcesMoneta clickResourcesMoneta();

    @Click(value = RESOURCES, by = Lookup.XPATH)
    KOM444_S002_ForeignResources clickResources();

    @Click(value = SALES_EMPLOYEE, by = Lookup.XPATH)
    KOM443_S004_SalesEmployee clickSalesEmployee();

    @Click(value = RISK, by = Lookup.XPATH)
    KOM414_S017_Risk clickRisk();

    @Click(value = CLIENT_ACCOUNTS, by = Lookup.XPATH)
    KOM462_S001_ClientAccounts clickClientAccounts();

    @Click(value = COVENANTS, by = Lookup.XPATH)
    KOV401_S001_Kovenanty clickCovenants();

    @Click(value = CONDITIONS_FULFILMENT, by = Lookup.XPATH)
    POD405_S001_ConditionsFulfilment clickConditionsFulfilment();

    @Click(value = DEAL_CONDITIONS, by = Lookup.XPATH)
    POD406_S001_DealConditions clickDealConditions();

    @Click(value = CHECKLISTS, by = Lookup.XPATH)
    KOM490_S001_Checklists clickChecklists();

    @Click(value = SEND_PROPOSAL, by = Lookup.XPATH)
    KOM419_S001_SendProposal clickSendProposal();

    @TypeInto(value = AMOUNT_FIELD, clear = true)
    KOM401_S001_ProposalParameters typeAmount(String amount);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(CHARACTER_TYPE)
    KOM401_S001_ProposalParameters selectCharacterType(String type);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(PROPOSAL_TYPE)
    KOM401_S001_ProposalParameters selectProposalType(String type);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(LOAN_TYPE)
    KOM401_S001_ProposalParameters selectLoanType(String type);

    @Wait(value = SELECT_OPTION_PRODUCT_TYPE, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(PRODUCT_TYPE)
    KOM401_S001_ProposalParameters selectProductType(String type);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(LOAN_PURPOSE)
    KOM401_S001_ProposalParameters selectLoanPurpose(String type);

    @TypeInto(SIGN_DATE)
    KOM401_S001_ProposalParameters typeSignDate(String date);

    @TypeInto(LAST_DRAWING_DATE)
    KOM401_S001_ProposalParameters typeLastDrawingDate(String date);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(SUPPORT)
    KOM401_S001_ProposalParameters selectSupport(String type);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(INSURANCE)
    KOM401_S001_ProposalParameters selectInsurance(String type);

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(RWA_FLAG)
    KOM401_S001_ProposalParameters selectRwaFlag(String type);

    @CustomAction
    default KOM401_S001_ProposalParameters selectCommitted(String type) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, Lookup.XPATH, Until.VISIBLE, String.format(SELECT_OPTION, type));
        endpoint.scrollIntoView(COMMITTED);
        endpoint.selectByVisibleText(COMMITTED, type);
        return null;
    }

    @Wait(value = SELECT_OPTION, by = Lookup.XPATH, isStringDynamicXpath = true)
    @Select(MATURITY)
    KOM401_S001_ProposalParameters selectMaturity(String type);
}
