From cde4084cd977ab6877ec4dcb68b5b72363a21b63 Mon Sep 17 00:00:00 2001 From: Emme Menezes Date: Mon, 4 Nov 2024 20:37:03 -0300 Subject: [PATCH] =?UTF-8?q?Extende=20exibi=C3=A7=C3=A3o=20para=20eventos?= =?UTF-8?q?=20de=20v=C3=A1rios=20dias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Blocks/Calendario/View.jsx | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 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 d7aedbc..43ffd77 100644 --- a/frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx +++ b/frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx @@ -6,20 +6,33 @@ import withQuerystringResults from './withQuerystringResults'; const groupByDate = (items) => { return items.reduce((map, obj) => { - const key = obj.start ? parseDate(obj.start.slice(0, 10)).toString() : null; - if (key) { - if (map[key] === undefined) { - map[key] = []; + if (!obj.start) return; + + 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(); + + if (key) { + if (map[key] === undefined) { + map[key] = []; + } + map[key].push(obj); } - map[key].push(obj); + + start = start.add({days: 1}) } return map; + + }, {}); }; const CalendarioBlockView = withQuerystringResults((props) => { const { data, isEditMode, path, pathname, className, listingItems } = props; const items = listingItems ? groupByDate(listingItems) : {}; + return (