diff --git a/frontend/src/components/RankingTable.tsx b/frontend/src/components/RankingTable.tsx index 6253d7a..dc0a53b 100644 --- a/frontend/src/components/RankingTable.tsx +++ b/frontend/src/components/RankingTable.tsx @@ -21,58 +21,76 @@ interface RankingTableRowProps { problems: ProblemInfo[]; } +type RowTemplateProps = { + ranking: number; + accountName: string; + score: number; + penalty: number; +}; +const RowTemplate: React.VFC = ({ + ranking, + accountName, + score, + penalty, +}) => ( + <> + {ranking} + {accountName} + +
{score}
+
{formatSecondToMMSS(penalty)}
+ + +); + +type PlayerStatusProps = { + problemId: number; + point: number; + time: number; +}; +const PlayerStatusOfProblem: React.VFC = ({ + problemId, + point, + time, +}) => ( + +
{point}
+
{formatSecondToMMSS(time)}
+ +); + export const RankingTableRow: React.FC = ({ account, isMe, problems, }) => { - const probElement = []; - for (let i = 0; i < problems.length; i++) { - if (account.acceptList.some((ac: any) => ac === i)) { - //null | number[] ? - probElement.push( - -

AC

-

- {formatSecondToMMSS(account.acceptTimeList[i])} -

- - ); - } else { - probElement.push( ); - } - } - return ( - {account.ranking} - {account.accountName} - -
{account.score}
-
{account.penalty}
- - {problems.map((problems) => { - const i = account.acceptList.findIndex( - (v) => v === problems.indexOfContest + + + {problems.map((problem) => { + const accountAcceptIdx = account.acceptList.findIndex( + (v) => v === problem.indexOfContest ); - if (i === -1) { + if (accountAcceptIdx === -1) { return ( - + - ); } return ( - -
- {problems.point} -
-
- {formatSecondToMMSS( - account.acceptTimeList[problems.indexOfContest] - )} -
- + ); })} diff --git a/frontend/src/pages/ContestPage.tsx b/frontend/src/pages/ContestPage.tsx index 281d118..f4bf09a 100644 --- a/frontend/src/pages/ContestPage.tsx +++ b/frontend/src/pages/ContestPage.tsx @@ -135,15 +135,15 @@ const RankingElement: React.FC = ({ getRanking(); } - useEffect(() => { - getRanking(); - }, []); - let myRank = ''; if (ranking?.requestAccountRank) { myRank = `順位: ${ranking.requestAccountRank}`; } + useEffect(() => { + getRanking(); + }, []); + return ( <>

{myRank}

diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 799ada2..e253a6d 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -38,16 +38,18 @@ export interface RankingInfo { /** * 順位表に表示するためのアカウント情報 */ +// AccountRankingInfoとRankingInfoAccountの区別が付きづらい User_StandingDataなどは? +// ユーザーの順位に関係するデータだとすぐわかるようにしたいです export interface RankingInfoAccount { accountName: string; /** * ACした問題リスト */ - acceptList: unknown[]; + acceptList: number[]; /** * このアカウントの現在順位 */ - ranking: any; + ranking: number; /** * 提出までに経過した秒数 */ @@ -141,4 +143,4 @@ export interface ProblemInfo { export interface AccountRankingInfo { accounts: AccountInfo[]; validAccountNum: number; -} \ No newline at end of file +}