support nested field parent label

This commit is contained in:
shamsmosowi
2023-04-20 15:45:14 +02:00
parent 3fc5b13f06
commit 40bb8a8158

View File

@@ -2,6 +2,7 @@ import { useLocation } from "react-router-dom";
import { ROUTES } from "@src/constants/routes";
import { ColumnConfig, TableRow, TableRowRef } from "@src/types/table";
import get from "lodash-es/get";
export const useSubTableData = (
column: ColumnConfig,
@@ -9,8 +10,8 @@ export const useSubTableData = (
_rowy_ref: TableRowRef
) => {
const label = (column.config?.parentLabel ?? []).reduce((acc, curr) => {
if (acc !== "") return `${acc} - ${row[curr]}`;
else return row[curr];
if (acc !== "") return `${acc} - ${get(row, curr)}`;
else return get(row, curr);
}, "");
const documentCount: string = row[column.fieldName]?.count ?? "";