diff --git a/src/components/NoPage.jsx b/src/components/NoPage.jsx
index 09a14f7..ec9d454 100644
--- a/src/components/NoPage.jsx
+++ b/src/components/NoPage.jsx
@@ -1,13 +1,14 @@
-// NotFound.js
import React from 'react';
-const NoPage = () => {
+const NotFound = () => {
return (
-
-
404 - Not Found
-
The page you are looking for does not exist.
+
+
+
404 - Not Found
+
The page you are looking for does not exist.
+
);
}
-export default NoPage;
+export default NotFound;
diff --git a/src/components/Purchase.jsx b/src/components/Purchase.jsx
index 69a8062..2352a0f 100644
--- a/src/components/Purchase.jsx
+++ b/src/components/Purchase.jsx
@@ -1,6 +1,8 @@
import React, { useState, useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
-import PurchaseConfirmation from './ConfirmationPage'; // Import the PurchaseConfirmation component
+import PurchaseConfirmation from './ConfirmationPage';
+import SignIn from './UserLogin';
+
import Header from './Header';
import Footer from './Footer';
@@ -37,6 +39,14 @@ function Purchase() {
});
}, [eventId]);
+ useEffect(() => {
+ // Check if the user is logged in
+ const jwt = localStorage.getItem('jwt');
+ if (!jwt) {
+ navigate("/login"); // Redirect to login page if not logged in
+ }
+ }, [navigate]);
+
if (error) {
return
Error: {error}
;
}
@@ -44,10 +54,14 @@ function Purchase() {
if (!event) {
return
Loading...
;
}
+
const handleRegularPurchaseClick = () => {
- const regularAvailable = event.data.attributes.ticketQuantityRegular - event.data.attributes.ticketsSoldRegular;
+
+
+ const regularAvailable = event.data.attributes.ticketQuantityRegular - event.data.attributes.ticketsSoldRegular;
+
if (regularQuantity <= 0) {
setErrorMessage('Please enter a valid quantity.');
return;
@@ -62,8 +76,11 @@ function Purchase() {
};
const handleVIPPurchaseClick = () => {
- const vipAvailable = event.data.attributes.ticketQuantityVIP - event.data.attributes.ticketSoldVIP;
+
+
+ const vipAvailable = event.data.attributes.ticketQuantityVIP - event.data.attributes.ticketSoldVIP;
+
if (vipQuantity <= 0) {
setErrorMessage('Please enter a valid quantity.');
return;
@@ -128,7 +145,7 @@ function Purchase() {
onChange={(e) => setRegularQuantity(e.target.value)}
placeholder="Enter quantity"
/>
-
+