Skip to content

Commit 1738f6b

Browse files
authored
Merge pull request #40 from templerobotics/updating-meeting-events
Updating meeting events
2 parents 6027fe3 + 5e75ce8 commit 1738f6b

File tree

9 files changed

+66
-40
lines changed

9 files changed

+66
-40
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ The only other accepted format is an empty string, meaning the date has not been
1111

1212
**Important:** Make sure to increment the id
1313

14-
```json
14+
```ts
1515
[
1616
{
17-
"title": "Title of the event",
18-
"description": "Description of the event",
19-
"date": "04/22",
20-
"location": "Engineering building",
21-
"id": 0
17+
title: 'Title of the event',
18+
description: 'Description of the event',
19+
date: new Date('2025-01-22T17:00:00'),
20+
location: 'The ideas hub (second floor of the engineering building)',
21+
weekly: true,
22+
endDate: new Date(semesterEnd)
2223
},
2324
{
24-
"title": "Title of the event 2",
25-
"description": "Description of the event 2",
26-
"date": "04/23",
27-
"location": "Engineering building",
28-
"id": 1
25+
title: 'Title of the event 2',
26+
description: 'Description of the event 2',
27+
date: new Date('2025-01-22T14:00:00'),
28+
location: 'The ideas hub (second floor of the engineering building)',
29+
weekly: true,
30+
endDate: new Date(semesterEnd)
2931
}
3032
]
3133
```

package-lock.json

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"react-spinners": "^0.13.4",
2727
"typescript": "^4.7.4",
2828
"util": "^0.12.4",
29+
"uuid": "^11.0.5",
2930
"web-vitals": "^2.1.4"
3031
},
3132
"scripts": {

src/data/EventsDatabase.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,23 @@ const EVENT_INFO: EventObject[] = [
1414
{
1515
title: 'Weekly Programming Meeting',
1616
description: 'The weekly meeting for the programming sub-team. Take a look at the code for the robot',
17-
date: new Date('TBD'),
18-
time: 'TBD',
17+
date: new Date('2025-01-22T17:00:00'),
1918
location: 'The ideas hub (second floor of the engineering building)',
2019
weekly: true,
2120
endDate: new Date(semesterEnd)
2221
},
2322
{
2423
title: 'Weekly Electrical Meeting',
2524
description: 'The weekly meeting for the electrical sub-team. Talk about improved batteries, wiring, and more!',
26-
date: new Date('1/22/2025'),
27-
time: '6:00 PM',
25+
date: new Date('2025-01-22T18:00:00'),
2826
location: 'The ideas hub (second floor of the engineering building)',
2927
weekly: true,
3028
endDate: new Date(semesterEnd)
3129
},
3230
{
3331
title: 'Weekly Mechanical Meeting',
3432
description: 'The weekly meeting for the mechanical sub-team. Learn about the design aspects of robot and 3D model parts.',
35-
date: new Date('1/22/2025'),
36-
time: '4:00 PM',
33+
date: new Date('2025-01-22T16:00:00'),
3734
location: 'The ideas hub (second floor of the engineering building)',
3835
weekly: true,
3936
endDate: new Date(semesterEnd)

src/pages/events/EventList.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class EventList extends React.Component<{events: EventObject[], loading: boolean
2424
</div>
2525
<div className='location'>
2626
<p>Location: {event.location}</p>
27-
<p>Time: {event.time === '' ? 'TBD' : event.time}</p>
27+
<p>Time: {event.tbd ? 'TBD' : toTimeString(event.date)}</p>
2828
</div>
2929
<p className='description'>Description: {event.description}</p>
3030
</Styles.EventItemContainer>
@@ -35,4 +35,11 @@ class EventList extends React.Component<{events: EventObject[], loading: boolean
3535
}
3636
}
3737

38+
function toTimeString (date: Date): string {
39+
const time = date.toTimeString().split(' ')[0].split(':')
40+
const hours = parseInt(time[0])
41+
const minutes = time[1]
42+
return `${hours % 12}:${minutes} ${hours >= 12 ? 'PM' : 'AM'}`
43+
}
44+
3845
export default EventList

src/pages/general/photo-gallery/PhotoGallery.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
import React from 'react'
33
import $ from 'jquery'
44
import { BsChevronLeft, BsChevronRight, BsDashLg } from 'react-icons/bs'
5+
import {v4 as uuid} from 'uuid'
56

67
// Custom styles
78
import Styles, { PhotoGalleryProps, GallerySlideProps } from './PhotoGalleryStyles'
89

910
// General tools
1011
import { ANIMATION_TIME, COLORS } from '../../../tools/Constants'
1112

12-
export default class PhotoGallery extends React.Component<PhotoGalleryProps, {currentSlide: number}> {
13+
export default class PhotoGallery extends React.Component<PhotoGalleryProps, {currentSlide: number, galleryId: string}> {
1314
constructor(props: PhotoGalleryProps) {
1415
super(props)
1516
this.state = {
16-
currentSlide: 0
17+
currentSlide: 0,
18+
galleryId: this.props.id ?? uuid()
1719
}
1820
}
1921

@@ -48,14 +50,14 @@ export default class PhotoGallery extends React.Component<PhotoGalleryProps, {cu
4850
const slidesLength = Math.ceil(this.props.galleryInfo.length / 3)
4951
nextSlide = ((nextSlide % slidesLength) + slidesLength) % slidesLength
5052

51-
$(`#slide${this.state.currentSlide}`)
53+
$(`#${this.state.galleryId} #slide${this.state.currentSlide}`)
5254
.fadeOut(animationSpeed).end()
53-
$(`#slide${nextSlide}`)
55+
$(`#${this.state.galleryId} #slide${nextSlide}`)
5456
.fadeIn(animationSpeed).end()
5557

