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

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