|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +//Hooks |
| 4 | +import useFetch from "../../Hooks/useFetch"; |
| 5 | +//Components |
| 6 | +import TreeItem from "./tree-item"; |
| 7 | + |
| 8 | +const TableRows = ({ data, columns }) => { |
| 9 | + |
| 10 | + /*const IsInternalIcon = data.Icon.IsInternalIcon; |
| 11 | +
|
| 12 | + let linkVal; |
| 13 | + if (IsInternalIcon) { |
| 14 | + linkVal = <img src={"/Content/icons/" + data.IconText + "_x16.png"} />; |
| 15 | + } else { |
| 16 | + linkVal = <img src={"/Content/icons/" + data.Icon.FileType + "_x16.png"} />; |
| 17 | + } |
| 18 | +
|
| 19 | + let expandVal; |
| 20 | + if (data.IsContainer && data.Collapse) { |
| 21 | + expandVal = " + "; |
| 22 | + } else if (data.IsContainer && !data.Collapse) { |
| 23 | + expandVal = " - "; |
| 24 | + } else { |
| 25 | + expandVal = null; |
| 26 | + } |
| 27 | + const treeItems = !data.Items ? loading && !data.Collapse : treeData.Items !== null && data.IsContainer !== null && !data.Collapse ? data.Items.map((record, key) => { |
| 28 | + return ( |
| 29 | + <TreeItem columns={columns} data={record} IsInternalIcon={IsInternalIcon} linkVal={linkVal} key={key} getDescendantProp={getDescendantProp}> |
| 30 | + { |
| 31 | + columns.map((column, key) => { |
| 32 | + return ( |
| 33 | + <td className="treeitem" key={key}> |
| 34 | + {getDescendantProp(record, column.Value)} |
| 35 | + </td> |
| 36 | + ); |
| 37 | + }) |
| 38 | + } |
| 39 | + </TreeItem> |
| 40 | + ); |
| 41 | + }) : null*/ |
| 42 | + return ( |
| 43 | + <tbody> |
| 44 | + <tr className="tableRow"> |
| 45 | + { |
| 46 | + columns.map((column, key) => { |
| 47 | + return ( |
| 48 | + <td className="treeitem" key={key} > |
| 49 | + {getDescendantProp(data, column.Value)} |
| 50 | + </td> |
| 51 | + ); |
| 52 | + }) |
| 53 | + } |
| 54 | + </tr> |
| 55 | + </tbody> |
| 56 | + ); |
| 57 | +} |
| 58 | + |
| 59 | +export default TableRows; |
| 60 | + |
| 61 | +const getDescendantProp = (obj, desc) => { |
| 62 | + var arr = desc.split('.'); |
| 63 | + while (arr.length && (obj = obj[arr.shift()])); |
| 64 | + return obj; |
| 65 | +} |
0 commit comments