Skip to content

Commit

Permalink
refactor(common-ui,clusters-ui): change onNameClick argument in Gro…
Browse files Browse the repository at this point in the history
…upedDataTable
  • Loading branch information
skamril committed Mar 29, 2024
1 parent cef2c05 commit acd923e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -127,8 +127,8 @@ function Renewables() {
return deleteRenewableClusters(study.id, areaId, ids);
};

const handleNameClick = (row: MRT_Row<RenewableClusterWithCapacity>) => {
navigate(`${location.pathname}/${row.original.id}`);
const handleNameClick = (row: RenewableClusterWithCapacity) => {
navigate(`${location.pathname}/${row.id}`);
};

////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -166,8 +166,8 @@ function Storages() {
return deleteStorages(study.id, areaId, ids);
};

const handleNameClick = (row: MRT_Row<Storage>) => {
navigate(`${location.pathname}/${row.original.id}`);
const handleNameClick = (row: Storage) => {
navigate(`${location.pathname}/${row.id}`);
};

////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -134,8 +134,8 @@ function Thermal() {
return deleteThermalClusters(study.id, areaId, ids);
};

const handleNameClick = (row: MRT_Row<ThermalClusterWithCapacity>) => {
navigate(`${location.pathname}/${row.original.id}`);
const handleNameClick = (row: ThermalClusterWithCapacity) => {
navigate(`${location.pathname}/${row.id}`);
};

////////////////////////////////////////////////////////////////
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/components/common/GroupedDataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -42,7 +41,7 @@ export interface GroupedDataTableProps<
onCreate?: (values: TRow<TGroups[number]>) => Promise<TData>;
onDuplicate?: (row: TData, newName: string) => Promise<TData>;
onDelete?: (rows: TData[]) => PromiseAny | void;
onNameClick?: (row: MRT_Row<TData>) => void;
onNameClick?: (row: TData) => void;
isLoading?: boolean;
deleteConfirmationMessage?: string | ((count: number) => string);
fillPendingRow?: (
Expand Down Expand Up @@ -131,7 +130,7 @@ function GroupedDataTable<
textDecoration: "underline",
},
}}
onClick={() => callbacksRef.current.onNameClick?.(row)}
onClick={() => callbacksRef.current.onNameClick?.(row.original)}
>
{renderedCellValue}
</Box>
Expand Down

0 comments on commit acd923e

Please sign in to comment.