Skip to content

Commit

Permalink
feat: aggiunto supporto per range di date per i seminari
Browse files Browse the repository at this point in the history
  • Loading branch information
aziis98 committed Nov 10, 2023
1 parent 7b13a3d commit fc223e8
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/element.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ let cachedSeminars = null

// FIX: Per ora scarichiamo tutti i seminari con l'endpoint "/public/seminars" e li filtriamo lato client per categoria
const getSeminarCategory = async ({ endpoint, category, from, to }) => {
if (!cachedSeminars) {
const req = await fetch(endpoint + '/api/v0/public/seminars', { mode: 'cors' })
const events = await req.json()

cachedSeminars = events.map(seminar => ({
const req = await fetch(endpoint + `/api/v0/public/seminars?from=${from}&to=${to}`, { mode: 'cors' })
const events = await req.json()
return events
.map(seminar => ({
title: seminar.title,
start: seminar.startDatetime,
end: new Date(new Date(seminar.startDatetime).getTime() + seminar.duration * 1000 * 60),
Expand All @@ -132,9 +131,7 @@ const getSeminarCategory = async ({ endpoint, category, from, to }) => {
...seminar,
},
}))
}

return cachedSeminars.filter(event => event.extendedProps?.category?._id === category)
.filter(event => event.extendedProps?.category?._id === category)
}

export const DMCalendar = ({ endpoint, includes, queryEvents }) => {
Expand Down

0 comments on commit fc223e8

Please sign in to comment.