package cz.moneta.test.dsl.ufo.banka.pages.po;

import cz.moneta.test.dsl.ufo.banka.pages.loans.CAS001_S001_ScoringPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.banka.pages.po.CIF043_S001_ActualOwnerPage.*;
import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;

@Wait(value = CIF043_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 60)
@Wait(SAVE_BUTTON)
public interface CIF043_S001_ActualOwnerPage extends WebFlow<CIF043_S001_ActualOwnerPage>, StoreAccessor {
    String CIF043_S001_PAGE_LABEL_XPATH = "//div[text()='CIF043_S001']";

    String CONTINUE_BUTTON = "CIF043_S001_B002";
    String ADD_NEW_ACTUAL_OWNER_BUTTON = "CIF043_S001_B003";
    String SAVE_BUTTON = "CIF043_S001_B005";

    String FIRST_NAME_INPUT = "CIF043_S001_E003";
    String LAST_NAME_INPUT = "CIF043_S001_E002";
    String BIRTH_NUMBER_INPUT = "CIF043_S001_E004";
    String CONCURRENT_SHARE_INPUT = "CIF043_S001_E005";
    String STREET_INPUT = "CIF043_S001_E009";
    String DESCRIPTIVE_NUMBER_INPUT = "CIF043_S001_E010";
    String CITY_INPUT = "CIF043_S001_E012";
    String ZIP_CODE_INPUT = "CIF043_S001_E013";

    String CZECH_RESIDENCY_FLAG_BUTTON = "CIF043_S001_P001";
    String CZECH_PERMANENT_RESIDENCY_FLAG_BUTTON = "CIF043_S001_P002";

    @Click(ADD_NEW_ACTUAL_OWNER_BUTTON)
    CIF043_S001_ActualOwnerPage clickToAddNewActualOwner();

    @TypeInto(FIRST_NAME_INPUT)
    CIF043_S001_ActualOwnerPage fillFirstName(String firstName);

    @TypeInto(LAST_NAME_INPUT)
    CIF043_S001_ActualOwnerPage fillLastName(String lastName);

    @TypeInto(BIRTH_NUMBER_INPUT)
    CIF043_S001_ActualOwnerPage fillBirthNumber(String birthNumber);

    @Click(CZECH_RESIDENCY_FLAG_BUTTON)
    CIF043_S001_ActualOwnerPage selectCzechResidency();

    @Click(CZECH_PERMANENT_RESIDENCY_FLAG_BUTTON)
    CIF043_S001_ActualOwnerPage selectCzechPermanentResidency();

    @TypeInto(CONCURRENT_SHARE_INPUT)
    CIF043_S001_ActualOwnerPage fillConcurrentShare(String concurrentShare);

    @TypeInto(STREET_INPUT)
    CIF043_S001_ActualOwnerPage fillStreet(String street);

    @TypeInto(DESCRIPTIVE_NUMBER_INPUT)
    CIF043_S001_ActualOwnerPage fillDescriptiveNumber(String descriptiveNumber);

    @TypeInto(CITY_INPUT)
    CIF043_S001_ActualOwnerPage fillCity(String city);

    @TypeInto(ZIP_CODE_INPUT)
    CIF043_S001_ActualOwnerPage fillZipCode(String zipCode);

    @Click(value = SAVE_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    CIF043_S001_ActualOwnerPage saveNewActualOwner();

    @Click(value = CONTINUE_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    CIF043_S001_ActualOwnerPage continueToRealOwners();

    @CustomAction
    default CIF043_S001_ActualOwnerPage scrollIntoContinueButton() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.scrollIntoView(CONTINUE_BUTTON);
        return null;
    }

    @Click(CONTINUE_BUTTON)
    CAS001_S001_ScoringPage continueToScoringPage();
}
