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
4 changes: 3 additions & 1 deletion mosu-app/src/pages/events/competition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ 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 sortedTopRatedSchools = topRatedSchools
.sort((e1, e2) => e2.paidApplicationCount - e1.paidApplicationCount)
.slice(0, 20);
const top3Schools = sortedTopRatedSchools.slice(0, 3).map((school) => school.schoolName);

return {
Expand Down
10 changes: 6 additions & 4 deletions mosu-app/src/widgets/competition/RankTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export const RankTableRow = ({ rank, schoolName, prevRank, gap }: RankTableRowPr
<tr>
<td>{rank}</td>
<td>{schoolName}</td>
<td>
{prevRank}등까지
<span className="color-[#7C9FFF]">{gap}</span>명
</td>
{prevRank !== 0 && (
<td>
{prevRank}등까지&nbsp;
<span className="color-[#7C9FFF]">{gap}</span>명
</td>
)}
</tr>
);
};
23 changes: 16 additions & 7 deletions mosu-app/src/widgets/competition/RankTableSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,28 @@ export const RankTableSection = ({ topRatedSchools }: RankTableSectionProps) =>
</thead>
<tbody>
{topRatedSchools.map((school, index) => {
let prevRank = 0;
let gap = 0;
const rank = index + 1;

if (index > 0) {
const prevSchoolCount = topRatedSchools[index - 1].paidApplicationCount;
gap = prevSchoolCount - school.paidApplicationCount;
prevRank = index;
if (rank === 1) {
return (
<RankTableRow
key={school.schoolName}
rank={rank}
schoolName={school.schoolName}
prevRank={0}
gap={0}
/>
);
}

const prevSchoolCount = topRatedSchools[index - 1].paidApplicationCount;
const gap = prevSchoolCount - school.paidApplicationCount;
const prevRank = index;

return (
<RankTableRow
key={school.schoolName}
rank={index + 1}
rank={rank}
schoolName={school.schoolName}
prevRank={prevRank}
gap={gap}
Expand Down