Do not auto generate columns for nested data (#4627)

This commit is contained in:
Sherfin Shamsudeen 2022-10-27 12:56:47 +05:30 committed by GitHub
parent 1a3f0521b6
commit 4a2e7d3bdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,11 @@ import { v4 as uuidv4 } from 'uuid';
export default function autogenerateColumns(tableData, existingColumns, columnDeletionHistory, setProperty) {
const firstRow = tableData?.[0] ?? {};
const keysOfTableData = Object.keys(firstRow);
const firstRowWithoutNestedElements = Object.fromEntries(
Object.entries(firstRow).filter(([_key, value]) => typeof value != 'object')
);
const keysOfTableData = Object.keys(firstRowWithoutNestedElements);
const keysOfExistingColumns = existingColumns.map((column) => column.key || column.name);