From e6a9f88ca9e969ca5fc087ffab8c370a813e88a8 Mon Sep 17 00:00:00 2001 From: Naman Srivastava Date: Tue, 1 Oct 2024 17:02:51 +0530 Subject: [PATCH] fix/all ticket types are rendered --- components/Tickets/ticketCards.js | 66 ++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/components/Tickets/ticketCards.js b/components/Tickets/ticketCards.js index 5f73b8e4..36af803e 100644 --- a/components/Tickets/ticketCards.js +++ b/components/Tickets/ticketCards.js @@ -1,32 +1,50 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import Button from '../Buttons/button'; +import cityList from '../../config/city-lists.json'; // Adjust the path to your JSON file -function TicketCards({ className, city }) { - // Determine card style based on event status - const isEndedOrUpcoming = city.ended || !city.ticket; - const cardOpacity = isEndedOrUpcoming ? 'opacity-40' : 'opacity-100'; - const buttonText = city.isFree ? 'Get Your Ticket' : 'Buy Now'; +function TicketCards({ className }) { + const [eventsData, setEventsData] = useState([]); + + useEffect(() => { + // Set the event data from the imported JSON file + setEventsData(cityList); + }, []); return ( -
-
-
{city.name}, {city.country}
-
{city.date}
-
-
- {/* Show a button based on the event status */} - {isEndedOrUpcoming ? ( - - ) : ( - - - - )} -
+
+ {eventsData.map((city) => { + // Determine card style based on event status + const isEndedOrUpcoming = city.ended || !city.ticket; + const cardOpacity = isEndedOrUpcoming ? 'opacity-40' : 'opacity-100'; + const buttonText = city.isFree ? 'Get Your Ticket' : 'Buy Now'; + + return ( +
+
+
{city.name}, {city.country}
+
{city.date}
+
{city.description}
{/* Added description */} +
+
+ {/* Show a button based on the event status */} + {isEndedOrUpcoming ? ( + + ) : ( + + + + )} +
+
+ ); + })}
); } -export default TicketCards; \ No newline at end of file +export default TicketCards;