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 ( +
+

+ {month} {year} +

+ + + + {daysOfWeek.map((day, index) => ( + + ))} + + + + {weeks.map((week, weekIndex) => ( + + {week.map((day, dayIndex) => ( + + ))} + + ))} + +
+ {day} +
handleDayClick(day)} + > + {day !== '' && ( +
+ {day} +
+ )} + {/* Placeholder for event names */} + {day !== '' &&
Event Name
} +
+
+ + +
+
+ ); + }; + + return
{generateCalendar()}
; +}; + +export default EventCalendar; \ No newline at end of file diff --git a/components/nav/common.js b/components/nav/common.js index 8be6dfa64..d12c844ec 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -347,6 +347,17 @@ export function Sorts ({ sub, prefix, className }) { top } + {sub !== 'jobs' && + + + events + + } ) } diff --git a/pages/~/events/index.js b/pages/~/events/index.js new file mode 100644 index 000000000..aef0cff4e --- /dev/null +++ b/pages/~/events/index.js @@ -0,0 +1,39 @@ +import Layout from '@/components/layout' +import Items from '@/components/items' +import EventCalendar from '@/components/event-calendar' +import { getGetServerSideProps } from '@/api/ssrApollo' +import RecentHeader from '@/components/recent-header' +import { useRouter } from 'next/router' +import { SUB_FULL, SUB_ITEMS } from '@/fragments/subs' +import { COMMENT_TYPE_QUERY } from '@/lib/constants' +import { useQuery } from '@apollo/client' +import PageLoading from '@/components/page-loading' + +const staticVariables = { sort: 'recent' } +const variablesFunc = vars => + ({ includeComments: COMMENT_TYPE_QUERY.includes(vars.type), ...staticVariables, ...vars }) +export const getServerSideProps = getGetServerSideProps({ + query: SUB_ITEMS, + variables: variablesFunc, + notFound: (data, vars) => vars.sub && !data.sub +}) + +export default function Index ({ ssrData }) { + const router = useRouter() + const variables = variablesFunc(router.query) + const { data } = useQuery(SUB_FULL, { variables }) + + if (!data && !ssrData) return + const { sub } = data || ssrData + + return ( + + {/* */} + + + ) +} diff --git a/styles/calendar.module.css b/styles/calendar.module.css new file mode 100644 index 000000000..dd47e14ef --- /dev/null +++ b/styles/calendar.module.css @@ -0,0 +1,20 @@ +.calendar-header { + width: 40px; + height: 40px; + } + + .calendar-cell { + width: 40px; + height: 40px; + cursor: pointer; + } + + @media (min-width: 768px) { + .calendar-header { + height: 80px; + } + + .calendar-cell { + height: 80px; + } + } \ No newline at end of file