diff --git a/client/src/components/CustomerDashboard/CustomerDashboard.tsx b/client/src/components/CustomerDashboard/CustomerDashboard.tsx index c6a58d2ba59969521c599ff844725d869a5c753c..394312ddd9113d9e2da3e90a621b2da18be7c977 100644 --- a/client/src/components/CustomerDashboard/CustomerDashboard.tsx +++ b/client/src/components/CustomerDashboard/CustomerDashboard.tsx @@ -2,6 +2,7 @@ import { useState } from 'react'; import { useLoaderData } from 'react-router-dom'; import { useForm } from 'react-hook-form'; import { ICustomerDashboardData } from '../../services/CustomerDashboard/CustomerDashboard'; +import { useAuth } from '../../hooks/useAuth'; import FlightCard from './FlightCard/FlightCard'; import avatar from './avatar.jpg'; import './CustomerDashboard.scss'; @@ -16,10 +17,11 @@ interface ICustomerDashboardForm { function CustomerDashboard() { const [error, setError] = useState(''); const [disabled, setDisabled] = useState(true); + const { user } = useAuth(); const data = useLoaderData() as ICustomerDashboardData; const formValues: ICustomerDashboardForm = { - name: data.name, - email: data.email, + name: user?.username ?? '', + email: user?.email ?? '', password: '', confirmPassword: '' }; @@ -52,7 +54,7 @@ function CustomerDashboard() { <div className='card bio-card'> <div className='flex'> <img src={avatar} alt='avatar' className='avatar'></img> - <span>{data.name}</span> + <span>{user?.username ?? ''}</span> <span>Loyal Customer</span> </div> </div> diff --git a/client/src/services/CustomerDashboard/CustomerDashboard.ts b/client/src/services/CustomerDashboard/CustomerDashboard.ts index afcd16fdaa1743d8226431646cde6cca215d54cc..e8c79844812345d29efb1e1a4c1071adc7ad37f3 100644 --- a/client/src/services/CustomerDashboard/CustomerDashboard.ts +++ b/client/src/services/CustomerDashboard/CustomerDashboard.ts @@ -11,16 +11,12 @@ export interface IFlight { } export interface ICustomerDashboardData { - name: string; - email: string; upcomingFlights: IFlight[]; flightsHistory: IFlight[]; } export async function GetCustomerDashboardData(): Promise<ICustomerDashboardData> { return { - name: 'fname lname', - email: 'test@test.com', upcomingFlights: [ { id: 4,