|
1 |
| -import React, { useState } from "react"; |
2 |
| -import { Table, Button, ButtonGroup } from "reactstrap"; |
| 1 | +import React from "react"; |
| 2 | +import { Table } from "reactstrap"; |
3 | 3 | import { ProblemId } from "../../interfaces/Status";
|
4 | 4 | import { isAccepted } from "../../utils";
|
5 | 5 | import { countBy, groupBy } from "../../utils/GroupBy";
|
@@ -47,7 +47,6 @@ export const getUserPointCounts = (
|
47 | 47 | };
|
48 | 48 |
|
49 | 49 | export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
|
50 |
| - const [grouped, setGrouped] = useState(true); |
51 | 50 | const mergedProblemMap =
|
52 | 51 | useMergedProblemMap().data ?? new Map<ProblemId, MergedProblem>();
|
53 | 52 | const userPointCountMap = getUserPointCounts(mergedProblemMap, submissions);
|
@@ -88,70 +87,48 @@ export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
|
88 | 87 | };
|
89 | 88 |
|
90 | 89 | return (
|
91 |
| - <> |
92 |
| - <ButtonGroup className="mb-2"> |
93 |
| - <Button onClick={(): void => setGrouped(!grouped)}> |
94 |
| - {grouped ? "Grouped" : "All"} |
95 |
| - </Button> |
96 |
| - </ButtonGroup> |
97 |
| - <Table striped bordered hover responsive> |
98 |
| - <thead> |
99 |
| - <tr> |
100 |
| - <th>Point</th> |
101 |
| - {(grouped ? totalCountBy100 : totalCount).map(({ point }) => ( |
102 |
| - <th key={point}> |
103 |
| - <a |
104 |
| - href={window.location.hash} |
105 |
| - onClick={(): void => setFilterFunc(point)} |
106 |
| - > |
107 |
| - {grouped ? `${point}-` : point} |
108 |
| - </a> |
109 |
| - </th> |
| 90 | + <Table striped bordered hover responsive> |
| 91 | + <thead> |
| 92 | + <tr> |
| 93 | + <th>Point</th> |
| 94 | + {totalCountBy100.map(({ point }) => ( |
| 95 | + <th key={point}> |
| 96 | + <a |
| 97 | + href={window.location.hash} |
| 98 | + onClick={(): void => setFilterFunc(point)} |
| 99 | + > |
| 100 | + {`${point}-`} |
| 101 | + </a> |
| 102 | + </th> |
| 103 | + ))} |
| 104 | + </tr> |
| 105 | + <tr> |
| 106 | + <th>Total</th> |
| 107 | + {totalCountBy100.map(({ point, count }) => ( |
| 108 | + <th key={point}>{count}</th> |
| 109 | + ))} |
| 110 | + </tr> |
| 111 | + </thead> |
| 112 | + <tbody> |
| 113 | + {userPointCountMap.map(({ userId, countByPoint }) => ( |
| 114 | + <tr key={userId}> |
| 115 | + <td>{userId}</td> |
| 116 | + {totalCountBy100.map(({ point, count }) => ( |
| 117 | + <td |
| 118 | + key={point} |
| 119 | + className={ |
| 120 | + getUserPointCountInArea(countByPoint, point, point + 100) === |
| 121 | + count |
| 122 | + ? TableColor.Success |
| 123 | + : TableColor.None |
| 124 | + } |
| 125 | + > |
| 126 | + {getUserPointCountInArea(countByPoint, point, point + 100) ?? 0} |
| 127 | + </td> |
110 | 128 | ))}
|
111 | 129 | </tr>
|
112 |
| - <tr> |
113 |
| - <th>Total</th> |
114 |
| - {(grouped ? totalCountBy100 : totalCount).map( |
115 |
| - ({ point, count }) => ( |
116 |
| - <th key={point}>{count}</th> |
117 |
| - ) |
118 |
| - )} |
119 |
| - </tr> |
120 |
| - </thead> |
121 |
| - <tbody> |
122 |
| - {userPointCountMap.map(({ userId, countByPoint }) => ( |
123 |
| - <tr key={userId}> |
124 |
| - <td>{userId}</td> |
125 |
| - {(grouped ? totalCountBy100 : totalCount).map( |
126 |
| - ({ point, count }) => ( |
127 |
| - <td |
128 |
| - key={point} |
129 |
| - className={ |
130 |
| - (grouped |
131 |
| - ? getUserPointCountInArea( |
132 |
| - countByPoint, |
133 |
| - point, |
134 |
| - point + 100 |
135 |
| - ) |
136 |
| - : countByPoint.get(point)) === count |
137 |
| - ? TableColor.Success |
138 |
| - : TableColor.None |
139 |
| - } |
140 |
| - > |
141 |
| - {(grouped |
142 |
| - ? getUserPointCountInArea( |
143 |
| - countByPoint, |
144 |
| - point, |
145 |
| - point + 100 |
146 |
| - ) |
147 |
| - : countByPoint.get(point)) ?? 0} |
148 |
| - </td> |
149 |
| - ) |
150 |
| - )} |
151 |
| - </tr> |
152 |
| - ))} |
153 |
| - </tbody> |
154 |
| - </Table> |
155 |
| - </> |
| 130 | + ))} |
| 131 | + </tbody> |
| 132 | + </Table> |
156 | 133 | );
|
157 | 134 | };
|
0 commit comments