From 5acfae0d5f670b814032cb94aa37151c7c1628e8 Mon Sep 17 00:00:00 2001
From: "Cross, Liam (UG - Comp Sci & Elec Eng)" <lc01383@surrey.ac.uk>
Date: Tue, 2 Apr 2024 16:50:18 +0000
Subject: [PATCH] Use real data in customer dashboard profile

---
 .../components/CustomerDashboard/CustomerDashboard.tsx    | 8 +++++---
 .../src/services/CustomerDashboard/CustomerDashboard.ts   | 4 ----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/client/src/components/CustomerDashboard/CustomerDashboard.tsx b/client/src/components/CustomerDashboard/CustomerDashboard.tsx
index c6a58d2..394312d 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 afcd16f..e8c7984 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,
-- 
GitLab