Skip to content

Commit 8fa3d08

Browse files
only show grouped by 100
1 parent 51e1dcb commit 8fa3d08

File tree

1 file changed

+43
-66
lines changed

1 file changed

+43
-66
lines changed

atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx

Lines changed: 43 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useState } from "react";
2-
import { Table, Button, ButtonGroup } from "reactstrap";
1+
import React from "react";
2+
import { Table } from "reactstrap";
33
import { ProblemId } from "../../interfaces/Status";
44
import { isAccepted } from "../../utils";
55
import { countBy, groupBy } from "../../utils/GroupBy";
@@ -47,7 +47,6 @@ export const getUserPointCounts = (
4747
};
4848

4949
export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
50-
const [grouped, setGrouped] = useState(true);
5150
const mergedProblemMap =
5251
useMergedProblemMap().data ?? new Map<ProblemId, MergedProblem>();
5352
const userPointCountMap = getUserPointCounts(mergedProblemMap, submissions);
@@ -88,70 +87,48 @@ export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
8887
};
8988

9089
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>
110128
))}
111129
</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>
156133
);
157134
};

0 commit comments

Comments
 (0)