From a70ded472b619465aa25c42df16f07974bf9a7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Thu, 14 Nov 2024 19:17:44 -0300 Subject: [PATCH] Corrige reduce da lista de eventos --- .../src/components/Blocks/Calendario/View.jsx | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx b/frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx index 0a9a81e..5fca900 100644 --- a/frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx +++ b/frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx @@ -5,30 +5,28 @@ import { parseDate } from '@internationalized/date'; import withQuerystringResults from './withQuerystringResults'; const groupByDate = (items) => { - return items - .reduce((map, obj) => { - if (!obj.start) { - return null; - } + return items.reduce((map, obj) => { + if (!obj.start) { + return map; + } - let start = obj.start ? parseDate(obj.start.slice(0, 10)) : null; - const end = obj.end ? parseDate(obj.end.slice(0, 10)) : start; + let start = obj.start ? parseDate(obj.start.slice(0, 10)) : null; + const end = obj.end ? parseDate(obj.end.slice(0, 10)) : start; - while (start < end) { - const key = start.toString(); + while (start < end) { + const key = start.toString(); - if (key) { - if (map[key] === undefined) { - map[key] = []; - } - map[key].push(obj); + if (key) { + if (map[key] === undefined) { + map[key] = []; } - - start = start.add({ days: 1 }); + map[key].push(obj); } - return map; - }, {}) - .filter((item) => item !== null); + + start = start.add({ days: 1 }); + } + return map; + }, {}); }; const CalendarioBlockView = withQuerystringResults((props) => {