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) => {