From 85d941b8df6f167eed1a15ecef72d948f2deafd9 Mon Sep 17 00:00:00 2001 From: Mouaz Abdelsamad <ma03081@surrey.ac.uk> Date: Sat, 20 Apr 2024 02:40:54 +0100 Subject: [PATCH] fix errors --- .../components/Dashboard/FlightCard/FlightCard.tsx | 3 +-- client/src/components/Login/Login.tsx | 2 +- client/src/components/Register/Register.tsx | 2 +- client/src/helpers/UserStorage.ts | 11 +++++++++++ client/src/services/Dashboard/AirlineDashboard.ts | 6 +----- 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 client/src/helpers/UserStorage.ts diff --git a/client/src/components/Dashboard/FlightCard/FlightCard.tsx b/client/src/components/Dashboard/FlightCard/FlightCard.tsx index dd3a998..c7ceb5a 100644 --- a/client/src/components/Dashboard/FlightCard/FlightCard.tsx +++ b/client/src/components/Dashboard/FlightCard/FlightCard.tsx @@ -1,6 +1,5 @@ import { Link } from 'react-router-dom'; import { IFlight } from '../../../services/Dashboard/CustomerDashboard'; -import { airportCode } from '../../../helpers/Airports'; import './FlightCard.scss'; interface IFlightCard { @@ -8,7 +7,7 @@ interface IFlightCard { extraInfo?: boolean; } -function FlightCard({ flight, extraInfo }: IFlightCard) { +function FlightCard({ flight }: IFlightCard) { return ( <> diff --git a/client/src/components/Login/Login.tsx b/client/src/components/Login/Login.tsx index edb5577..c3baf71 100644 --- a/client/src/components/Login/Login.tsx +++ b/client/src/components/Login/Login.tsx @@ -26,7 +26,7 @@ export function Login() { const result = await loginUser(formValue); if (result) { giveAuth(); - const userId = result.data.id; + const userId = result.data.id.toString(); UserStorage.storeUserId(userId) updateUser(result.data); navigate(`/${userToDashboard(result.data)}`); diff --git a/client/src/components/Register/Register.tsx b/client/src/components/Register/Register.tsx index e44fae1..c188dad 100644 --- a/client/src/components/Register/Register.tsx +++ b/client/src/components/Register/Register.tsx @@ -40,7 +40,7 @@ export function Register() { try { const result = await registerUser(formValue); giveAuth(); - const userId = result.data.id; + const userId = result.data.id.toString(); UserStorage.storeUserId(userId); updateUser(result.data); navigate(`/${userToDashboard(result.data)}`); diff --git a/client/src/helpers/UserStorage.ts b/client/src/helpers/UserStorage.ts new file mode 100644 index 0000000..638c332 --- /dev/null +++ b/client/src/helpers/UserStorage.ts @@ -0,0 +1,11 @@ +class UserStorage { + static storeUserId(id: string): void { + localStorage.setItem('userId', id); + } + + static getUserId(): string | null { + return localStorage.getItem('userId'); + } + } + + export default UserStorage; \ No newline at end of file diff --git a/client/src/services/Dashboard/AirlineDashboard.ts b/client/src/services/Dashboard/AirlineDashboard.ts index b088499..d697d38 100644 --- a/client/src/services/Dashboard/AirlineDashboard.ts +++ b/client/src/services/Dashboard/AirlineDashboard.ts @@ -31,11 +31,7 @@ export interface IAirlineDashboardData { flightList: IFlight[]; } -export async function GetAirlineDashboardData({ - request, -}: { - request: Request; -}): Promise<IAirlineDashboardData> { +export async function GetAirlineDashboardData(): Promise<IAirlineDashboardData> { try { const id = UserStorage.getUserId(); const response = await Api.get(`Flight?airlineId=${id}`, { -- GitLab