Skip to content
Snippets Groups Projects
AirlineDashboard.ts 1006 B
Newer Older
import Api from "../../helpers/Api";
import UserStorage from "../../helpers/UserStorage";
Arzan Pour, Arshia (UG - SISC)'s avatar
Arzan Pour, Arshia (UG - SISC) committed
export interface ISeat {
  id: number;
  classType: number;
  seatNumber: string;
  isAvailable: boolean;
}

export interface ISeats {
  $id: string;
  $values: ISeat[];
}

export interface IFlight {
  id: number;
  origin: string;
  destination: string;
  arrivalTime: string;
  departureTime: string;
  economyCapacity: number;
  businessCapacity: number;
  economyPrice: number;
  businessPrice: number;
  seats: ISeats
}

export interface IAirlineDashboardData {
  type: 'airline'
export async function GetAirlineDashboardData({request}: {request: Request}): Promise<IAirlineDashboardData> {
  try {
    const id = UserStorage.getUserId();
    const response = await Api.get(`Flight?airlineId=${id}`, { withCredentials: true });
    const flights = response.data.$values;
    return {
      type: 'airline',
      flightList: flights