- {ongoingEvents.map((event, index) => (
-
}
+
+ {/* Displaying the Events */}
+
+ {/* Present Events */}
+
Present Events
+ {presentEvents.length > 0 ? (
+
+ {presentEvents.map((event) => (
+
))}
) : (
-
No ongoing events.
+
No present events available.
)}
-
-
-
Past Events
- {pastEvents.length > 0 ? (
-
- {pastEvents.map((event, index) => (
-
Future Events
+ {futureEvents.length > 0 ? (
+
+ {futureEvents.map((event) => (
+
))}
) : (
- No past events.
+ No future events available.
)}
-
+ {/* Past Events */}
+
Past Events
+ {pastEvents.length > 0 ? (
+
+ {pastEvents.map((event) => (
+
+ ))}
+
+ ) : (
+
No past events available.
+ )}
- {selectedEvent && (
-
+ {/* Sidebar for Event Details */}
+ {isSidebarOpen && selectedEvent && (
+
+ )}
+
+ {/* Event Update Form */}
+ {isAdminLoggedIn && selectedEvent && (
+
+
Update Event
+
+
)}
);
};
-export default Page;
+export default EventsPage;
diff --git a/components/EventCard.tsx b/components/EventCard.tsx
new file mode 100644
index 0000000..4afb601
--- /dev/null
+++ b/components/EventCard.tsx
@@ -0,0 +1,96 @@
+import Image from "next/image";
+
+interface EventCardProps {
+ event: {
+ id: string;
+ eventName: string;
+ description: string;
+ eventDate: string;
+ lastDateOfRegistration: string;
+ dateCreated: string;
+ dateModified: string;
+ imageURL: string;
+ registrationLink: string;
+ };
+ isAdminLoggedIn: boolean;
+ onDelete: (eventId: string) => void;
+ onSelect: (event: {
+ id: string;
+ eventName: string;
+ description: string;
+ eventDate: string;
+ lastDateOfRegistration: string;
+ dateCreated: string;
+ dateModified: string;
+ imageURL: string;
+ registrationLink: string;
+ }) => void;
+}
+
+const EventCard: React.FC
= ({
+ event,
+ isAdminLoggedIn,
+ onDelete,
+ onSelect,
+}) => {
+ // Extracting the day and month from the eventDate string
+ const eventDate = new Date(event.eventDate);
+ const day = eventDate.toLocaleString("en-US", { day: "2-digit" });
+ const month = eventDate.toLocaleString("en-US", { month: "short" });
+
+ return (
+ onSelect(event)}
+ >
+ {/* Event Date Badge */}
+
+
+ {/* Event Image */}
+
+
+
+ {/* Event Content */}
+
+
+
{event.eventName}
+
{event.description}
+
+ {/* Admin Options */}
+ {isAdminLoggedIn && (
+
+
+
+
+ )}
+
+
+ );
+};
+
+export default EventCard;
diff --git a/components/EventForm.tsx b/components/EventForm.tsx
new file mode 100644
index 0000000..ad903dc
--- /dev/null
+++ b/components/EventForm.tsx
@@ -0,0 +1,146 @@
+import { useState } from "react";
+import { db } from "../Firebase";
+import { addDoc, collection } from "firebase/firestore";
+
+const EventForm = () => {
+ const [eventName, setEventName] = useState("");
+ const [eventDate, setEventDate] = useState("");
+ const [lastDateOfRegistration, setLastDateOfRegistration] = useState("");
+ const [description, setDescription] = useState("");
+ const [imageURL, setImageURL] = useState("");
+ const [registrationLink, setRegistrationLink] = useState("");
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+ try {
+ const eventsCollection = collection(db, "myEvents");
+ const currentDate = new Date().toISOString(); // Get current date/time in ISO format
+
+ await addDoc(eventsCollection, {
+ eventName,
+ eventDate,
+ lastDateOfRegistration,
+ description,
+ imageURL,
+ registrationLink,
+ dateCreated: currentDate,
+ dateModified: currentDate,
+ });
+
+ alert("Event added successfully!");
+
+ // Clear form fields after submission
+ setEventName("");
+ setEventDate("");
+ setLastDateOfRegistration("");
+ setDescription("");
+ setImageURL("");
+ setRegistrationLink("");
+ } catch (error) {
+ console.error("Error adding event:", error);
+ }
+ };
+
+ return (
+
+ );
+};
+
+export default EventForm;
diff --git a/components/EventUpdateForm.tsx b/components/EventUpdateForm.tsx
new file mode 100644
index 0000000..b5f35c9
--- /dev/null
+++ b/components/EventUpdateForm.tsx
@@ -0,0 +1,164 @@
+import { useState } from "react";
+import { db } from "../Firebase";
+import { doc, updateDoc } from "firebase/firestore";
+
+interface EventUpdateFormProps {
+ eventId: string;
+ initialEventData: {
+ eventName: string;
+ eventDate: string;
+ lastDateOfRegistration: string;
+ description: string;
+ imageURL: string;
+ registrationLink: string; // Add this field to your initial data structure
+ };
+}
+
+const EventUpdateForm = ({
+ eventId,
+ initialEventData,
+}: EventUpdateFormProps) => {
+ const [eventName, setEventName] = useState(initialEventData.eventName);
+ const [eventDate, setEventDate] = useState(initialEventData.eventDate);
+ const [lastDateOfRegistration, setLastDateOfRegistration] = useState(
+ initialEventData.lastDateOfRegistration
+ );
+ const [description, setDescription] = useState(initialEventData.description);
+ const [imageURL, setImageURL] = useState(initialEventData.imageURL);
+ const [registrationLink, setRegistrationLink] = useState(initialEventData.registrationLink); // New state for registration link
+
+ const handleUpdate = async (e: React.FormEvent) => {
+ e.preventDefault();
+ try {
+ const eventDocRef = doc(db, "myEvents", eventId);
+ const currentDate = new Date().toISOString(); // Set dateModified to the current date/time
+
+ await updateDoc(eventDocRef, {
+ eventName,
+ eventDate,
+ lastDateOfRegistration,
+ description,
+ imageURL,
+ registrationLink, // Include the registration link in the update
+ dateModified: currentDate,
+ });
+
+ alert("Event updated successfully!");
+ } catch (error) {
+ console.error("Error updating event:", error);
+ }
+ };
+
+ return (
+
+ );
+};
+
+export default EventUpdateForm;
diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx
new file mode 100644
index 0000000..75327f2
--- /dev/null
+++ b/components/Sidebar.tsx
@@ -0,0 +1,137 @@
+import Image from "next/image";
+import {
+ FaCalendarAlt,
+ FaMapMarkerAlt,
+ FaCheckCircle,
+ FaClock,
+ FaUserShield,
+} from "react-icons/fa"; // Icons for various info
+import { useState, useEffect } from "react";
+
+interface SidebarProps {
+ event: {
+ id: string;
+ eventName: string;
+ description: string;
+ eventDate: string;
+ lastDateOfRegistration: string;
+ dateCreated: string;
+ dateModified: string;
+ imageURL: string;
+ } | null;
+ onClose: () => void;
+ registrationLink?: string; // Optionally pass a registration link
+}
+
+const Sidebar: React.FC = ({ event, onClose, registrationLink }) => {
+ const [isVisible, setIsVisible] = useState(false);
+
+ // Get current date
+ const currentDate = new Date().toISOString().split("T")[0];
+
+ // Trigger sidebar to open with animation when event is passed
+ useEffect(() => {
+ if (event) {
+ setIsVisible(true);
+ } else {
+ setIsVisible(false);
+ }
+ }, [event]);
+
+ if (!event) return null; // Return nothing if no event is selected
+
+ return (
+
+
+ {/* Close Button */}
+
+
+ {/* Event Name */}
+
+ {event.eventName}
+
+
+ {/* Image */}
+ {event.imageURL ? (
+
+
+
+ ) : (
+
+ No image available
+
+ )}
+
+ {/* Event Details */}
+
+
+
+
Event Date: {event.eventDate}
+
+
+
+
+ Last Registration Date: {event.lastDateOfRegistration}
+
+
+
+
+
Location: Bengaluru, Karnataka
{" "}
+ {/* Can adjust dynamically if available */}
+
+
+
+ {/* Registration Section */}
+
+
+ {/* About Event */}
+
+
+ About Event
+
+
{event.description}
+
+
+
+ );
+};
+
+export default Sidebar;