Skip to content

Commit ee516da

Browse files
authored
Merge pull request #391 from mosu-dev/feature#388
Fix#388 학교 경쟁 페이지 및 순위 테이블 스타일 변경
2 parents f5b5372 + b9133b1 commit ee516da

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

mosu-app/src/pages/events/competition/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ import { RankTableSection } from "@/widgets/competition/RankTableSection";
1313
export const getStaticProps = async () => {
1414
const topRatedSchools = await getTopRatedSchools();
1515

16+
const sortedTopRatedSchools = topRatedSchools.sort((e1, e2) => e2.paidApplicationCount - e1.paidApplicationCount);
17+
const top3Schools = sortedTopRatedSchools.slice(0, 3).map((school) => school.schoolName);
18+
1619
return {
1720
props: {
18-
topRatedSchools: topRatedSchools.sort((e1, e2) => e2.paidApplicationCount - e1.paidApplicationCount),
21+
top3Schools,
22+
topRatedSchools: sortedTopRatedSchools,
1923
},
2024
revalidate: 3600, // 1 hour
2125
};
2226
};
2327

24-
export default function SchoolCompetitionPage({ topRatedSchools }: InferGetStaticPropsType<typeof getStaticProps>) {
25-
const top3Schools = topRatedSchools.slice(0, 3).map((school) => school.schoolName);
26-
28+
export default function SchoolCompetitionPage({
29+
top3Schools,
30+
topRatedSchools,
31+
}: InferGetStaticPropsType<typeof getStaticProps>) {
2732
return (
2833
<main>
2934
<SiteMetadata

mosu-app/src/widgets/competition/InfoSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const InfoSection = () => {
3939
<RankInfoCard
4040
imgSrc={imgRank3}
4141
rank={"6~10위"}
42-
descriptions={["도시락은", "모수가 쏩니다!"]}
42+
descriptions={["전원 치킨", "기프티콘"]}
4343
value={"0"}
4444
delimiter={"원"}
4545
/>
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
export interface RankTableRowProps {
22
rank: number;
33
schoolName: string;
4-
gapMessage?: string;
4+
5+
prevRank: number;
6+
gap: number;
57
}
68

7-
export const RankTableRow = ({ rank, schoolName, gapMessage }: RankTableRowProps) => {
9+
export const RankTableRow = ({ rank, schoolName, prevRank, gap }: RankTableRowProps) => {
810
return (
911
<tr>
1012
<td>{rank}</td>
1113
<td>{schoolName}</td>
12-
<td>{gapMessage || ""}</td>
14+
<td>
15+
{prevRank}등까지
16+
<span className="color-[#7C9FFF]">{gap}</span>
17+
</td>
1318
</tr>
1419
);
1520
};

mosu-app/src/widgets/competition/RankTableSection.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ export const RankTableSection = ({ topRatedSchools }: RankTableSectionProps) =>
2020
</thead>
2121
<tbody>
2222
{topRatedSchools.map((school, index) => {
23-
let gapMessage = "";
23+
let prevRank = 0;
24+
let gap = 0;
25+
2426
if (index > 0) {
2527
const prevSchoolCount = topRatedSchools[index - 1].paidApplicationCount;
26-
const gap = prevSchoolCount - school.paidApplicationCount;
27-
const prevRank = index;
28-
gapMessage = `${prevRank}등까지 ${gap}명`;
28+
gap = prevSchoolCount - school.paidApplicationCount;
29+
prevRank = index;
2930
}
3031

3132
return (
3233
<RankTableRow
3334
key={school.schoolName}
3435
rank={index + 1}
3536
schoolName={school.schoolName}
36-
gapMessage={gapMessage}
37+
prevRank={prevRank}
38+
gap={gap}
3739
/>
3840
);
3941
})}

0 commit comments

Comments
 (0)