package cz.moneta.test.dsl.util.task.brokerportal;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.brokerportal.contractdetail.ContractDetailPage;
import cz.moneta.test.dsl.util.DateUtils;

import java.util.function.Function;

public class ContractDetailTasks {

    private final Harness harness;

    public ContractDetailTasks(Harness harness) {
        this.harness = harness;
    }

    public Function<ContractDetailPage, ContractDetailPage> fillAndSaveContactDetails() {
        return start -> start.opensContactDetailsModal()
                .fillEmail("karel.hruza1@moneta.cz")
                .fillPhoneNumber(harness.tasks().brokerPortal().commonTasks().getMobilePhoneNumber())
                .saveContactDetails();
    }

    public Function<ContractDetailPage, ContractDetailPage> uploadChecklistDoc(String doc) {
        return start -> start.clickChecklist()
                .clickChecklistDoc(doc)
                .checklistUploadFile(harness.tasks().common().getFakePdfPath())
                .clickChecklistDocUpload()
                .fillDocumentDate(DateUtils.getTodayDateIncrementedByDays(360, "dd.MM.yyyy"))
                .clickSaveButton()
                .waitChecklistUpload()
                .waitChecklist()
                .checkChecklistDocUploaded();
    }
}