diff --git a/packages/app/src/components/FlightsTable/index.tsx b/packages/app/src/components/FlightsTable/index.tsx index 32488167..074fe0fc 100644 --- a/packages/app/src/components/FlightsTable/index.tsx +++ b/packages/app/src/components/FlightsTable/index.tsx @@ -1,15 +1,23 @@ -"use client" +"use client"; -import Flight from '@mach/common' -import { FC, useState } from 'react' -import { Airport } from '../../services/fetch-airports' -import { formatAirport } from '../../utils/format-airport' -import Button from '../Button' -import FlightModal from '../FlightModal' -import styles from './index.module.css' +import Flight from "@mach/common"; +import { FC, useState } from "react"; +import { Airport } from "../../services/fetch-airports"; +import { formatAirport } from "../../utils/format-airport"; +import Button from "../Button"; +import FlightModal from "../FlightModal"; +import styles from "./index.module.css"; type Props = { - items: Array + items: Array; +}; + +function minutesToEet(totalMinutes: number) { + const hours = Math.floor(totalMinutes / 60); + const minutes = totalMinutes % 60; + return `${hours.toString().padStart(2, "0")}${minutes + .toString() + .padStart(2, "0")}`; } const FlightsTable: FC = ({ items }) => { @@ -18,36 +26,53 @@ const FlightsTable: FC = ({ items }) => { return (
- - - - - - - - - +
CallsignDepartureArrivalEOBTAircraftDetails
+ + + + + + + + + + + + + {items.map((flight, key) => ( + + + + + + + + - - - {items.map((flight, key) => ( - - - - - - - - - ))} - + ))} +
CallsignDepartureArrivalEOBTEETAircraftDetails
{flight.callsign} + + {flight.departureIcao} + + + + {flight.arrivalIcao} + + {flight.estimatedOffBlockTime}{minutesToEet(flight.estimatedEnrouteMinutes)}{flight.aircraft.icaoCode} + +
{flight.callsign}{flight.departureIcao}{flight.arrivalIcao}{flight.estimatedOffBlockTime}{flight.aircraft.icaoCode} - -
= ({ items }) => { onClose={() => setFlight(undefined)} />
- ) -} + ); +}; -export default FlightsTable +export default FlightsTable;