package cz.moneta.test.dsl.hypos.tasks;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.hypos.pages.structure.*;
import java.util.function.Function;

import static cz.moneta.test.dsl.hypos.enums.HyposLogType.TASK;

public class HyposStructureTasks {
    private final Harness harness;
    private HyposCommonTasks tasks;

    public HyposStructureTasks(Harness harness) {
        this.harness = harness;
        this.tasks = harness.tasks().hypos().hyposCommonTasks();
    }

    public Function<StructurePage, StructurePage> checkStructureDrawPostponed() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickDrawPostponed()
                .clickResetFilterButton()
                .clickSearchButton()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructureDraw() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickDraw()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructureUw2() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickUw2()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructureDocsVerification() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickDocsVerification()
                .checkContracts()
                .clickEndOfWork()
                .clickStructure();
    }

    public Function<StructurePage, StructurePage> checkStructureAppraisementFee() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickAppraisementFee()
                .clickSearchButton()
                .checkContracts()
                .clickEndOfWork()
                .clickStructure();
    }

    public Function<StructurePage, StructurePage> checkStructureLetter() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickLetter()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructurePpd() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickPpd()
                .clickActiveSanctions()
                .checkContracts()
                .clickEndOfWork()
                .clickStructure();
    }

    public Function<StructurePage, StructurePage> checkStructureUw1() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickUw1()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructureOpus() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickOpus()
                .clickSpin()
                .clickSpinAllowed()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructurePktu() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickPktu()
                .fillFilterDateFrom("01.01.2010")
                .clickSearchButton()
                .checkTransactions()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructureClientChange() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickClientChange()
                .clickAppendix()
                .clickAppendixAllowed()
                .selectFilterCreatedBy("-- všichni --")
                .clickSearchButton()
                .checkContracts()
                .clickBackButton();
    }

    public Function<StructurePage, StructurePage> checkStructureFinancialException() {
        tasks.hyposLog(TASK, new Object(){}.getClass().getEnclosingMethod().getName());
        return start -> start.clickFinancialException()
                .checkContracts()
                .clickEndOfWork()
                .clickStructure();
    }
}