function populateColumnDefinitions()

in src/components/search/SearchResults.tsx [203:245]


  function populateColumnDefinitions() {
    let tempColumnList: {
      id: any;
      header: any;
      cell: any;
      sortingField: any;
    }[] = [];
    const allColumnNameSet = new Set();

    tableItems.forEach((tableItem) => {
      Object.keys(tableItem).forEach((tableItemKey) => {
        allColumnNameSet.add(tableItemKey);
      });
    });

    allColumnNameSet.forEach((columnName: any) => {
      tempColumnList.push({
        id: columnName,
        header: columnName,
        cell: (e: any) => e[columnName],
        sortingField: columnName,
      });
    });

    // Move column id to the be the first column in the table
    const idColumn = tempColumnList.find((column) => {
      return column.header === "id";
    });
    const resourceTypeColumn = tempColumnList.find((column) => {
      return column.header === "resourceType";
    });
    tempColumnList = tempColumnList.filter((column) => {
      return column.header !== "id" && column.header !== "resourceType";
    });
    if (idColumn) {
      tempColumnList.unshift(idColumn);
    }
    if (resourceTypeColumn) {
      tempColumnList.unshift(resourceTypeColumn);
    }

    setTableColumnDefinitions(tempColumnList);
  }