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

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