import { FlightStatus, RouteType } from '@typings/enums';
import { IFlightId } from '@typings/flight/flight-id';
import { IOperatingBy } from '@typings/operating-by';
import { IFlightLeg } from './flight-leg';

export type IFlightBase = {
    flightId: IFlightId;
    flyingTime: string;
    operatingBy: IOperatingBy;
    id: string;
    status: FlightStatus;
};

export type IDirectFlight = IFlightBase & {
    routeType: RouteType.DIRECT;
    leg: IFlightLeg;
};

export type IMultiLegFlight = IFlightBase & {
    routeType: RouteType.MULTI_LEG;
    legs: IFlightLeg[];
};

export type IConnectingFlight = {
    flights: (IDirectFlight | IMultiLegFlight)[];
    routeType: RouteType.CONNECTING;
    flyingTime: string;
    status: FlightStatus;
};

export type ISimpleFlight = IDirectFlight | IMultiLegFlight;
export type IFlight = ISimpleFlight | IConnectingFlight;
