import React, { useEffect, useState } from "react"; import { useFetchDeparture } from "../../hooks/useFetchDeparture"; import { Flight } from "../../Types"; import './Page.css' import { Table, Thead, Tbody, Tr, Th, Td } from 'react-super-responsive-table'; import 'react-super-responsive-table/dist/SuperResponsiveTableStyle.css'; interface Props { flights?: Flight[]; } export const Departure: React.FC = (props) => { let origin = process.env.REACT_APP_ORIGIN; const { zones, error } = useFetchDeparture(origin); const [startIndex, setStartIndex] = useState(0); useEffect(() => { const interval = setInterval(() => { if (zones.length <= 10) { return; } setStartIndex((prevIndex) => (prevIndex + 10) >= zones.length ? 0 : (prevIndex + 10)); }, 5000); return () => clearInterval(interval); }, [zones]); return (

Departure

{zones.length > 0 && ( <> {zones.slice(startIndex, startIndex + 10).map((flight) => ( // ); ))} {startIndex + 10 >= zones.length && ( <> {Array.from({ length: startIndex + 10 - zones.length }).map((_, index) => { return ( ) })} ) } )}
Code Time Destination Gate Status
{flight.flight_code} {flight.departure_time} {flight.destination} {flight.gate} {flight.status}
{error ?
{error}
: <>}
); };