import { Pipe, PipeTransform } from '@angular/core';
import { TranslatePipe } from '@ngx-translate/core';
import { DurationPipe } from './duration.pipe';
import { Leg } from '../models-legacy';

@Pipe({
    name: 'legDuration',
})
export class LegDurationPipe implements PipeTransform {
    constructor(private translate: TranslatePipe, private duration: DurationPipe) {}
    transform(leg: Leg, canChange: boolean): string {
        if (!leg) return '';

        return canChange
            ? this.duration.transform(leg.estimatedDuration || leg.scheduledDuration)
            : this.duration.transform(leg.scheduledDuration);
    }
}
