Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions mosu-app/src/pages/events/competition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@ import { RankTableSection } from "@/widgets/competition/RankTableSection";
export const getStaticProps = async () => {
const topRatedSchools = await getTopRatedSchools();

const sortedTopRatedSchools = topRatedSchools.sort((e1, e2) => e2.paidApplicationCount - e1.paidApplicationCount);
const top3Schools = sortedTopRatedSchools.slice(0, 3).map((school) => school.schoolName);

return {
props: {
topRatedSchools: topRatedSchools.sort((e1, e2) => e2.paidApplicationCount - e1.paidApplicationCount),
top3Schools,
topRatedSchools: sortedTopRatedSchools,
},
revalidate: 3600, // 1 hour
};
};

export default function SchoolCompetitionPage({ topRatedSchools }: InferGetStaticPropsType<typeof getStaticProps>) {
const top3Schools = topRatedSchools.slice(0, 3).map((school) => school.schoolName);

export default function SchoolCompetitionPage({
top3Schools,
topRatedSchools,
}: InferGetStaticPropsType<typeof getStaticProps>) {
return (
<main>
<SiteMetadata
Expand Down
2 changes: 1 addition & 1 deletion mosu-app/src/widgets/competition/InfoSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const InfoSection = () => {
<RankInfoCard
imgSrc={imgRank3}
rank={"6~10위"}
descriptions={["도시락은", "모수가 쏩니다!"]}
descriptions={["전원 치킨", "기프티콘"]}
value={"0"}
delimiter={"원"}
/>
Expand Down
11 changes: 8 additions & 3 deletions mosu-app/src/widgets/competition/RankTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
export interface RankTableRowProps {
rank: number;
schoolName: string;
gapMessage?: string;

prevRank: number;
gap: number;
}

export const RankTableRow = ({ rank, schoolName, gapMessage }: RankTableRowProps) => {
export const RankTableRow = ({ rank, schoolName, prevRank, gap }: RankTableRowProps) => {
return (
<tr>
<td>{rank}</td>
<td>{schoolName}</td>
<td>{gapMessage || ""}</td>
<td>
{prevRank}등까지
<span className="color-[#7C9FFF]">{gap}</span>명
</td>
</tr>
);
};
12 changes: 7 additions & 5 deletions mosu-app/src/widgets/competition/RankTableSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ export const RankTableSection = ({ topRatedSchools }: RankTableSectionProps) =>
</thead>
<tbody>
{topRatedSchools.map((school, index) => {
let gapMessage = "";
let prevRank = 0;
let gap = 0;

if (index > 0) {
const prevSchoolCount = topRatedSchools[index - 1].paidApplicationCount;
const gap = prevSchoolCount - school.paidApplicationCount;
const prevRank = index;
gapMessage = `${prevRank}등까지 ${gap}명`;
gap = prevSchoolCount - school.paidApplicationCount;
prevRank = index;
}

return (
<RankTableRow
key={school.schoolName}
rank={index + 1}
schoolName={school.schoolName}
gapMessage={gapMessage}
prevRank={prevRank}
gap={gap}
/>
);
})}
Expand Down