import { RouteType } from '@typings/enums';
import { IWithLeg } from '@utils/flight/legs/types';

export function getFlightFirstLeg(flight: IWithLeg) {
    switch (flight.routeType) {
        case RouteType.CONNECTING: {
            return getFlightFirstLeg(flight.flights[0]);
        }
        case RouteType.DIRECT: {
            return flight.leg;
        }
        case RouteType.MULTI_LEG: {
            return flight.legs[0];
        }
    }
}
