Skip to content

Commit

Permalink
Merge pull request blockful-io#18 from ZuzaluSoftwareBuilder/dev
Browse files Browse the repository at this point in the history
feat: move Invalid Date to end
  • Loading branch information
renoyang66 authored Nov 4, 2024
2 parents 606277d + 8aeb9a8 commit 9d7c789
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 9d7c789

Please sign in to comment.