Skip to content

Commit

Permalink
Merge branch 'development' into dependabot/npm_and_yarn/client/browse…
Browse files Browse the repository at this point in the history
…rify-sign-4.2.2
  • Loading branch information
trillium authored Dec 7, 2023
2 parents 3ce33bf + 038c431 commit d583b86
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 51 deletions.
6 changes: 6 additions & 0 deletions backend/workers/closeCheckins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
78 changes: 42 additions & 36 deletions backend/workers/createRecurringEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
50 changes: 48 additions & 2 deletions client/src/components/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ export const simpleInputs = [
name: 'name',
type: 'text',
placeholder: 'Enter project name',
disabled: false
},
{
label: 'Project Description',
name: 'description',
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',
Expand All @@ -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
},
];
];

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
}
]
9 changes: 7 additions & 2 deletions client/src/components/manageProjects/editProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -92,7 +97,7 @@ const EditProject = ({
/>
</div>
<ProjectForm
arr={simpleInputs}
arr={[...simpleInputs, ...additionalInputsForEdit]}
formData={formData}
projectToEdit={projectToEdit}
isEdit={true}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/parts/form/ValidatedTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function ValidatedTextField({
type={input.type}
placeholder={input.placeholder}
helperText={`${errors[input.name]?.message || ' '}`}
disabled={isEdit ? !editMode : undefined} // handles edit mode for EditProjcet form
disabled={isEdit ? !editMode || input.disabled : undefined} // handles edit mode for EditProjcet form
/>
</Box>
);
Expand Down
24 changes: 14 additions & 10 deletions client/src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Home = () => {
<h2>Volunteer Relationship Management System</h2>
</div>

{events && events.length >= 1 && (
{events && events.length > 0 ? (
<div className="meeting-select-container">
<form
className="form-select-meeting"
Expand Down Expand Up @@ -85,21 +85,25 @@ const Home = () => {
</div>
</form>
</div>
)}
):(

<div className="home-buttons">
{/* If no events with checkInReady: true */}
{events.length === 0 && <CreateNewProfileButton />}

{/* If no meetings available*/}
<h4>No meetings available</h4>
<CreateNewProfileButton />
</div>
)}
{/* If any events with checkInReady: true */}
{events.length > 0 && (
<CheckInButtons
disabled={selectedEvent === ''}
event={selectedEvent}
events={events}
/>
<div className="home-buttons">
<CheckInButtons
disabled={selectedEvent === ''}
event={selectedEvent}
events={events}
/>
</div>
)}
</div>
</div>
);
};
Expand Down

0 comments on commit d583b86

Please sign in to comment.