1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-03-17 22:12:43 +00:00
bramw_baserow/premium/web-frontend/modules/baserow_premium/services/views/calendar.js
2023-05-11 07:42:59 +00:00

50 lines
1.2 KiB
JavaScript

import addPublicAuthTokenHeader from '@baserow/modules/database/utils/publicView'
export default (client) => {
return {
fetchRows({
calendarId,
limit = 100,
offset = null,
includeFieldOptions = false,
fromTimestamp = null,
toTimestamp = null,
userTimeZone = null,
publicUrl = false,
publicAuthToken = null,
}) {
const include = []
const params = new URLSearchParams()
params.append('limit', limit)
if (offset !== null) {
params.append('offset', offset)
}
if (includeFieldOptions) {
include.push('field_options')
}
if (include.length > 0) {
params.append('include', include.join(','))
}
params.append('from_timestamp', fromTimestamp.toISOString())
params.append('to_timestamp', toTimestamp.toISOString())
if (userTimeZone) {
params.append('user_timezone', userTimeZone)
}
const config = { params }
if (publicAuthToken) {
addPublicAuthTokenHeader(config, publicAuthToken)
}
const url = publicUrl ? 'public/rows/' : ''
return client.get(`/database/views/calendar/${calendarId}/${url}`, config)
},
}
}