Skip to content

Commit

Permalink
Corrige reduce da lista de eventos
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Nov 14, 2024
1 parent ad3bcd1 commit a70ded4
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit a70ded4

Please sign in to comment.