diff --git a/components/event-calendar.js b/components/event-calendar.js new file mode 100644 index 000000000..7d2a3455e --- /dev/null +++ b/components/event-calendar.js @@ -0,0 +1,132 @@ +import React, { useState } from 'react'; +import { Container, Row, Col, Button } from 'react-bootstrap'; + +const EventCalendar = () => { + const [currentDate, setCurrentDate] = useState(new Date()); + const [selectedDate, setSelectedDate] = useState(null); + + const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + const months = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', + ]; + + const getDaysInMonth = () => { + const year = currentDate.getFullYear(); + const month = currentDate.getMonth(); + const daysInMonth = new Date(year, month + 1, 0).getDate(); + return daysInMonth; + }; + + const handleDayClick = (day) => { + if (day !== '') { + setSelectedDate(new Date(currentDate.getFullYear(), currentDate.getMonth(), day)); + } + }; + + const handleMonthChange = (direction) => { + const newMonth = currentDate.getMonth() + direction; + setCurrentDate(new Date(currentDate.getFullYear(), newMonth, 1)); + setSelectedDate(null); // Reset the selectedDate when the month changes + }; + + const generateCalendar = () => { + const daysInMonth = getDaysInMonth(); + const month = months[currentDate.getMonth()]; + const year = currentDate.getFullYear(); + const firstDay = new Date(year, currentDate.getMonth(), 1); + const dayOfWeek = firstDay.getDay(); // Adjust the day of the week + + const days = []; + for (let i = 0; i < dayOfWeek; i++) { + days.push(''); + } + for (let i = 1; i <= daysInMonth; i++) { + days.push(i); + } + while (days.length % 7 !== 0) { + days.push(''); + } + + const weeks = []; + let week = []; + for (let i = 0; i < days.length; i++) { + week.push(days[i]); + if ((i + 1) % 7 === 0) { + weeks.push(week); + week = []; + } + } + const cellStyle = { + width: '40px', + height: '40px', + cursor: 'pointer', + '@media (min-width: 768px)': { + height: '80px', + }, + }; + + return ( +
+ {day} + | + ))} +
---|
handleDayClick(day)}
+ >
+ {day !== '' && (
+
+ {day}
+
+ )}
+ {/* Placeholder for event names */}
+ {day !== '' && Event Name }
+ |
+ ))}
+