diff --git a/client/src/components/Dashboard/FlightCard/FlightCard.tsx b/client/src/components/Dashboard/FlightCard/FlightCard.tsx index 1d19058b029459608146abd8ba41387047833666..dd3a9987bf80db4de611bd2c0a61c827f4f92ecd 100644 --- a/client/src/components/Dashboard/FlightCard/FlightCard.tsx +++ b/client/src/components/Dashboard/FlightCard/FlightCard.tsx @@ -11,16 +11,17 @@ interface IFlightCard { function FlightCard({ flight, extraInfo }: IFlightCard) { return ( <> - <div className='flight-card'> - <span>{flight.id}</span> - {extraInfo && <span>Departure Time: {new Date(flight.departureTime).toLocaleString()}</span>} - {extraInfo && <span>Arrival Time: {new Date(flight.arrivalTime).toLocaleString()}</span>} - <span className='flight-path'>{airportCode(flight.origin)} - {airportCode(flight.destination)}</span> - <span>{flight.origin} - {flight.destination}</span> - <Link to={'/flight/' + flight.id}>View Flight</Link> - </div> + + <div className='flight-card'> + <span>Flight Number: {flight.id}</span> + <span>Departure Time: {new Date(flight.departureTime).toLocaleString()}</span> + <span>Arrival Time: {new Date(flight.arrivalTime).toLocaleString()}</span> + <span className='flight-path'>{flight.origin} - {flight.destination}</span> + <Link to={'/Flight/' + flight.id}>View Flight</Link> + </div> </> ); } export default FlightCard; + diff --git a/client/src/components/Dashboard/Flights/Flights.scss b/client/src/components/Dashboard/Flights/Flights.scss index 9cabf460c2016b19398d619f43069a435bc92294..ad5eea8aaead5fec6e153c86b50f776d41d5207c 100644 --- a/client/src/components/Dashboard/Flights/Flights.scss +++ b/client/src/components/Dashboard/Flights/Flights.scss @@ -22,6 +22,7 @@ border-radius: 5px; background-color: var(--main); color: white; + margin-left: 25px; } .view-more:hover { diff --git a/client/src/components/Dashboard/Flights/Flights.tsx b/client/src/components/Dashboard/Flights/Flights.tsx index 7b6e1f85185d297bbfa631856c70449367245707..aa2f3adc2c49a40695784882dabdafc4f554f985 100644 --- a/client/src/components/Dashboard/Flights/Flights.tsx +++ b/client/src/components/Dashboard/Flights/Flights.tsx @@ -7,7 +7,8 @@ import { Link } from 'react-router-dom'; function Flights() { const data = useLoaderData() as ICustomerDashboardData | IAirlineDashboardData; - + console.log(data) + console.log("bitch pls") if (data.type === 'customer') { return ( <> @@ -20,8 +21,9 @@ function Flights() { </div> <div className='flight-list'> {data.upcomingFlights.length > 0 - ? data.upcomingFlights.slice(0,3).map((flight) => { - return <FlightCard key={flight.id} flight={flight}></FlightCard> + ? data.upcomingFlights.slice(0,3).map((item) => { + // Only pass the flight data to the FlightCard + return <FlightCard key={item.flight.id} flight={item.flight}></FlightCard> }) : <div>No Upcoming Flights</div>} </div> @@ -33,23 +35,25 @@ function Flights() { <button type='button' className='view-more'>View more</button> </div> <div className='flight-list'> - {data.upcomingFlights.length > 0 - ? data.flightsHistory.slice(0,3).map((flight) => { - return <FlightCard key={flight.id} flight={flight}></FlightCard> + {data.flightsHistory.length > 0 + ? data.flightsHistory.slice(0,3).map((item) => { + // Only pass the flight data to the FlightCard + return <FlightCard key={item.flight.id} flight={item.flight}></FlightCard> }) : <div>No Flights History</div>} </div> </div> </> ); - } else { + } + else { return ( <> <div className='flights'> <div className='flex-row'> - <span className='flights-title'>Upcoming Flights</span> + <span className='flights-title'>Flights List</span> <Link to="/register-flight"> - <button type='button' className='add-flight'>Add flight</button> + <button type='button' className='view-more'>Add flight</button> </Link> </div> <div className='flight-list'> diff --git a/client/src/services/Dashboard/AirlineDashboard.ts b/client/src/services/Dashboard/AirlineDashboard.ts index 37c97021968b4ff3854ec733e0848e1e59b4531a..4a358bf93bf08fbb0647aacd717efdcade52461d 100644 --- a/client/src/services/Dashboard/AirlineDashboard.ts +++ b/client/src/services/Dashboard/AirlineDashboard.ts @@ -34,12 +34,13 @@ export interface IAirlineDashboardData { export async function GetAirlineDashboardData({request}: {request: Request}): Promise<IAirlineDashboardData> { try { const id = getSearchParam(request.url, 'id'); - const result = await Api.get(`Flight?airlineId=${id}`, { withCredentials: true }); + const response = await Api.get(`Flight?airlineId=${id}`, { withCredentials: true }); + const flights = response.data.$values; return { type: 'airline', - flightList : result.data + flightList: flights }; } catch (error) { throw error; } -} +} \ No newline at end of file diff --git a/client/src/services/Dashboard/CustomerDashboard.ts b/client/src/services/Dashboard/CustomerDashboard.ts index cff674c48e209c88b2cd520ca5f7b61aa06bb84d..f3bd27c8e7195f72796ed63c9cf61d635b468be2 100644 --- a/client/src/services/Dashboard/CustomerDashboard.ts +++ b/client/src/services/Dashboard/CustomerDashboard.ts @@ -31,10 +31,10 @@ export interface ICustomerDashboardData { flightsHistory: IFlight[]; } -export async function GetCustomerDashboardData({ request } : { request: Request }): Promise<ICustomerDashboardData> { +export async function GetCustomerDashboardData(): Promise<ICustomerDashboardData> { try { - const upcomingFlights = Api.get('', {withCredentials: true}); - const flightsHistory = Api.get('', {withCredentials: true}); + const upcomingFlights = Api.get('Booking/upcoming', { withCredentials: true }); + const flightsHistory = Api.get('Booking/history', { withCredentials: true }); const [uData, hData] = await Promise.all([upcomingFlights, flightsHistory]); return { @@ -46,3 +46,4 @@ export async function GetCustomerDashboardData({ request } : { request: Request throw error; } } +