import { BasePageData } from "../../Page/BasePageData";
import { IMainStateFactory } from "../../Types";
import { DateBoxFactory } from "./DateBoxFactory";

export class DateBoxesFactory {
    public forceUpdate = () => { };
    public fromDateBoxFactory: DateBoxFactory;
    public toDateBoxFactory: DateBoxFactory;

    constructor(
        public mainStateFactory: IMainStateFactory,
        public fieldName: string,
        _showHasChangeFlag: boolean,
        required: boolean,
        public caption?: string,
        fromCaption?: string,
        fromPlaceHolder?: string,
        toCaption?: string,
        toPlaceHolder?: string,
        tabIndex?: number,
        public pageData?: BasePageData,
        fromPayLoadKey?: string,
        toPayLoadKey?: string,
        fromResponseKey?: string,
        toResponseKey?: string,
    ) {
        const fromTabIndex = typeof tabIndex === 'number' ? tabIndex : undefined;
        const toTabIndex = typeof tabIndex === 'number' ? tabIndex + .1 : undefined;

        const disposeFrom = () => { }
        const disposeTo = () => { }


        this.fromDateBoxFactory = new DateBoxFactory(mainStateFactory, `dateBoxFrom${fieldName}`, disposeFrom, required, _showHasChangeFlag, fromCaption, fromPlaceHolder, fromTabIndex, undefined, fromPayLoadKey, fromResponseKey);
        this.toDateBoxFactory = new DateBoxFactory(mainStateFactory, `dateBoxTo${fieldName}`, disposeTo, required, _showHasChangeFlag, toCaption, toPlaceHolder, toTabIndex, undefined, toPayLoadKey, toResponseKey);
    }
}

