Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurring event 1351 bug fix #1395

Merged
merged 3 commits into from
May 27, 2023

Conversation

vanessavun
Copy link
Member

Fixes #1351

What changes did you make and why did you make them?

  • Refactored the addDurationToTime.js file which had 8 hardcoded switch statements that did not include a statement for any "0.5" inputted time. The file now has one line of the same formula and any duration will return a new Date object. Any invalid inputs will result an Error.
  • Added an additional conditional statement to include blank descriptions when editing meeting details. If it previously had a description and the user wants to leave it blank, the blank description will be carried over with the update.
  • Added a Jest test file for the addDurationToTime.js file to ensure that the formula works.

Screenshots of Proposed Changes Of The Website (if any, please do not screenshot code changes)

Visuals before and after for blank descriptions

blank

Visuals before and after for half-hour meetings

halfhour

@vanessavun vanessavun requested a review from MicahBear May 26, 2023 00:01
@github-actions
Copy link

Want to review this pull request? Take a look at this documentation for a step by step guide!

From your project repository, check out a new branch and test the changes.

git checkout -b vanessavun-recurring-event-1351 development
git pull https://github.com/vanessavun/VRMS.git recurring-event-1351

Copy link
Contributor

@MattPereira MattPereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @vanessavun 🎉

Users will finally be able to create and update meeting times with a duration of 30 minutes!

Loved that refactor of the gross switch statement and well done going above and beyond with the testing 💪

Feel free to merge whenever you like!

@@ -39,7 +39,8 @@ const EditMeetingTimes = ({
};
}

if (values.description) {
//if there is a description or a blank description
if (values.description || !values.description) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help us understand why the if statement is necessary here? Wouldn't this conditional just always evaluate to true ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it needs to always be true so the description is carried over with the update. When there is a blank description, the original conditional, if (values.description), will be falsy so the blank description doesn't get updated. I guess there is a better way to rewrite this file in which we do a catch all to update all the values like:
theUpdatedEvent = { ...theUpdatedEvent, **value name: updated value** };

Comment on lines +2 to +8
// Create the endTime by adding seconds based on the selected duration to the timestamp and converting it back to date
if(startTimeDate && duration){
return new Date(startTimeDate.getTime() + (Number(duration)*3600000))
} else {
throw new Error('Error: Cannot calculate endTime.')
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plang-psm
Copy link
Member

Will take a peak at this tomorrow but it looks super clean from a quick skim!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 30+ lines of code of hard-coded cases 💯

@Spiteless
Copy link
Member

Seriously great work figuring this one out. Well done :)

Copy link
Member

@MicahBear MicahBear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a test case for this is a great addition.

Copy link
Member

@plang-psm plang-psm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanessavun vanessavun merged commit 550a37c into hackforla:development May 27, 2023
5 checks passed
@vanessavun vanessavun deleted the recurring-event-1351 branch May 27, 2023 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bugs when updating a recurring event
5 participants