Skip to content

Commit

Permalink
rename component to StatisticTable
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelemarre committed Jul 3, 2024
1 parent 411b40a commit 885db5b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import _ from "../../../../domain/entities/generic/Collection";
import { TableCell, TableRow } from "@material-ui/core";
import styled from "styled-components";
import { PerformanceOverviewTableProps } from "./PerformanceOverviewTable";
import { StatisticTableProps } from "./StatisticTable";

export type TableColumn = {
value: string;
Expand All @@ -21,7 +21,7 @@ type MedianRowProps = {
export const MedianRow: React.FC<MedianRowProps> = React.memo(
({ rows, columns, calculateColumns }) => {
const calculateMedian = (
rows: PerformanceOverviewTableProps["rows"],
rows: StatisticTableProps["rows"],
column: TableColumn["value"]
) => {
const values = rows.map(row => Number(row[column])).filter(value => !isNaN(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import _ from "../../../../domain/entities/generic/Collection";
import { TableCell, TableRow } from "@material-ui/core";
import styled from "styled-components";
import { PerformanceOverviewTableProps } from "./PerformanceOverviewTable";
import { StatisticTableProps } from "./StatisticTable";

export type TableColumn = {
value: string;
Expand All @@ -24,7 +24,7 @@ type PercentTargetMetRowProps = {
export const PercentTargetMetRow: React.FC<PercentTargetMetRowProps> = React.memo(
({ rows, columns, columnRules, calculateColumns }) => {
const calculatePercentTargetMet = (
rows: PerformanceOverviewTableProps["rows"],
rows: StatisticTableProps["rows"],
column: TableColumn["value"],
target: number
) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type TableColumn = {
dark?: boolean;
};

export type PerformanceOverviewTableProps = {
export type StatisticTableProps = {
columns: TableColumn[];
columnRules: {
[key: TableColumn["value"]]: number;
Expand All @@ -33,11 +33,10 @@ export type PerformanceOverviewTableProps = {
}[];
};

export const PerformanceOverviewTable: React.FC<PerformanceOverviewTableProps> = React.memo(
export const StatisticTable: React.FC<StatisticTableProps> = React.memo(
({ rows, columns, columnRules, editRiskAssessmentColumns }) => {
const [searchTerm, setSearchTerm] = useState<string>("");
const [filterValue, setFilterValue] = useState("");
// const [filteredRows, setFilteredRows] = useState(rows);

const calculateColumns = [...editRiskAssessmentColumns, ...Object.keys(columnRules)];

Expand Down Expand Up @@ -131,7 +130,7 @@ export const PerformanceOverviewTable: React.FC<PerformanceOverviewTableProps> =
}
);

const useTableSearch = (rows: PerformanceOverviewTableProps["rows"], searchTerm: string) => {
const useTableSearch = (rows: StatisticTableProps["rows"], searchTerm: string) => {
return useMemo(() => {
if (searchTerm === "") {
return rows;
Expand Down
6 changes: 3 additions & 3 deletions src/webapp/pages/dashboard/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import i18n from "../../../utils/i18n";
import { Layout } from "../../components/layout/Layout";
import { Section } from "../../components/section/Section";
import {
PerformanceOverviewTable,
StatisticTable,
TableColumn,
} from "../../components/table/performance-overview-table/PerformanceOverviewTable";
} from "../../components/table/performance-overview-table/StatisticTable";

export const DashboardPage: React.FC = React.memo(() => {
// TODO remove harcoded data
Expand Down Expand Up @@ -188,7 +188,7 @@ export const DashboardPage: React.FC = React.memo(() => {
</Section>
<Section title={i18n.t("7-1-7 performance")}>7-1-7 performance content</Section>
<Section title={i18n.t("Performance overview")}>
<PerformanceOverviewTable
<StatisticTable
columns={columns}
rows={dataPerformanceOverview}
columnRules={columnRules}
Expand Down

0 comments on commit 885db5b

Please sign in to comment.