Skip to content

Commit

Permalink
Arrumar reduce do filtro
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemaygi committed Nov 15, 2024
1 parent ffbe3b2 commit 49925f1
Showing 1 changed file with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@ import { parseDate } from '@internationalized/date';
import withQuerystringResults from './withQuerystringResults';

const groupByDate = (items) => {
return Object.values(
items
.reduce((map, obj) => {
if (!obj.start) {
return null;
}

let start = obj.start ? parseDate(obj.start.slice(0, 10)) : null;
const end = obj.end ? parseDate(obj.end.slice(0, 10)) : start;
return items.reduce((map, obj) => {
if (!obj.start) {
return map;
}

while (start < end) {
const key = start.toString();
let start = obj.start ? parseDate(obj.start.slice(0, 10)) : null;
const end = obj.end ? parseDate(obj.end.slice(0, 10)) : start;

if (key) {
if (map[key] === undefined) {
map[key] = [];
}
map[key].push(obj);
}
while (start < end) {
const key = start.toString();

start = start.add({ days: 1 });
if (key) {
if (map[key] === undefined) {
map[key] = [];
}
return map;
}, {})
).filter((item) => item !== null);
map[key].push(obj);
}

start = start.add({ days: 1 });
}
return map;
}, {});
};


Check failure on line 32 in frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.jsx

View workflow job for this annotation

GitHub Actions / frontend / code-analysis

Delete `⏎⏎`

const CalendarioBlockView = withQuerystringResults((props) => {
const { data, isEditMode, path, pathname, className, listingItems } = props;
const items = listingItems ? groupByDate(listingItems) : {};
Expand Down

0 comments on commit 49925f1

Please sign in to comment.