From 0845831c817bae43afcae6d1d95f506a80383c01 Mon Sep 17 00:00:00 2001 From: lcross2002 <liamdcross@outlook.com> Date: Wed, 1 May 2024 23:29:10 +0100 Subject: [PATCH] dashboard timeout bugfix + add home page text --- client/src/components/Home/Home.scss | 22 +++++++++++++++++++ client/src/components/Home/Home.tsx | 18 +++++++++++++++ client/src/index.scss | 1 + client/src/main.tsx | 5 +++++ .../services/Dashboard/CustomerDashboard.ts | 14 ++++++++++-- 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 client/src/components/Home/Home.scss create mode 100644 client/src/components/Home/Home.tsx diff --git a/client/src/components/Home/Home.scss b/client/src/components/Home/Home.scss new file mode 100644 index 0000000..2b6b8ce --- /dev/null +++ b/client/src/components/Home/Home.scss @@ -0,0 +1,22 @@ +.home { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; +} + +.home-card { + display: flex; + align-items: center; + justify-content: center; + width: 80vw; + height: 90%; + min-width: 350px; + background-color: var(--light); + text-align: center; + + p { + font-size: 1.75rem; + } +} diff --git a/client/src/components/Home/Home.tsx b/client/src/components/Home/Home.tsx new file mode 100644 index 0000000..9f25796 --- /dev/null +++ b/client/src/components/Home/Home.tsx @@ -0,0 +1,18 @@ +import './Home.scss'; + +function Home() { + return ( + <> + <div className='home'> + <div className='card home-card'> + <p>Welcome to Airline Booking!</p> + <p>This website allows you to create and book domestic flights in the UK</p> + <p>If you are new please navigate to the register page via the link in the header</p> + <p>Happy flying</p> + </div> + </div> + </> + ); +} + +export default Home; diff --git a/client/src/index.scss b/client/src/index.scss index 9579f87..8c3d147 100644 --- a/client/src/index.scss +++ b/client/src/index.scss @@ -15,6 +15,7 @@ body { /* CSS Variables */ :root { --main: #000055; + --light: hsla(240, 100%, 17%, 0.299); } /* diff --git a/client/src/main.tsx b/client/src/main.tsx index 28bec0b..e80244f 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -30,6 +30,7 @@ import CustomerProtectedRoute from "./components/ProtectedRoute/CustomerProtecte import AirlineProtectedRoute from "./components/ProtectedRoute/AirlineProtectedRoute.tsx"; import ErrorPage404 from "./components/ErrorPage/ErrorPage404.tsx"; import ErrorPage from "./components/ErrorPage/ErrorPage.tsx"; +import Home from "./components/Home/Home.tsx"; import { loadStripe } from '@stripe/stripe-js'; loadStripe('pk_test_51P5UhOExQclpActcEGkHdut1X1k6uQnEXQ2cKKTD5l9FS9a1TyB2ap1lRSQXZt35Dpd7mh8gHOwFyVb4TiqpZfJr00bDRrD4vF'); @@ -41,6 +42,10 @@ const router = createBrowserRouter([ element: <App></App>, errorElement: <ErrorPage></ErrorPage>, children: [ + { + path: "", + element: <Home></Home> + }, { element: <InverseProtectedRoute></InverseProtectedRoute>, children: [ diff --git a/client/src/services/Dashboard/CustomerDashboard.ts b/client/src/services/Dashboard/CustomerDashboard.ts index 040429f..4a31774 100644 --- a/client/src/services/Dashboard/CustomerDashboard.ts +++ b/client/src/services/Dashboard/CustomerDashboard.ts @@ -48,7 +48,17 @@ export async function GetCustomerDashboardData(): Promise<ICustomerDashboardData flightsHistory: hData.data }; } catch (error) { - throw error; + try { + const upcomingFlights = Api.get('Booking/upcoming', { withCredentials: true }); + const flightsHistory = Api.get('Booking/history', { withCredentials: true }); + const [uData, hData] = await Promise.all([upcomingFlights, flightsHistory]); + return { + type: 'customer', + upcomingFlights: uData.data, + flightsHistory: hData.data + }; + } catch (newError) { + throw newError; + } } } - -- GitLab