From 6497ad755a624a8619dc38d5ea77712dda14ed4e Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:58:26 +0100 Subject: [PATCH] refactor(common-ui,clusters-ui): change `onNameClick` argument in GroupedDataTable --- .../explore/Modelization/Areas/Renewables/index.tsx | 6 +++--- .../explore/Modelization/Areas/Storages/index.tsx | 6 +++--- .../explore/Modelization/Areas/Thermal/index.tsx | 6 +++--- webapp/src/components/common/GroupedDataTable/index.tsx | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx index 3878b6410e..0ee30ab4b9 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx @@ -1,5 +1,5 @@ import { useMemo } from "react"; -import { createMRTColumnHelper, type MRT_Row } from "material-react-table"; +import { createMRTColumnHelper } from "material-react-table"; import { Box } from "@mui/material"; import { useLocation, useNavigate, useOutletContext } from "react-router-dom"; import { useTranslation } from "react-i18next"; @@ -127,8 +127,8 @@ function Renewables() { return deleteRenewableClusters(study.id, areaId, ids); }; - const handleNameClick = (row: MRT_Row) => { - navigate(`${location.pathname}/${row.original.id}`); + const handleNameClick = (row: RenewableClusterWithCapacity) => { + navigate(`${location.pathname}/${row.id}`); }; //////////////////////////////////////////////////////////////// diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx index b3adf2490c..15f91f5636 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; import { useTranslation } from "react-i18next"; -import { createMRTColumnHelper, type MRT_Row } from "material-react-table"; +import { createMRTColumnHelper } from "material-react-table"; import { Box, Tooltip } from "@mui/material"; import { useLocation, useNavigate, useOutletContext } from "react-router-dom"; import { StudyMetadata } from "../../../../../../../common/types"; @@ -166,8 +166,8 @@ function Storages() { return deleteStorages(study.id, areaId, ids); }; - const handleNameClick = (row: MRT_Row) => { - navigate(`${location.pathname}/${row.original.id}`); + const handleNameClick = (row: Storage) => { + navigate(`${location.pathname}/${row.id}`); }; //////////////////////////////////////////////////////////////// diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx index 6eecd4d3fb..c1a768cc9f 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx @@ -1,5 +1,5 @@ import { useMemo } from "react"; -import { createMRTColumnHelper, type MRT_Row } from "material-react-table"; +import { createMRTColumnHelper } from "material-react-table"; import { Box } from "@mui/material"; import { useLocation, useNavigate, useOutletContext } from "react-router-dom"; import { useTranslation } from "react-i18next"; @@ -134,8 +134,8 @@ function Thermal() { return deleteThermalClusters(study.id, areaId, ids); }; - const handleNameClick = (row: MRT_Row) => { - navigate(`${location.pathname}/${row.original.id}`); + const handleNameClick = (row: ThermalClusterWithCapacity) => { + navigate(`${location.pathname}/${row.id}`); }; //////////////////////////////////////////////////////////////// diff --git a/webapp/src/components/common/GroupedDataTable/index.tsx b/webapp/src/components/common/GroupedDataTable/index.tsx index d74ad143b7..f7ef8264db 100644 --- a/webapp/src/components/common/GroupedDataTable/index.tsx +++ b/webapp/src/components/common/GroupedDataTable/index.tsx @@ -11,7 +11,6 @@ import { useMaterialReactTable, type MRT_RowSelectionState, type MRT_ColumnDef, - type MRT_Row, } from "material-react-table"; import { useTranslation } from "react-i18next"; import { useMemo, useRef, useState } from "react"; @@ -42,7 +41,7 @@ export interface GroupedDataTableProps< onCreate?: (values: TRow) => Promise; onDuplicate?: (row: TData, newName: string) => Promise; onDelete?: (rows: TData[]) => PromiseAny | void; - onNameClick?: (row: MRT_Row) => void; + onNameClick?: (row: TData) => void; isLoading?: boolean; deleteConfirmationMessage?: string | ((count: number) => string); fillPendingRow?: ( @@ -131,7 +130,7 @@ function GroupedDataTable< textDecoration: "underline", }, }} - onClick={() => callbacksRef.current.onNameClick?.(row)} + onClick={() => callbacksRef.current.onNameClick?.(row.original)} > {renderedCellValue}