diff --git a/client/src/components/FlightList/FlightList.tsx b/client/src/components/FlightList/FlightList.tsx index 819bfe3c900c52a4b17a81fa4ada963f99f692f6..6674565c0442ce73505cb544b2ce0d39658f3eda 100644 --- a/client/src/components/FlightList/FlightList.tsx +++ b/client/src/components/FlightList/FlightList.tsx @@ -18,7 +18,7 @@ function FlightList() { { flights.map((flight) => { return ( - <FlightCard flight={flight} extraInfo={true} /> + <FlightCard key={flight.id} flight={flight} extraInfo={true} /> ); }) } diff --git a/client/src/components/Header/Header.tsx b/client/src/components/Header/Header.tsx index 3fc4d51a4b15ef34897d22b2d69f33240ac5621b..fb28dd8c38ffff5cb631015154f81fed1e5be5ee 100644 --- a/client/src/components/Header/Header.tsx +++ b/client/src/components/Header/Header.tsx @@ -27,7 +27,7 @@ function Header() { <div> <NavLink to={userToDashboard(user)} className={activeClass} >Dashboard</NavLink> {user?.type === 0 && <NavLink to={'booking/query'} className={activeClass}>Book a Flight</NavLink>} - {user?.type === 1 && <NavLink to={'flights'} className={activeClass}>Flight List</NavLink>} + {user?.type === 1 && <NavLink to={`flights?id=${user.id}`} className={activeClass}>Flight List</NavLink>} <NavLink to={'logout'} className={activeClass}>Logout</NavLink> </div> : <div> diff --git a/client/src/services/FlightList/FlightList.ts b/client/src/services/FlightList/FlightList.ts index 38e3a8e08ed319a918b14fb533193071b1f9ee09..3ce1f23572237611b8e37ab2b42dfa05b041b0e5 100644 --- a/client/src/services/FlightList/FlightList.ts +++ b/client/src/services/FlightList/FlightList.ts @@ -1,9 +1,10 @@ -import { Params } from 'react-router-dom'; import Api from '../../helpers/Api'; +import { getSearchParam } from '../../helpers/SearchParams'; -export async function GetFlightList({ params }: { params: Params }) { +export async function GetFlightList({ request }: { request: Request}) { try { - const result = await Api.get(`Flight?airlineId=${params.id}`, { withCredentials: true }); + const id = getSearchParam(request.url, 'id'); + const result = await Api.get(`Flight?airlineId=${id}`, { withCredentials: true }); return result.data; } catch (error) { return null;