diff --git a/JSON/events.json b/JSON/events.json
index ec096b9..2106ebc 100644
--- a/JSON/events.json
+++ b/JSON/events.json
@@ -22,7 +22,7 @@
"start_date": "2020-10-01T00:00:00Z",
"end_date": "2020-10-31T23:59:59Z",
"title": "Hacktoberfest 2020",
- "description": "Hacktoberfest is a month-long celebration of open source software run by DigitalOcean in partnership with GitHub and Twilio. We will put projects on different fields like Mobile App Development, Web Development, Python, etc. We will initialise some GitHub Repo and will make them open source.",
+ "description": "Hacktoberfest is a month-long celebration of open source software run by DigitalOcean in partnership with GitHub and Twilio.",
"filename": "hacktoberfest_2020.md"
}
],
@@ -31,8 +31,15 @@
"start_date": "2021-10-01T00:00:00Z",
"end_date": "2021-10-31T23:59:59Z",
"title": "Hacktoberfest 2021",
- "description": "Hacktoberfest is a month-long celebration of open source software run by DigitalOcean in partnership with GitHub, Intel, Appwrite & Deepsource. Hacktoberfest encourages participation in the open source community, which grows bigger every year. Complete the 2021 challenge and earn a limited edition T-shirt. We have different projects on our github, check it out!",
+ "description": "Hacktoberfest encourages participation in the open source community.",
"filename": "hacktoberfest_2021.md"
+ },
+ {
+ "start_date": "2021-11-01T00:00:00Z",
+ "end_date": "2021-11-01T23:59:59Z",
+ "title": "Tech Symposium 2021",
+ "description": "A day of talks and workshops from industry leaders.",
+ "filename": "tech_symposium_2021.md"
}
],
"2024": [
@@ -40,8 +47,22 @@
"start_date": "2024-10-01T00:00:00Z",
"end_date": "2024-10-31T23:59:59Z",
"title": "Hacktoberfest 2024",
- "description": "Hacktoberfest 2024 is a month-long celebration of open source software, hosted by DigitalOcean and GitHub. Contribute four quality pull requests during October to earn either a limited edition eco-friendly t-shirt or have a tree planted in your name. Join developers worldwide in supporting open source projects - from beginners to experts, everyone is welcome!",
+ "description": "Hacktoberfest 2024 is a month-long celebration of open source software.",
"filename": "hacktoberfest_2024.md"
+ },
+ {
+ "start_date": "2024-11-01T00:00:00Z",
+ "end_date": "2024-11-01T23:59:59Z",
+ "title": "New Tech Conference 2024",
+ "description": "Join us for a day of insightful talks and networking with industry leaders in tech.",
+ "filename": "new_tech_conference_2024.md"
+ },
+ {
+ "start_date": "2024-12-01T00:00:00Z",
+ "end_date": "2024-12-01T23:59:59Z",
+ "title": "Year-End Hackathon",
+ "description": "A collaborative event for developers to showcase their skills.",
+ "filename": "year_end_hackathon_2024.md"
}
]
}
diff --git a/src/Pages/Events.jsx b/src/Pages/Events.jsx
index ca44eb1..7ebd0a3 100644
--- a/src/Pages/Events.jsx
+++ b/src/Pages/Events.jsx
@@ -2,75 +2,126 @@ import React, { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import EventCard from '@/components/EventCard';
import Loader from '@/components/Loader';
-import SEO from '@/components/SEO';
+import SEO from '@/components/SEO';
+import EventToggle from '../components/EventToggle';
+import RegistrationForm from '../components/RegistrationForm';
const Events = () => {
const { year } = useParams();
const [events, setEvents] = useState([]);
const [loading, setLoading] = useState(true);
+ const [activeTab, setActiveTab] = useState('upcoming');
+ const [isRegistering, setIsRegistering] = useState(false);
+ const [selectedEvent, setSelectedEvent] = useState(null);
+
+ const handleToggle = (tab) => {
+ setActiveTab(tab);
+ };
+
+ const handleRegisterClick = (event) => {
+ setSelectedEvent(event);
+ setIsRegistering(true);
+ };
+
+ const closeRegistration = () => {
+ setIsRegistering(false);
+ setSelectedEvent(null);
+ };
useEffect(() => {
const fetchEvents = async () => {
try {
const response = await fetch("https://raw.githubusercontent.com/clubgamma/club-gamma-frontend/refs/heads/main/JSON/events.json");
const data = await response.json();
- const filteredEvents = data[year] || [];
-
- const eventsWithMarkdown = await Promise.all(filteredEvents.map(async (event) => {
- const filename = event.filename || `${event.title.replace(/\s+/g, '_').toLowerCase()}.md`;
- const markdownResponse = await fetch(`https://raw.githubusercontent.com/clubgamma/club-gamma-frontend/refs/heads/main/JSON/markdowns/${filename}`);
- const markdownContent = await markdownResponse.text();
-
- return {
- ...event,
- markdownContent,
- };
- }));
-
- setEvents(eventsWithMarkdown);
+
+ // Filter events based on the selected year
+ const filteredEvents = data[year] ? data[year].map(event => ({
+ ...event,
+ date: event.start_date || event.date, // Ensure we have a date field
+ })) : [];
+
+ console.log("Fetched Events for year " + year + ":", JSON.stringify(filteredEvents, null, 2));
+ setEvents(filteredEvents);
} catch (error) {
console.error("Error fetching events:", error);
} finally {
setLoading(false);
}
};
-
+
fetchEvents();
}, [year]);
+ // Separate upcoming and past events based on current date
+ const currentDate = new Date();
+console.log("Current Date:", currentDate.toISOString());
+
+const upcomingEvents = events.filter(event => {
+ const startDate = new Date(event.start_date || event.date);
+ console.log(`Checking Event: ${event.title}, Start Date: ${startDate.toISOString()}`);
+ return startDate >= currentDate;
+});
+const pastEvents = events.filter(event => {
+ const endDate = new Date(event.end_date || event.date);
+ return endDate < currentDate;
+});
- return (
- <>
-
No upcoming events found.
+ )} + {year === '2024' && activeTab === 'past' && pastEvents.length === 0 && ( +No past events found.
+ )}No events found for the year {year}.
)} -