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 OnlineBoardDepartureUrlParamsResolver
    implements Resolve<IOnlineBoardUrlParams>
{
    constructor(private urlService: OnlineBoardUrlParserService) {}

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

        return {
            route: this.urlService.parseDepartureSearchUrlParams(params),
        };
    }
}
