From 83156d541fc62082f2b14166d12bd9561f2e0e40 Mon Sep 17 00:00:00 2001 From: Adwit Mukherji <66975870+4dw1tz@users.noreply.github.com> Date: Sat, 26 Oct 2024 23:32:21 +0100 Subject: [PATCH] Buy ticket interface works --- .eslintrc.json | 3 +- app/events/[...eventId]/page.tsx | 73 +++++++++++++++----------- app/events/page.tsx | 3 +- components/custom/EventDescription.tsx | 52 ++++++++++++------ components/custom/ImageCarousel.tsx | 21 +++++--- package-lock.json | 2 + 6 files changed, 98 insertions(+), 56 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1a1ad7a..c9fcf13 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "extends": ["next/core-web-vitals", "next/typescript"], "rules": { - "@next/next/no-img-element": "off" + "@next/next/no-img-element": "off", + "@typescript-eslint/no-explicit-any": "off" } } diff --git a/app/events/[...eventId]/page.tsx b/app/events/[...eventId]/page.tsx index 60ad8d6..644e4bb 100644 --- a/app/events/[...eventId]/page.tsx +++ b/app/events/[...eventId]/page.tsx @@ -1,46 +1,55 @@ 'use client'; -import React from 'react'; -import { useSearchParams } from 'next/navigation'; +import React, { useEffect, useState } from 'react'; +import { useParams } from 'next/navigation'; import Header from '../../../components/custom/header'; import Footer from '../../../components/custom/footer'; import EventDescription from '../../../components/custom/EventDescription'; -// Dummy function to simulate a GET request -const fetchEventDetails = (eventID: number) => { - alert(`Fetching details for event ID: ${eventID}`); - // Simulated JSON response for the event - return { - EventID: eventID, - name: 'Example Event Name', - date: '2023-12-01', - location: 'Example Location', - ticketPrice: 100, - description: 'Detailed description of the event.', - capacity: 300, - ticketsSold: 150, - imageUrl: [ - 'https://via.placeholder.com/150', - 'https://via.placeholder.com/150', - ], - host: 'Example Host', - tickets: [1, 2, 3, 4], - }; -}; - const ListingPage: React.FC = () => { - const searchParams = useSearchParams(); - const eventID = searchParams.get('eventID'); + const { eventId } = useParams(); + const [eventDetails, setEventDetails] = useState(null); - // Simulate fetching data from backend - if (eventID) { - const eventDetails = fetchEventDetails(Number(eventID)); - console.log('Event Details:', eventDetails); - } + useEffect(() => { + const fetchEventDetails = async (id: number) => { + alert(`Fetching details for event ID: ${id}`); + // Dummy Response + const details = { + EventID: id, + name: 'Example Event Name', + date: '2023-12-01', + location: 'Example Location', + ticketPrice: 100, + description: 'Detailed description of the event.', + capacity: 300, + ticketsSold: 295, + imageUrl: [ + 'https://via.placeholder.com/150', + 'https://via.placeholder.com/150', + ], + host: 'Example Host', + tickets: [1, 2, 3, 4], + }; + return details; + }; + + const getEventDetails = async () => { + if (eventId) { + const details = await fetchEventDetails(Number(eventId)); + setEventDetails(details); + } + }; + + getEventDetails(); + }, [eventId]); return ( <>
- + {eventDetails ? ( + + ) : ( +

Loading...

+ )}