-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSchedule.js
More file actions
163 lines (145 loc) · 4.79 KB
/
Schedule.js
File metadata and controls
163 lines (145 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import React, { useState, useEffect } from 'react';
import { Container } from 'react-bootstrap';
import FullCalendar from '@fullcalendar/react';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import { events } from './events';
import './schedule.css';
const ScheduleCalendar = () => {
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
const [currentDate, setCurrentDate] = useState('2025-01-24');
const calendarRef = React.useRef();
useEffect(() => {
const handleResize = () => setWindowWidth(window.innerWidth);
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
// Add effect to update calendar view when window width changes
useEffect(() => {
if (calendarRef.current) {
const calendarApi = calendarRef.current.getApi();
const isMobile = windowWidth < 768;
// Update view
calendarApi.changeView(isMobile ? 'timeGridDay' : 'timeGridThreeDay');
// Force re-render of the calendar
calendarApi.updateSize();
}
}, [windowWidth]);
const dateButtons = [
{ date: '2025-01-24', label: 'Friday' },
{ date: '2025-01-25', label: 'Saturday' },
{ date: '2025-01-26', label: 'Sunday' }
];
const handleDateSelect = (date) => {
if (calendarRef.current) {
calendarRef.current.getApi().gotoDate(date);
setCurrentDate(date);
}
};
const getEventClassNames = (eventInfo) => {
switch (eventInfo.event.extendedProps.type) {
case 'educational':
return ['event-color-1', 'clickable-event']; // append back 'clickable-event' when link is needed
case 'events':
return ['event-color-2'];
case 'hacking':
return ['event-color-3'];
case 'keynote':
return ['event-color-4', 'clickable-event'];
case 'unconference':
return ['event-color-5'];
default:
return ['event-color-1'];
}
};
const renderEventContent = (eventInfo) => {
const link = eventInfo.event.extendedProps.link
if (link) {
return (
<a
href={link}
className="custom-event-content clickable"
onClick={(e) => e.stopPropagation()}
>
<div className="event-title">{eventInfo.event.title}</div>
</a>
);
}
// const isWorkshop = eventInfo.event.extendedProps.type === 'workshop';
// if (isWorkshop) {
// return (
// <a
// href="https://brainhack-vandy.github.io/"
// target="_blank"
// rel="noopener noreferrer"
// className="custom-event-content clickable"
// onClick={(e) => e.stopPropagation()}
// >
// <div className="event-title">{eventInfo.event.title}</div>
// </a>
// );
// }
return (
<div className="custom-event-content">
<div className="event-title">{eventInfo.event.title}</div>
</div>
);
};
const isMobile = windowWidth < 768;
return (
<Container fluid className="schedule-section">
<Container>
<h1 className="page-heading">Event <strong className="purple">Schedule</strong></h1>
{isMobile && (
<div className="date-selector">
{dateButtons.map(({ date, label }) => (
<button
key={date}
onClick={() => handleDateSelect(date)}
className={`date-button ${currentDate === date ? 'active' : ''}`}
>
{label}
</button>
))}
</div>
)}
<div className="schedule-container">
<FullCalendar
ref={calendarRef}
plugins={[dayGridPlugin, timeGridPlugin]}
initialView={isMobile ? 'timeGridDay' : 'timeGridThreeDay'}
views={{
timeGridThreeDay: {
type: 'timeGrid',
duration: { days: 3 },
buttonText: '3 day'
}
}}
headerToolbar={{
left: isMobile ? 'prev,next' : '',
center: 'title',
right: isMobile ? 'timeGridDay' : ''
}}
dayHeaderFormat={{ weekday: 'long' }}
initialDate="2025-01-24"
validRange={{
start: '2025-01-24',
end: '2025-01-27'
}}
slotMinTime="09:00:00"
slotMaxTime="19:00:00"
expandRows={true}
height={isMobile ? 600 : 800}
slotDuration="00:30:00"
events={events}
eventContent={renderEventContent}
eventClassNames={getEventClassNames}
eventDisplay="block"
allDaySlot={false}
/>
</div>
</Container>
</Container>
);
};
export default ScheduleCalendar;