From fc223e8aa84b52b1b7d6f8b22255560589d7eb42 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Fri, 10 Nov 2023 15:20:35 +0100 Subject: [PATCH] feat: aggiunto supporto per range di date per i seminari --- src/element.jsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/element.jsx b/src/element.jsx index 6b329f4..36049e8 100644 --- a/src/element.jsx +++ b/src/element.jsx @@ -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), @@ -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 }) => {