Agusti
06/14/2022, 10:52 PM<https://api.cal.com/v1/availability?apiKey=YOUR_API_KEY_HERE&dateFrom=2022-06-14&dateTo=2022-06-17&userId=1>
Postman docs: https://documenter.getpostman.com/view/20666831/Uz5ArJni#8333a1d5-9df6-4134-b654-8ede7becafb5Varun Krishnamurthy
06/14/2022, 10:53 PMAgusti
06/14/2022, 10:55 PM// 20220615003519
// <https://api.cal.com/v1/availability?apiKey=,,,&dateFrom=2022-06-14&dateTo=2022-06-17&userId=1>
{
"busy": [
{
"start": "2022-06-14T13:00:00.000Z",
"end": "2022-06-14T13:15:00.000Z"
},
{
"start": "2022-06-14T14:00:00.000Z",
"end": "2022-06-14T14:30:00.000Z"
},
{
"start": "2022-06-15T09:30:00.000Z",
"end": "2022-06-15T10:00:00.000Z"
},
{
"start": "2022-06-14T13:30:00.000Z",
"end": "2022-06-14T13:45:00.000Z"
},
{
"start": "2022-06-14T09:30:00.000Z",
"end": "2022-06-14T10:00:00.000Z"
},
{
"start": "2022-06-15T10:00:00.000Z",
"end": "2022-06-15T10:15:00.000Z"
},
{
"start": "2022-06-14T09:30:00.000Z",
"end": "2022-06-14T10:00:00.000Z"
},
{
"start": "2022-06-14T13:00:00.000Z",
"end": "2022-06-14T13:15:00.000Z"
},
{
"start": "2022-06-14T13:30:00.000Z",
"end": "2022-06-14T13:45:00.000Z"
},
{
"start": "2022-06-14T14:00:00.000Z",
"end": "2022-06-14T14:30:00.000Z"
},
{
"start": "2022-06-14T16:30:00.000Z",
"end": "2022-06-14T17:00:00.000Z"
},
{
"start": "2022-06-15T09:00:00.000Z",
"end": "2022-06-15T10:15:00.000Z"
},
{
"start": "2022-06-15T18:00:00.000Z",
"end": "2022-06-15T18:15:00.000Z"
},
{
"start": "2022-06-16T09:00:00.000Z",
"end": "2022-06-16T09:30:00.000Z"
},
{
"start": "2022-06-15T14:15:00.000Z",
"end": "2022-06-15T15:15:00.000Z"
},
{
"start": "2022-06-15T23:00:00.000Z",
"end": "2022-06-16T23:00:00.000Z"
}
],
"timeZone": "GMT",
"workingHours": [
{
"days": [
1,
2,
3,
4,
5
],
"startTime": 540,
"endTime": 1020
}
]
}
Varun Krishnamurthy
06/14/2022, 11:00 PMzomars
06/14/2022, 11:01 PMVarun Krishnamurthy
06/14/2022, 11:13 PMAgusti
06/14/2022, 11:23 PM<http://cal.com/apps/web/lib/hooks/useSlots.ts|cal.com/apps/web/lib/hooks/useSlots.ts>
from line 169
users.map((user) => fetch(`/api/availability/${user.username}?${query}`).then(handleAvailableSlots))
Varun Krishnamurthy
06/14/2022, 11:25 PMAgusti
06/14/2022, 11:25 PMAgusti
06/14/2022, 11:26 PMAgusti
06/14/2022, 11:26 PMVarun Krishnamurthy
06/14/2022, 11:27 PMstartTime
and endTime
times in the workingHours
object?
"startTime": 540,
"endTime": 1020
Agusti
06/14/2022, 11:28 PMAgusti
06/14/2022, 11:29 PMVarun Krishnamurthy
06/14/2022, 11:29 PMAgusti
06/14/2022, 11:29 PMAgusti
06/14/2022, 11:29 PMAgusti
06/14/2022, 11:30 PMAgusti
06/14/2022, 11:30 PMVarun Krishnamurthy
06/14/2022, 11:35 PMVikram
06/14/2022, 11:37 PMVikram
06/14/2022, 11:40 PMevent-types
api and generates "available" times using the availability api. I have something super hacky that is hardcoded to work with a single event but I can try to generalize it and make it availableVarun Krishnamurthy
06/14/2022, 11:55 PMVikram
06/15/2022, 12:02 AMdate.setHours(workingHours.startTime)
while (date.getHours() < workingHours.endTime) {
const startDateTime = new Date(date);
date.setHours(date.getHours() + 1)
const endDateTime = date;
const slotTaken = availabilties?.busy?.some(busy => {
return dateIsBetween(startDateTime, new Date(busy.start), new Date(busy.end)) || dateIsBetween(endDateTime, new Date(busy.start), new Date(busy.end));
})
if (!slotTaken) {
const slot = {
name: `${startDateTime.toLocaleTimeString('en-us', timeFormatOptions)} to ${endDateTime.toLocaleTimeString('en-us', timeFormatOptions)}`,
lengthInMinutes: 60,
startTime: startDateTime.toISOString(),
endTime: endDateTime.toISOString(),
} slots.push(slot);
}
}
Vikram
06/15/2022, 12:03 AMVarun Krishnamurthy
06/15/2022, 12:07 AMVikram
06/15/2022, 12:11 AMVarun Krishnamurthy
06/15/2022, 12:14 AMVikram
06/15/2022, 12:15 AMVikram
06/15/2022, 12:15 AMVarun Krishnamurthy
06/15/2022, 12:16 AMzomars
06/15/2022, 2:18 AM