diff --git a/client/src/components/Login/Login.tsx b/client/src/components/Login/Login.tsx index d9190f95cd2070fcaffa0d123dcc2a3569121c31..edb557747a2fba32d18c7096a950116fd824f281 100644 --- a/client/src/components/Login/Login.tsx +++ b/client/src/components/Login/Login.tsx @@ -5,6 +5,7 @@ import { AxiosError } from 'axios'; import { useAuth } from '../../hooks/useAuth'; import { loginUser } from '../../services/Login/Login'; import { userToDashboard } from '../../helpers/UserType'; +import UserStorage from "../../helpers/UserStorage"; import './Login.scss'; export interface ILoginForm { @@ -25,6 +26,8 @@ export function Login() { const result = await loginUser(formValue); if (result) { giveAuth(); + const userId = result.data.id; + UserStorage.storeUserId(userId) updateUser(result.data); navigate(`/${userToDashboard(result.data)}`); } else { diff --git a/client/src/components/Register/Register.tsx b/client/src/components/Register/Register.tsx index dd9bd0a46e3a887b3e08ca9af01a5a9837ceea52..5b85c96545c6439751bc1e763b86e8b09052a177 100644 --- a/client/src/components/Register/Register.tsx +++ b/client/src/components/Register/Register.tsx @@ -6,6 +6,7 @@ import { registerUser } from '../../services/Register/Register'; import { useAuth } from '../../hooks/useAuth'; import './Register.scss'; import { userToDashboard } from '../../helpers/UserType'; +import UserStorage from "../../helpers/UserStorage"; export interface IRegisterForm { name: string; @@ -37,6 +38,8 @@ export function Register() { try { const result = await registerUser(formValue); giveAuth(); + const userId = result.data.id; + UserStorage.storeUserId(userId) updateUser(result.data); navigate(`/${userToDashboard(result.data)}`); } catch (error) { diff --git a/client/src/services/Dashboard/AirlineDashboard.ts b/client/src/services/Dashboard/AirlineDashboard.ts index 4a358bf93bf08fbb0647aacd717efdcade52461d..b0e1dda10fcbd384fa1f04b9c69cee1bcdb3abdf 100644 --- a/client/src/services/Dashboard/AirlineDashboard.ts +++ b/client/src/services/Dashboard/AirlineDashboard.ts @@ -1,5 +1,5 @@ import Api from "../../helpers/Api"; -import { getSearchParam } from "../../helpers/SearchParams"; +import UserStorage from "../../helpers/UserStorage"; export interface ISeat { id: number; @@ -33,7 +33,7 @@ export interface IAirlineDashboardData { export async function GetAirlineDashboardData({request}: {request: Request}): Promise<IAirlineDashboardData> { try { - const id = getSearchParam(request.url, 'id'); + const id = UserStorage.getUserId(); const response = await Api.get(`Flight?airlineId=${id}`, { withCredentials: true }); const flights = response.data.$values; return {