-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpage.tsx
More file actions
75 lines (67 loc) · 1.92 KB
/
page.tsx
File metadata and controls
75 lines (67 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Fragment } from 'react';
import ClubCard from '@/components/club-card';
import DefaultLayout from '@/components/default-layout';
import api from '@/utils/api-actions';
export const metadata = {
title: 'Clubs',
description:
'Check out all the official/unofficial clubs and societies of NIT-KKR',
};
const clubCategories = [
'Cultural Club',
'Technical Club',
'Technical Society',
'Magazine',
'Crew',
'Committee',
] as const;
const getCategorisedClubs = (
category: ClubCategory,
clubs: Array<ClubBasic>
) => {
const filteredClubs = clubs.filter((club) => club.category === category);
if (filteredClubs.length === 0)
return <p className='text-red-400'>No club found for the {category} category</p>;
return filteredClubs.map((club, index) => (
<li key={index}>
<ClubCard club={club} />
</li>
));
};
export default async function ClubsPage() {
const clubs: Array<ClubBasic> = await api.GET('/clubs');
return (
<DefaultLayout
title="Clubs"
description="An overview all the clubs and societies of NIT-KKR"
prompt={
<>
<p className="inline-flex">
The cards of only the following clubs are enabled:
</p>
<ul>
{clubs.map((club) => {
if (club.short_description === 'Lorem Ipsum') {
return <></>;
} else {
return <li>{club.short_name}</li>;
}
})}
</ul>
</>
}
alert={true}
>
{clubCategories.map((category: ClubCategory, categoryIndex) => {
return (
<Fragment key={categoryIndex}>
<h2 className='text-palette-700 dark:text-palette-100'>{category}</h2>
<ol className="flex flex-row flex-wrap gap-2 sm:gap-4 mb-8">
{getCategorisedClubs(category, clubs)}
</ol>
</Fragment>
);
})}
</DefaultLayout>
);
}