Skip to content

Commit

Permalink
fix: ordering by closing date
Browse files Browse the repository at this point in the history
  • Loading branch information
scraly committed Jan 7, 2025
1 parent 63ea50c commit 65b56a8
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions page/src/components/CfpView/CfpView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Clock, Link, CalendarClock } from 'lucide-react';

import {useYearEvents} from 'app.hooks';
import {getMonthName, getMonthNames} from 'utils';
import ShortDate from 'components/ShortDate/ShortDate';


const CfpView = () => {
let events = useYearEvents();
Expand All @@ -18,23 +20,25 @@ const CfpView = () => {
events = events.filter(e => e.cfp && new Date(e.cfp.untilDate + 24 * 60 * 60 * 1000) > new Date());

const eventsByMonth = events.reduce((acc, cur) => {
const currentMonth = getMonthName(new Date(cur.date[0]).getMonth());
if (!acc[currentMonth]) {
acc[currentMonth] = [];
}
acc[currentMonth].push(cur);
if (cur.date.length > 1) {
const nextMonth = getMonthName(new Date(cur.date[1]).getMonth());
if (currentMonth !== nextMonth) {
if (!acc[nextMonth]) {
acc[nextMonth] = [];
}
acc[nextMonth].push(cur);
}
let monthKey;
monthKey = getMonthName(new Date(cur.cfp.untilDate).getMonth());
if (!acc[monthKey]) {
acc[monthKey] = [];
}
return acc;
}, {});
acc[monthKey].push(cur);

return acc;
}, {});

// Get the month names in the correct order based on sort type
const monthOrder = Object.keys(eventsByMonth).sort((a, b) => {
const monthA = getMonthNames().indexOf(a);
const monthB = getMonthNames().indexOf(b);
return monthA - monthB;
});


//TODO: Fix: Order in closing date for every months!
return (
<div className="cfpView">
{getMonthNames()
Expand All @@ -49,8 +53,9 @@ const CfpView = () => {

<div className="content">
<b>{e.name} {e.hyperlink ? <a href={e.hyperlink} target="_blank"><Link /></a> : ''}</b>
<ShortDate dates={e.date} />

<span><Clock color="green" /> Until {e.cfp.until} </span>
<span><Clock color="green" /> Until {e.cfp.until} </span>

<span>{e.location}</span>

Expand All @@ -66,8 +71,11 @@ const CfpView = () => {
</div>
</React.Fragment>
))}


</div>
);

};

export default CfpView;

0 comments on commit 65b56a8

Please sign in to comment.