Skip to content

Commit b541b25

Browse files
committed
Refactor and format
1 parent 01166d3 commit b541b25

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/app/(main)/community/events/events-scrollview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function EventsScrollview({
1212
<div
1313
className={clsx(
1414
"xs:nextra-scrollbar relative -mx-6 grid w-fit max-w-full grid-flow-col grid-rows-2 gap-2 overflow-auto p-6 scrollview-fade-x-16 scrollview-fade has-[>:only-child]:grid-rows-1 max-sm:min-w-[100vw] sm:-mx-1 sm:px-1 lg:gap-4",
15-
15+
1616
className,
1717
)}
1818
>

src/app/(main)/resources/[category]/page.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default async function CategoryPage({ params }: { params: PageParams }) {
5959

6060
if (sections.length === 0) sections = grouped.map(group => group.kind)
6161

62-
sections = await ensureFutureEvents(sections, category)
62+
sections = await removeEventsSectionWithoutFutureEvents(sections, category)
6363

6464
const activePath: Item[] = [
6565
{
@@ -128,20 +128,25 @@ export default async function CategoryPage({ params }: { params: PageParams }) {
128128
/**
129129
* if there is no events in the future, we remove the section from the TOC
130130
*/
131-
async function ensureFutureEvents(sections: Kind[], category: Topic) {
132-
if (!sections.includes("event")) return sections
133-
134-
const events = await loadWorkingGroupMeetings()
135-
const predicate = categoriesConfig[category].sections.event?.predicate
136-
137-
if (predicate) {
138-
const futureEvents = events
139-
.filter(predicate)
140-
.filter(event => new Date(event.start).getTime() >= Date.now())
141-
142-
if (futureEvents.length === 0)
143-
return sections.filter(section => section !== "event")
131+
async function removeEventsSectionWithoutFutureEvents(
132+
sections: Kind[],
133+
category: Topic,
134+
) {
135+
if (sections.includes("event")) {
136+
const events = await loadWorkingGroupMeetings()
137+
const predicate = categoriesConfig[category].sections.event?.predicate
138+
139+
if (predicate) {
140+
const futureEvents = events
141+
.filter(predicate)
142+
.filter(event => new Date(event.start).getTime() >= Date.now())
143+
144+
if (futureEvents.length === 0)
145+
return sections.filter(section => section !== "event")
146+
}
144147
}
148+
149+
return sections
145150
}
146151

147152
function uniqueByTitle(resources: ResourceMetadata[]) {

0 commit comments

Comments
 (0)