Newer
Older
import { useLoaderData } from 'react-router';
import { ICustomerDashboardData } from '../../../services/Dashboard/CustomerDashboard';
import { IAirlineDashboardData } from '../../../services/Dashboard/AirlineDashboard';
import FlightCard from '../FlightCard/FlightCard';
import FlightCreationForm from '../../FlightCreationForm/FlightCreationForm';
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import './Flights.scss';
function Flights() {
const data = useLoaderData() as ICustomerDashboardData | IAirlineDashboardData;
if (data.type === 'customer') {
return (
<>
<div className='flights'>
<div className='flex-row'>
<span className='flights-title'>Upcoming Flights</span>
<button type='submit' className='view-more'>View more</button>
</div>
<div className='flight-list'>
{data.upcomingFlights.length > 0
? data.upcomingFlights.map((flight) => {
return <FlightCard key={flight.id} flight={flight}></FlightCard>
})
: <div>No Upcoming Flights</div>}
</div>
</div>
<div className='flights'>
<div className='flex-row'>
<span className='flights-title'>Flights History</span>
<button type='submit' className='view-more'>View more</button>
</div>
<div className='flight-list'>
{data.upcomingFlights.length > 0
? data.flightsHistory.map((flight) => {
return <FlightCard key={flight.id} flight={flight}></FlightCard>
})
: <div>No Flights History</div>}
</div>
</div>
</>
);
} else {
return (
<>
<div>
<FlightCreationForm></FlightCreationForm>
</div>
</>
);
}
}
export default Flights;