diff --git a/backend/workers/closeCheckins.js b/backend/workers/closeCheckins.js index d2c64d20..9d04cd7d 100644 --- a/backend/workers/closeCheckins.js +++ b/backend/workers/closeCheckins.js @@ -28,6 +28,12 @@ module.exports = (cron, fetch) => { if (events && events.length > 0) { const sortedEvents = events.filter(event => { + if (!event.date) { + // handle if event date is null/undefined + // false meaning don't include in sortedEvents + return false + } + const currentTimeISO = new Date().toISOString(); const threeHoursFromStartTime = new Date(event.date).getTime() + 10800000; const threeHoursISO = new Date(threeHoursFromStartTime).toISOString(); diff --git a/backend/workers/createRecurringEvents.js b/backend/workers/createRecurringEvents.js index a1228c36..3eef5fbf 100644 --- a/backend/workers/createRecurringEvents.js +++ b/backend/workers/createRecurringEvents.js @@ -60,52 +60,58 @@ module.exports = (cron, fetch) => { // forEach function with async/await. for (filteredEvent of filteredEvents) { const eventExists = await checkIfEventExists(filteredEvent.name); - // console.log('Event exists? ', eventExists); - const eventDate = new Date(filteredEvent.date); if (eventExists) { - console.log("Not going to run ceateEvent"); + //Do nothing + console.log("➖ Not going to run ceateEvent"); } else { // Create new event - const hours = eventDate.getHours(); - const minutes = eventDate.getMinutes(); - const seconds = eventDate.getSeconds(); - const milliseconds = eventDate.getMilliseconds(); - - const yearToday = TODAY_DATE.getFullYear(); - const monthToday = TODAY_DATE.getMonth(); - const dateToday = TODAY_DATE.getDate(); - - const newEventDate = new Date(yearToday, monthToday, dateToday, hours, minutes, seconds, milliseconds); - - const newEndTime = new Date(yearToday, monthToday, dateToday, hours + filteredEvent.hours, minutes, seconds, milliseconds) - - const eventToCreate = { - name: filteredEvent.name && filteredEvent.name, - hacknight: filteredEvent.hacknight && filteredEvent.hacknight, - eventType: filteredEvent.eventType && filteredEvent.eventType, - description: filteredEvent.eventDescription && filteredEvent.eventDescription, - project: filteredEvent.project && filteredEvent.project, - date: filteredEvent.date && newEventDate, - startTime: filteredEvent.startTime && newEventDate, - endTime: filteredEvent.endTime && newEndTime, - hours: filteredEvent.hours && filteredEvent.hours - } - if (filteredEvent.hasOwnProperty("location")) { - eventToCreate.location = { - city: filteredEvent.location.city ? filteredEvent.location.city : 'REMOTE', - state: filteredEvent.location.state ? filteredEvent.location.state : 'REMOTE', - country: filteredEvent.location.country ? filteredEvent.location.country : 'REMOTE' - }; - } - + const eventToCreate = generateEventData(filteredEvent); + const created = await createEvent(eventToCreate); - console.log(created); + console.log("➕", created); }; }; }; }; + function generateEventData(eventData, TODAY_DATE = new Date()) { + const eventDate = new Date(eventData.startTime); + // Create new event + const hours = eventDate.getHours(); + const minutes = eventDate.getMinutes(); + const seconds = eventDate.getSeconds(); + const milliseconds = eventDate.getMilliseconds(); + + const yearToday = TODAY_DATE.getFullYear(); + const monthToday = TODAY_DATE.getMonth(); + const dateToday = TODAY_DATE.getDate(); + + const newEventDate = new Date(yearToday, monthToday, dateToday, hours, minutes, seconds, milliseconds); + + const newEndTime = new Date(yearToday, monthToday, dateToday, hours + filteredEvent.hours, minutes, seconds, milliseconds) + + const eventToCreate = { + name: eventData.name && eventData.name, + hacknight: eventData.hacknight && eventData.hacknight, + eventType: eventData.eventType && eventData.eventType, + description: eventData.eventDescription && eventData.eventDescription, + project: eventData.project && eventData.project, + date: eventData.date && newEventDate, + startTime: eventData.startTime && newEventDate, + endTime: eventData.endTime && newEndTime, + hours: eventData.hours && eventData.hours + } + if (eventData.hasOwnProperty("location")) { + eventToCreate.location = { + city: eventData.location.city ? eventData.location.city : 'REMOTE', + state: eventData.location.state ? eventData.location.state : 'REMOTE', + country: eventData.location.country ? eventData.location.country : 'REMOTE' + }; + } + return eventToCreate + }; + async function checkIfEventExists(eventName) { const events = EVENTS; // const today = new Date(); diff --git a/client/src/components/data.js b/client/src/components/data.js index c5e7a27b..ca37540b 100644 --- a/client/src/components/data.js +++ b/client/src/components/data.js @@ -5,6 +5,7 @@ export const simpleInputs = [ name: 'name', type: 'text', placeholder: 'Enter project name', + disabled: false }, { label: 'Project Description', @@ -12,7 +13,8 @@ export const simpleInputs = [ type: 'textarea', placeholder: 'Enter project description', value: /^[a-zA-Z0-9].{0,250}$/, - errorMessage: 'Description must start with alphanumeric characters, 250 char limit' + errorMessage: 'Description must start with alphanumeric characters, 250 char limit', + disabled: false }, { label: 'Location', @@ -23,35 +25,79 @@ export const simpleInputs = [ errorMessage: 'Please enter a valid Zoom URL', addressValue: '', addressError: 'Invalid address', + disabled: false }, { label: 'GitHub Identifier', name: 'githubIdentifier', type: 'text', placeholder: 'Enter GitHub identifier', + disabled: false }, { label: 'GitHub URL', name: 'githubUrl', type: 'text', placeholder: 'htttps://github.com/', + disabled: false }, { label: 'Slack Channel Link', name: 'slackUrl', type: 'text', placeholder: 'htttps://slack.com/', + disabled: false }, { label: 'Google Drive URL', name: 'googleDriveUrl', type: 'text', placeholder: 'htttps://drive.google.com/', + disabled: false }, { label: 'HFLA Website URL', name: 'hflaWebsiteUrl', type: 'text', placeholder: 'htttps://hackforla.org/projects/', + disabled: false }, -]; \ No newline at end of file +]; + +export const additionalInputsForEdit = [ + { + label: 'Partners', + name: 'partners', + type: 'text', + placeholder: 'partners', + disabled: false + }, + { + label: 'Managed by Users', + name: 'managedByUsers', + type: 'text', + placeholder: 'Managed by Users', + disabled: false + }, + { + label: 'Project Status', + name: 'projectStatus', + type: 'text', + placeholder: 'Project Status', + disabled: false + }, + { + label: 'Google Drive ID', + name: 'googleDriveId', + type: 'text', + placeholder: 'htttps://drive.google.com/', + disabled: false + }, + { + label: 'Created Date', + name: 'createdDate', + type: 'text', + placeholder: 'Created Date', + disabled: true + } +] \ No newline at end of file diff --git a/client/src/components/manageProjects/editProject.js b/client/src/components/manageProjects/editProject.js index 399bc3ab..886d0a22 100644 --- a/client/src/components/manageProjects/editProject.js +++ b/client/src/components/manageProjects/editProject.js @@ -3,7 +3,7 @@ import EditMeetingTimes from './editMeetingTimes'; import CreateNewEvent from './createNewEvent'; import readableEvent from './utilities/readableEvent'; import ProjectForm from '../ProjectForm'; -import { simpleInputs } from '../data'; +import { simpleInputs, additionalInputsForEdit } from '../data'; import TitledBox from '../parts/boxes/TitledBox'; import { ReactComponent as EditIcon } from '../../svg/Icon_Edit.svg'; @@ -31,6 +31,11 @@ const EditProject = ({ slackUrl: projectToEdit.slackUrl, googleDriveUrl: projectToEdit.googleDriveUrl, hflaWebsiteUrl: projectToEdit.hflaWebsiteUrl, + partners: projectToEdit.partners, + managedByUsers: projectToEdit.managedByUsers, + projectStatus: projectToEdit.projectStatus, + googleDriveId: projectToEdit.googleDriveId, + createdDate: new Date(projectToEdit.createdDate) }); // eslint-disable-next-line no-unused-vars @@ -92,7 +97,7 @@ const EditProject = ({ /> ); diff --git a/client/src/pages/Home.js b/client/src/pages/Home.js index e64a6f4b..48e1df04 100644 --- a/client/src/pages/Home.js +++ b/client/src/pages/Home.js @@ -49,7 +49,7 @@ const Home = () => {

Volunteer Relationship Management System

- {events && events.length >= 1 && ( + {events && events.length > 0 ? (
{
- )} + ):(
{/* If no events with checkInReady: true */} - {events.length === 0 && } - + {/* If no meetings available*/} +

No meetings available

+ +
+ )} {/* If any events with checkInReady: true */} {events.length > 0 && ( - +
+ +
)} - ); };