import { Injectable } from '@angular/core';
import { IUrlTimeRange } from '@typings/common/url';

export type IOnlineBoardFilterSelectedTab = 'route' | 'flight';

@Injectable({
    providedIn: 'root',
})
export class OnlineBoardFiltersStateService {
    selectedTab?: IOnlineBoardFilterSelectedTab = 'route';

    flightNumber: string;
    suffix: string;
    flightNumberDate: Date;

    timeRange: IUrlTimeRange;
    routeDate: Date;
    departure: string;
    arrival: string;

    clearSelectedTab() {
        this.selectedTab = undefined;
    }

    clearFlightNumber() {
        this.flightNumber = undefined;
        this.suffix = undefined;
        this.flightNumberDate = undefined;
    }

    clearRoute() {
        this.timeRange = undefined;
        this.routeDate = undefined;
        this.departure = undefined;
        this.arrival = undefined;
    }

    clear() {
        this.selectedTab = 'route';
        this.clearFlightNumber();
        this.clearRoute();
    }
}
