import { Injectable } from '@angular/core';
import { AppSettingsService } from '@shared/services';
import { isBetween } from '@utils/date';

@Injectable()
export class OnlineBoardDateValidationService {
    constructor(private settings: AppSettingsService) {}

    isDateValid(date: Date) {
        return this.settings
            .getSettings()
            .then(({ boardMinDate, boardMaxDate }) => {
                // COMMON-479
                return date && isBetween(date, new Date(boardMinDate.getDate()-1), boardMaxDate);
            });
    }
}
