From 29400e1626b6682dee1b290362e6e9fb44d1ad13 Mon Sep 17 00:00:00 2001 From: "Abdelsamad, Mouaz R (UG - Comp Sci & Elec Eng)" <ma03081@surrey.ac.uk> Date: Sat, 20 Apr 2024 15:07:29 +0000 Subject: [PATCH] Fix customer dash --- .../components/Dashboard/FlightCard/FlightCard.tsx | 3 +-- client/src/components/Dashboard/Flights/Flights.tsx | 6 ++---- client/src/services/Dashboard/CustomerDashboard.ts | 11 ++++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/src/components/Dashboard/FlightCard/FlightCard.tsx b/client/src/components/Dashboard/FlightCard/FlightCard.tsx index c7ceb5a..af0a2f9 100644 --- a/client/src/components/Dashboard/FlightCard/FlightCard.tsx +++ b/client/src/components/Dashboard/FlightCard/FlightCard.tsx @@ -10,13 +10,12 @@ interface IFlightCard { function FlightCard({ flight }: IFlightCard) { return ( <> - <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> + <Link to={'/Flight/' + flight.id}>View Flight Info</Link> </div> </> ); diff --git a/client/src/components/Dashboard/Flights/Flights.tsx b/client/src/components/Dashboard/Flights/Flights.tsx index 0fcf82d..0f043d8 100644 --- a/client/src/components/Dashboard/Flights/Flights.tsx +++ b/client/src/components/Dashboard/Flights/Flights.tsx @@ -31,8 +31,7 @@ function Flights() { <div className="flight-list"> {data.upcomingFlights.length > 0 ? ( data.upcomingFlights.slice(0, 3).map((item) => { - // Only pass the flight data to the FlightCard - return <FlightCard key={item.id} flight={item}></FlightCard>; + return <FlightCard key={item.flight.id} flight={item.flight}></FlightCard>; }) ) : ( <div>No Upcoming Flights</div> @@ -54,8 +53,7 @@ function Flights() { <div className="flight-list"> {data.flightsHistory.length > 0 ? ( data.flightsHistory.slice(0, 3).map((item) => { - // Only pass the flight data to the FlightCard - return <FlightCard key={item.id} flight={item}></FlightCard>; + return <FlightCard key={item.flight.id} flight={item.flight}></FlightCard>; }) ) : ( <div>No Flights History</div> diff --git a/client/src/services/Dashboard/CustomerDashboard.ts b/client/src/services/Dashboard/CustomerDashboard.ts index f3bd27c..040429f 100644 --- a/client/src/services/Dashboard/CustomerDashboard.ts +++ b/client/src/services/Dashboard/CustomerDashboard.ts @@ -1,4 +1,5 @@ import Api from "../../helpers/Api"; +import { IBookingInfo } from "../BookingView/BookingView"; export interface ISeat { id: number; @@ -25,10 +26,15 @@ export interface IFlight { seats: ISeats } +export interface IFLightBookingData{ + flight: IFlight; + booking: IBookingInfo; +} + export interface ICustomerDashboardData { type: 'customer' - upcomingFlights: IFlight[]; - flightsHistory: IFlight[]; + upcomingFlights: IFLightBookingData[]; + flightsHistory: IFLightBookingData[]; } export async function GetCustomerDashboardData(): Promise<ICustomerDashboardData> { @@ -36,7 +42,6 @@ export async function GetCustomerDashboardData(): Promise<ICustomerDashboardData 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 { type: 'customer', upcomingFlights: uData.data, -- GitLab