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

Render Availabilities as TimeSlots in Scheduler View from FreeBusy API #71

Open
wants to merge 3 commits into
base: feature-be-google-calendar-freebusy-api
Choose a base branch
from

Conversation

singhmi4
Copy link
Collaborator

@singhmi4 singhmi4 commented Dec 13, 2020

What it Does:

  • upon request to back-end freebusy controller, the front-end renders a list of available timeslot buttons or a "no availability" message depending on if there are available timeslots

When there is Availability:
image

When There Isn't:
image

  • selected day on calendar defaults to tomorrows date upon render

What to Look For:

  • DRY code
  • efficient code sequence of steps to retrieve and display timeslots

What To Avoid

  • access tokens not being refreshed after 1 hr (will look at this in another PR)

…endering timeslots upon change in date

* mapped the returned array to render in the timeslot selection area of the scheduler or returns "not available message" if there is no availability
* request query params takes in day, month, year, duration, and user for freebusy query to work correctly
@singhmi4 singhmi4 requested a review from bonnieli December 13, 2020 20:36
@singhmi4 singhmi4 linked an issue Dec 13, 2020 that may be closed by this pull request
const [selectedDay, setSelectedDay] = useState(null);
const [selectedDay, setSelectedDay] = useState({
day: tomorrowsDate.getDate(),
month: tomorrowsDate.getMonth() + 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

how come this needs to be + 1?

Copy link
Contributor

Choose a reason for hiding this comment

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

if it's due to indices, maybes make a note of this in a comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, regular JavaScript indexes the months starting with 0 whereas this library indexes it with 0, so December in the .getMonth() method returns 11, but to display it as December for this library, it should be 12 which is where the ...+ 1 adjusts it to.

// request.query.meetingTypeID
// request.query.date // must be in datetime format
availabilitiesRouter.get("/freebusy", async (request, response) => {
const { day, month, year } = request.query;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { day, month, year } = request.query;
const { day, month, year, duration, user } = request.query;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this has to be

Suggested change
const { day, month, year } = request.query;
let{ day, month, year, duration, user } = request.query;

in order to reassignment of

duration = Number(duration)
user = await User.findbyId(user)

in the suggestions below:

// request.query.date // must be in datetime format
availabilitiesRouter.get("/freebusy", async (request, response) => {
const { day, month, year } = request.query;
const duration = Number(request.query.duration);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const duration = Number(request.query.duration);
const duration = Number(duration);

availabilitiesRouter.get("/freebusy", async (request, response) => {
const { day, month, year } = request.query;
const duration = Number(request.query.duration);
const user = await User.findById(request.query.user);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const user = await User.findById(request.query.user);
const user = await User.findById(user);

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.

Integrate with click on calendar
2 participants