Skip to content

Commit

Permalink
feat: move Invalid Date to end
Browse files Browse the repository at this point in the history
  • Loading branch information
KieSun committed Nov 4, 2024
1 parent 26e7435 commit 8aeb9a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,18 @@ const Home: React.FC = () => {

const eventsData = useMemo(() => {
const data = groupEventsByMonth(events);
const keys = Object.keys(data).sort((a, b) => {
let keys = Object.keys(data).sort((a, b) => {
const dateA = dayjs(a, 'MMMM YYYY');
const dateB = dayjs(b, 'MMMM YYYY');
return dateA.isBefore(dateB) ? 1 : -1;
});

const invalidDateIndex = keys.findIndex((key) => key === 'Invalid Date');
if (invalidDateIndex !== -1) {
const invalidDate = keys.splice(invalidDateIndex, 1)[0];
keys.push(invalidDate);
}

const groupedEvents: { [key: string]: Event[] } = {};
keys.forEach((key) => {
const value = data[key];
Expand Down

0 comments on commit 8aeb9a8

Please sign in to comment.