|
| 1 | +import { fetchContent } from "@/app/actions"; |
| 2 | +import type { PastHackathonWinner } from "@/app/contentfulTypes"; |
1 | 3 | import { Underline } from "@/utils/text-utils";
|
2 | 4 |
|
3 | 5 | import WinnerCard from "./WinnerCard";
|
4 | 6 |
|
5 |
| -export type PastWinner = { |
6 |
| - name: string; |
7 |
| - description: string; |
8 |
| - image: string; |
9 |
| - team: string; |
10 |
| - rank: number; |
11 |
| - award: string; |
12 |
| - link: string; |
13 |
| -}; |
14 |
| - |
15 |
| -const pastWinners: PastWinner[] = [ |
16 |
| - { |
17 |
| - name: "Seed-Pod", |
18 |
| - description: "A seed that grows into a pod.", |
19 |
| - image: "seed-pod.jpg", |
20 |
| - team: "Team 1", |
21 |
| - rank: 1, |
22 |
| - award: "2024 Winner", |
23 |
| - link: "https://www.youtube.com/watch?v=mCdA4bJAGGk&t=19s", |
24 |
| - }, |
25 |
| - { |
26 |
| - name: "Seed-Pod", |
27 |
| - description: "A seed that grows into a pod.", |
28 |
| - image: "seed-pod.jpg", |
29 |
| - team: "Team 2", |
30 |
| - rank: 2, |
31 |
| - award: "2024 Runner Up", |
32 |
| - link: "https://www.youtube.com/watch?v=mCdA4bJAGGk&t=19s", |
33 |
| - }, |
34 |
| - { |
35 |
| - award: "Best Design", |
36 |
| - name: "Seed-Pod", |
37 |
| - description: "A seed that grows into a pod.", |
38 |
| - image: "seed-pod.jpg", |
39 |
| - team: "Team Solo Mid", |
40 |
| - rank: 3, |
41 |
| - link: "https://www.youtube.com/watch?v=mCdA4bJAGGk&t=19s", |
42 |
| - }, |
43 |
| - { |
44 |
| - award: "Best Presentation", |
45 |
| - name: "Seed-Pod", |
46 |
| - description: "A seed that grows into a pod.", |
47 |
| - image: "seed-pod.jpg", |
48 |
| - team: "Awesome team poggers", |
49 |
| - rank: 4, |
50 |
| - link: "https://www.youtube.com/watch?v=mCdA4bJAGGk&t=19s", |
51 |
| - }, |
52 |
| - { |
53 |
| - award: "Best Impact", |
54 |
| - name: "Seed-Pod", |
55 |
| - description: "A seed that grows into a pod.", |
56 |
| - image: "seed-pod.jpg", |
57 |
| - team: "Justin's cool team", |
58 |
| - rank: 5, |
59 |
| - link: "https://www.youtube.com/watch?v=mCdA4bJAGGk&t=19s", |
60 |
| - }, |
61 |
| -] as const; |
62 |
| - |
63 |
| -export default function PastWinners() { |
64 |
| - const sortedPastWinners = pastWinners.reduce( |
65 |
| - (acc, el) => (el.rank % 2 ? [...acc, el] : [el, ...acc]), |
66 |
| - [] as PastWinner[], |
67 |
| - ); |
68 |
| - |
| 7 | +export default async function PastWinners() { |
| 8 | + const data = await fetchContent("pastHackathonWinner"); |
| 9 | + const pastWinners = data.map((el) => el.fields); |
| 10 | + const sortedPastWinners = pastWinners |
| 11 | + .sort((a, b) => (a.teamRanking ?? 0) - (b.teamRanking ?? 0)) |
| 12 | + .reduce( |
| 13 | + (acc, el, index) => (index % 2 ? [...acc, el] : [el, ...acc]), |
| 14 | + [] as PastHackathonWinner[], |
| 15 | + ); |
69 | 16 | return (
|
70 | 17 | <div className=" flex flex-col gap-2 bg-fuzzy-peach lg:p-10 ">
|
71 | 18 | <h1 className="text-nowrap p-4 text-2xl font-extrabold sm:w-1/4">
|
72 | 19 | <Underline noTick>
|
73 |
| - {" Last Year's "} |
| 20 | + {" Previous Year's "} |
74 | 21 | <span className="pl-1 italic text-awesomer-purple">Winners</span>
|
75 | 22 | </Underline>
|
76 | 23 | </h1>
|
77 | 24 | <div className="flex w-full snap-x items-center justify-center overflow-x-auto lg:overflow-visible">
|
78 | 25 | <ul className="flex max-h-screen w-full max-w-screen-2xl justify-around gap-2 sm:aspect-auto">
|
79 | 26 | {Object.entries(sortedPastWinners).map(([key, value], index) => (
|
80 | 27 | <WinnerCard
|
81 |
| - pastWinnersArraySize={pastWinners.length} |
| 28 | + pastWinnersArraySize={sortedPastWinners.length} |
82 | 29 | pastWinner={value}
|
83 | 30 | key={key}
|
84 | 31 | index={index}
|
|
0 commit comments