56-
$(`#counter${this.state.currentSlide}`)
58+
$(`#${this.state.galleryId} #counter${this.state.currentSlide}`)
5759
.css('color', COLORS.TEXT)
58-
$(`#counter${nextSlide}`)
60+
$(`#${this.state.galleryId} #counter${nextSlide}`)
5961
.css('color', COLORS.PRIMARY)
6062

6163
this.setState({ currentSlide: nextSlide })
@@ -64,17 +66,17 @@ export default class PhotoGallery extends React.Component<PhotoGalleryProps, {cu
6466
componentDidMount(): void {
6567
// Hide slides after they render
6668
for (let i = 1; i < this.props.galleryInfo.length % 3; i++) {
67-
$(`#slide${i}`).hide()
69+
$(`#${this.state.galleryId} #slide${i}`).hide()
6870
}
69-
$('#counter0').css('color', COLORS.PRIMARY)
71+
$(`#${this.state.galleryId} #counter0`).css('color', COLORS.PRIMARY)
7072
}
7173

7274
render(): React.ReactElement {
7375
const gridColumns = '100% '.repeat(Math.ceil(this.props.galleryInfo.length / 3))
7476
const width = document.documentElement.style.getPropertyValue('--vh')
7577

7678
return (
77-
<Styles.GalleryContainer className={this.props.className} id={this.props.id}>
79+
<Styles.GalleryContainer className={this.props.className} id={this.state.galleryId}>
7880
<Styles.Title>{this.props.title ?? 'Photo Gallery'}</Styles.Title>
7981
<Styles.Chevron as={BsChevronLeft} size={parseFloat(width) * 0.05} onClick={this.slideLeft}/>
8082
<Styles.SlideContainer gridColumns={gridColumns}>

src/pages/robotic-mining/RoboticMining.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const RoboticMining = (): React.ReactElement => {
7878
</div>
7979
</Styles.OutreachGallery>
8080

81-
<PhotoGallery galleryInfo={ GALLERY_INFO }/>
81+
<PhotoGallery className='testing' galleryInfo={ GALLERY_INFO }/>
8282
</Styles.SpaceBackground>
8383

8484
<Contact/>

src/tools/CustomTypes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export type EventObject = {
88
title: string,
99
date: Date,
1010
location: string,
11-
time: string,
1211
description: string,
1312
weekly?: boolean,
14-
endDate?: Date
13+
endDate?: Date,
14+
tbd?: boolean
1515
}

src/tools/services/getEvents.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import EVENT_INFO from '../../data/EventsDatabase'
22
import { EventObject } from '../CustomTypes'
33

44
function sortByDate(eventA: EventObject, eventB: EventObject): number {
5-
if (eventA.date > eventB.date || isNaN(eventA.date.getMonth())) {
5+
const dateComparison = eventA.date.getTime() - eventB.date.getTime()
6+
if (dateComparison > 0 || isNaN(eventA.date.getMonth())) {
67
return 1
78
} else if (eventA.date == eventB.date) {
89
return 0
@@ -16,22 +17,24 @@ function sortByDate(eventA: EventObject, eventB: EventObject): number {
1617
* @returns The events to be posted with the correct weekly dates
1718
*/
1819
function handleWeeklyEvents(events: EventObject[]): EventObject[] {
19-
const currentDate = new Date()
20-
currentDate.setDate(currentDate.getDate() - 1)
21-
currentDate.setUTCHours(23, 59, 59, 999)
20+
// Date used to filter out old events
21+
const dateFilter = new Date()
22+
dateFilter.setDate(dateFilter.getDate() - 1)
23+
dateFilter.setUTCHours(23, 59, 59, 999)
2224

2325
// Remove events that are in the past and no longer occurring.
2426
events = events.filter(event => {
25-
if (event.date < currentDate && !event.weekly) return 0
26-
if (event.weekly && ((event.endDate ?? new Date()) < currentDate)) return 0
27+
if (event.date < dateFilter && !event.weekly) return 0
28+
if (event.weekly && ((event.endDate ?? new Date()) < dateFilter)) return 0
2729
return 1
2830
})
2931

3032
// Handle weekly dates
3133
events.forEach(event => {
3234
const currentDayForWeek = new Date()
3335
const dayOffset = (7 + event.date.getDay() - currentDayForWeek.getDay()) % 7
34-
if (event.weekly && event.date < currentDayForWeek) {
36+
const dateComparison = event.date.getTime() - currentDayForWeek.getTime()
37+
if (event.weekly && dateComparison < 0) {
3538
const newDate = currentDayForWeek.getTime() + dayOffset * 24 * 60 * 60 * 1000
3639
event.date = new Date(newDate)
3740
}

0 commit comments

Comments
 (0)