import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { OnlineBoardUrlParserService } from '@online-board/services/url';
import { IOnlineBoardUrlParams } from '@online-board/types';

@Injectable()
export class OnlineBoardFlightNumberUrlParamsResolver
    implements Resolve<IOnlineBoardUrlParams>
{
    constructor(private urlService: OnlineBoardUrlParserService) {}

    resolve(route: ActivatedRouteSnapshot): IOnlineBoardUrlParams {
        const { params } = route.params;

        return {
            flightNumber: this.urlService.parseFlightId(params),
        };
    }
}
