From e47f92dbadff23a3bfc8b70685e045846e3da11f Mon Sep 17 00:00:00 2001 From: Malin Date: Mon, 20 Jan 2025 16:08:10 -0500 Subject: [PATCH 1/3] Updated programming time and date --- src/data/EventsDatabase.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/EventsDatabase.tsx b/src/data/EventsDatabase.tsx index 515d1c9..1b13247 100644 --- a/src/data/EventsDatabase.tsx +++ b/src/data/EventsDatabase.tsx @@ -14,8 +14,8 @@ const EVENT_INFO: EventObject[] = [ { title: 'Weekly Programming Meeting', description: 'The weekly meeting for the programming sub-team. Take a look at the code for the robot', - date: new Date('TBD'), - time: 'TBD', + date: new Date('1/22/2025'), + time: '5:00 PM', location: 'The ideas hub (second floor of the engineering building)', weekly: true, endDate: new Date(semesterEnd) From ea51b680648bc824154bb84bcb15a84146b5c6c6 Mon Sep 17 00:00:00 2001 From: Ryan Hodge Date: Mon, 20 Jan 2025 16:55:58 -0500 Subject: [PATCH 2/3] Fix date sorting issues and gallery images not cycling --- package-lock.json | 20 ++++++++++++++++--- package.json | 1 + src/data/EventsDatabase.tsx | 9 +++------ src/pages/events/EventList.tsx | 9 ++++++++- .../general/photo-gallery/PhotoGallery.tsx | 20 ++++++++++--------- src/pages/robotic-mining/RoboticMining.tsx | 2 +- src/tools/CustomTypes.tsx | 4 ++-- src/tools/services/getEvents.tsx | 17 +++++++++------- 8 files changed, 53 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index cc9fc92..64cdf97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "react-spinners": "^0.13.4", "typescript": "^4.7.4", "util": "^0.12.4", + "uuid": "^11.0.5", "web-vitals": "^2.1.4" }, "devDependencies": { @@ -16823,6 +16824,14 @@ "websocket-driver": "^0.7.4" } }, + "node_modules/sockjs/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/source-list-map": { "version": "2.0.1", "license": "MIT" @@ -18081,10 +18090,15 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "license": "MIT", + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.5.tgz", + "integrity": "sha512-508e6IcKLrhxKdBbcA2b4KQZlLVp2+J5UwQ6F7Drckkc5N9ZJwFa4TgWtsww9UG8fGHbm6gbV19TdM5pQ4GaIA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/v8-to-istanbul": { diff --git a/package.json b/package.json index 9161dc6..541de0b 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "react-spinners": "^0.13.4", "typescript": "^4.7.4", "util": "^0.12.4", + "uuid": "^11.0.5", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/src/data/EventsDatabase.tsx b/src/data/EventsDatabase.tsx index 1b13247..3500cfd 100644 --- a/src/data/EventsDatabase.tsx +++ b/src/data/EventsDatabase.tsx @@ -14,8 +14,7 @@ const EVENT_INFO: EventObject[] = [ { title: 'Weekly Programming Meeting', description: 'The weekly meeting for the programming sub-team. Take a look at the code for the robot', - date: new Date('1/22/2025'), - time: '5:00 PM', + date: new Date('2025-01-22T17:00:00'), location: 'The ideas hub (second floor of the engineering building)', weekly: true, endDate: new Date(semesterEnd) @@ -23,8 +22,7 @@ const EVENT_INFO: EventObject[] = [ { title: 'Weekly Electrical Meeting', description: 'The weekly meeting for the electrical sub-team. Talk about improved batteries, wiring, and more!', - date: new Date('1/22/2025'), - time: '6:00 PM', + date: new Date('2025-01-22T18:00:00'), location: 'The ideas hub (second floor of the engineering building)', weekly: true, endDate: new Date(semesterEnd) @@ -32,8 +30,7 @@ const EVENT_INFO: EventObject[] = [ { title: 'Weekly Mechanical Meeting', description: 'The weekly meeting for the mechanical sub-team. Learn about the design aspects of robot and 3D model parts.', - date: new Date('1/22/2025'), - time: '4:00 PM', + date: new Date('2025-01-22T16:00:00'), location: 'The ideas hub (second floor of the engineering building)', weekly: true, endDate: new Date(semesterEnd) diff --git a/src/pages/events/EventList.tsx b/src/pages/events/EventList.tsx index bef2467..55cdf3a 100644 --- a/src/pages/events/EventList.tsx +++ b/src/pages/events/EventList.tsx @@ -24,7 +24,7 @@ class EventList extends React.Component<{events: EventObject[], loading: boolean

Location: {event.location}

-

Time: {event.time === '' ? 'TBD' : event.time}

+

Time: {event.tbd ? 'TBD' : toTimeString(event.date)}

Description: {event.description}

@@ -35,4 +35,11 @@ class EventList extends React.Component<{events: EventObject[], loading: boolean } } +function toTimeString (date: Date): string { + const time = date.toTimeString().split(' ')[0].split(':') + const hours = parseInt(time[0]) + const minutes = time[1] + return `${hours % 12}:${minutes} ${hours >= 12 ? 'PM' : 'AM'}` +} + export default EventList diff --git a/src/pages/general/photo-gallery/PhotoGallery.tsx b/src/pages/general/photo-gallery/PhotoGallery.tsx index 206b469..8de61cc 100644 --- a/src/pages/general/photo-gallery/PhotoGallery.tsx +++ b/src/pages/general/photo-gallery/PhotoGallery.tsx @@ -2,6 +2,7 @@ import React from 'react' import $ from 'jquery' import { BsChevronLeft, BsChevronRight, BsDashLg } from 'react-icons/bs' +import {v4 as uuid} from 'uuid' // Custom styles import Styles, { PhotoGalleryProps, GallerySlideProps } from './PhotoGalleryStyles' @@ -9,11 +10,12 @@ import Styles, { PhotoGalleryProps, GallerySlideProps } from './PhotoGalleryStyl // General tools import { ANIMATION_TIME, COLORS } from '../../../tools/Constants' -export default class PhotoGallery extends React.Component { +export default class PhotoGallery extends React.Component { constructor(props: PhotoGalleryProps) { super(props) this.state = { - currentSlide: 0 + currentSlide: 0, + galleryId: this.props.id ?? uuid() } } @@ -48,14 +50,14 @@ export default class PhotoGallery extends React.Component + {this.props.title ?? 'Photo Gallery'} diff --git a/src/pages/robotic-mining/RoboticMining.tsx b/src/pages/robotic-mining/RoboticMining.tsx index 3974b95..eed6ce8 100644 --- a/src/pages/robotic-mining/RoboticMining.tsx +++ b/src/pages/robotic-mining/RoboticMining.tsx @@ -78,7 +78,7 @@ const RoboticMining = (): React.ReactElement => { - + diff --git a/src/tools/CustomTypes.tsx b/src/tools/CustomTypes.tsx index 5b7555a..e2d17f5 100644 --- a/src/tools/CustomTypes.tsx +++ b/src/tools/CustomTypes.tsx @@ -8,8 +8,8 @@ export type EventObject = { title: string, date: Date, location: string, - time: string, description: string, weekly?: boolean, - endDate?: Date + endDate?: Date, + tbd?: boolean } diff --git a/src/tools/services/getEvents.tsx b/src/tools/services/getEvents.tsx index 6e785a0..5534e96 100644 --- a/src/tools/services/getEvents.tsx +++ b/src/tools/services/getEvents.tsx @@ -2,7 +2,8 @@ import EVENT_INFO from '../../data/EventsDatabase' import { EventObject } from '../CustomTypes' function sortByDate(eventA: EventObject, eventB: EventObject): number { - if (eventA.date > eventB.date || isNaN(eventA.date.getMonth())) { + const dateComparison = eventA.date.getTime() - eventB.date.getTime() + if (dateComparison > 0 || isNaN(eventA.date.getMonth())) { return 1 } else if (eventA.date == eventB.date) { return 0 @@ -16,14 +17,15 @@ function sortByDate(eventA: EventObject, eventB: EventObject): number { * @returns The events to be posted with the correct weekly dates */ function handleWeeklyEvents(events: EventObject[]): EventObject[] { - const currentDate = new Date() - currentDate.setDate(currentDate.getDate() - 1) - currentDate.setUTCHours(23, 59, 59, 999) + // Date used to filter out old events + const dateFilter = new Date() + dateFilter.setDate(dateFilter.getDate() - 1) + dateFilter.setUTCHours(23, 59, 59, 999) // Remove events that are in the past and no longer occurring. events = events.filter(event => { - if (event.date < currentDate && !event.weekly) return 0 - if (event.weekly && ((event.endDate ?? new Date()) < currentDate)) return 0 + if (event.date < dateFilter && !event.weekly) return 0 + if (event.weekly && ((event.endDate ?? new Date()) < dateFilter)) return 0 return 1 }) @@ -31,7 +33,8 @@ function handleWeeklyEvents(events: EventObject[]): EventObject[] { events.forEach(event => { const currentDayForWeek = new Date() const dayOffset = (7 + event.date.getDay() - currentDayForWeek.getDay()) % 7 - if (event.weekly && event.date < currentDayForWeek) { + const dateComparison = event.date.getTime() - currentDayForWeek.getTime() + if (event.weekly && dateComparison < 0) { const newDate = currentDayForWeek.getTime() + dayOffset * 24 * 60 * 60 * 1000 event.date = new Date(newDate) } From 5e75ce8acf3c6710b13a17657c05006e91b8b472 Mon Sep 17 00:00:00 2001 From: Ryan Hodge Date: Mon, 20 Jan 2025 16:59:24 -0500 Subject: [PATCH 3/3] Updated readme for date events --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1c3888d..b77a430 100644 --- a/README.md +++ b/README.md @@ -11,21 +11,23 @@ The only other accepted format is an empty string, meaning the date has not been **Important:** Make sure to increment the id -```json +```ts [ { - "title": "Title of the event", - "description": "Description of the event", - "date": "04/22", - "location": "Engineering building", - "id": 0 + title: 'Title of the event', + description: 'Description of the event', + date: new Date('2025-01-22T17:00:00'), + location: 'The ideas hub (second floor of the engineering building)', + weekly: true, + endDate: new Date(semesterEnd) }, { - "title": "Title of the event 2", - "description": "Description of the event 2", - "date": "04/23", - "location": "Engineering building", - "id": 1 + title: 'Title of the event 2', + description: 'Description of the event 2', + date: new Date('2025-01-22T14:00:00'), + location: 'The ideas hub (second floor of the engineering building)', + weekly: true, + endDate: new Date(semesterEnd) } ] ```