-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: feature-be-google-calendar-freebusy-api
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,25 +4,24 @@ const { google } = require("googleapis"); | |||||||||
|
||||||||||
// @desc FreeBusy | ||||||||||
// @route GET /freebusy?date=143213434&meetingTypeID=df34234fgdg235 | ||||||||||
availabilitiesRouter.get("/freebusy", (request, response) => { | ||||||||||
// request.query.meetingTypeID | ||||||||||
// request.query.date // must be in datetime format | ||||||||||
availabilitiesRouter.get("/freebusy", async (request, response) => { | ||||||||||
const { day, month, year } = request.query; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this has to be
Suggested change
in order to reassignment of duration = Number(duration)
user = await User.findbyId(user) in the suggestions below: |
||||||||||
const duration = Number(request.query.duration); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
const user = await User.findById(request.query.user); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
const oauth2Client = new google.auth.OAuth2({ | ||||||||||
clientID: process.env.GOOGLE_CLIENT_ID, | ||||||||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET, | ||||||||||
callbackURL: "/api/auth/google/callback" | ||||||||||
}); | ||||||||||
|
||||||||||
oauth2Client.credentials = { | ||||||||||
access_token: request.user.accessToken, | ||||||||||
refresh_token: request.user.refreshToken | ||||||||||
access_token: user.accessToken, | ||||||||||
refresh_token: user.refreshToken | ||||||||||
}; | ||||||||||
|
||||||||||
const availStartTime = new Date(2020, 11, 12, 9, 0, 0, 0); | ||||||||||
const availEndTime = new Date(2020, 11, 12, 17, 0, 0, 0); | ||||||||||
|
||||||||||
// Duration in minutes | ||||||||||
const duration = 60; | ||||||||||
const availStartTime = new Date(year, month, day, 9, 0, 0, 0); | ||||||||||
const availEndTime = new Date(year, month, day, 17, 0, 0, 0); | ||||||||||
|
||||||||||
|
||||||||||
const calendar = google.calendar({ version: "v3", auth: oauth2Client }); | ||||||||||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.