import { Injectable } from '@angular/core';
import { IBreadCrumbItem } from '@components/page/breadcrumds/page-breadcrumbs.component';
import { ScheduleTitleService } from './title.service';
import { IScheduleRouteDirectionParams } from './url/types';
import { ScheduleUrlBuilderService } from './url/url-builder.service';

@Injectable()
export class ScheduleBreadCrumbService {
    constructor(
        private urlBuilder: ScheduleUrlBuilderService,
        private titleService: ScheduleTitleService,
    ) {}

    getRootBreadCrumb(): IBreadCrumbItem {
        return {
            url: this.urlBuilder.getStartPageUrl(),
            label: this.titleService.getStartPageTitle(),
        };
    }

    async getSearchPageBreadCrumb(
        outbound: IScheduleRouteDirectionParams,
        inbound?: IScheduleRouteDirectionParams,
    ): Promise<IBreadCrumbItem> {
        const label = await this.titleService.getSearchPageRouteTitle(outbound);

        return {
            label,
            url: this.urlBuilder.getRoutePageUrl(outbound, inbound),
        };
    }
}
