|
1 | | -import { useMemo } from "react"; |
| 1 | +import { useMemo, useState } from "react"; |
2 | 2 | import { injectIntl } from "react-intl"; |
3 | 3 | import { usePagination, useResizeColumns, useSortBy, useTable } from "react-table"; |
4 | 4 | import BusySpinner from "../BusySpinner/BusySpinner"; |
5 | 5 | import WithSortedChallenges from "../HOCs/WithSortedChallenges/WithSortedChallenges"; |
6 | 6 | import PaginationControl from "../PaginationControl/PaginationControl"; |
7 | 7 | import { TableWrapper, renderTableHeader } from "../TableShared/EnhancedTable"; |
8 | 8 | import { cellStyles, rowStyles, tableStyles } from "../TableShared/TableStyles"; |
9 | | -import { CHALLENGE_COLUMNS, PROJECT_COLUMNS, USER_COLUMNS } from "./MetricsData"; |
| 9 | +import { CHALLENGE_COLUMNS, PROJECT_COLUMNS, getUserColumns } from "./MetricsData"; |
10 | 10 | import WithMetricsSearchResults from "./WithMetricsSearchResults"; |
11 | 11 | import WithSortedProjects from "./WithSortedProjects"; |
12 | 12 | import WithSortedUsers from "./WithSortedUsers"; |
13 | 13 |
|
14 | 14 | const MetricsTable = (props) => { |
| 15 | + const [userChanges, setUserChanges] = useState({}); |
| 16 | + |
15 | 17 | const data = useMemo(() => { |
16 | 18 | if (props.currentTab === "challenges") { |
17 | 19 | return props.challenges.map((c) => ({ |
@@ -58,10 +60,10 @@ const MetricsTable = (props) => { |
58 | 60 | } else if (props.currentTab === "projects") { |
59 | 61 | return PROJECT_COLUMNS; |
60 | 62 | } else if (props.currentTab === "users") { |
61 | | - return USER_COLUMNS; |
| 63 | + return getUserColumns(userChanges, setUserChanges); |
62 | 64 | } |
63 | 65 | return []; |
64 | | - }, [props.currentTab]); |
| 66 | + }, [props.currentTab, userChanges]); |
65 | 67 |
|
66 | 68 | const { |
67 | 69 | getTableProps, |
|
0 commit comments