Rufus Pollock 2562781e3e [refactor,#527][m]: move the nextjs app at root of repo to examples/dataset-frictionless.
The current app at root of repo is for single frictionless dataset. Should be in its own example so we have space going forward for multiple example and for root to have core portal.js code.

* Also refactor its README (moved from root) to reflect it is just an example
* Move design content from the root README.md into DESIGN.md
* Stub a new root README.md based largely on examples/catalog/README.md
2021-04-12 16:15:20 +02:00

29 lines
735 B
JavaScript

/* eslint-disable max-len */
import React from 'react';
import { DataGrid } from '@material-ui/data-grid';
/*
* @param schema: Frictionless Table Schmea
* @param data: an array of data objects e.g. [ {a: 1, b: 2}, {a: 5, b: 7} ]
*/
const Table = ({ schema, data }) => {
const columns = schema.fields.map((field) => (
{
field: field.title || field.name,
headerName: field.name,
width: 300
}
))
data = data.map((item, index)=>{
item.id = index //Datagrid requires every row to have an ID
return item
})
return (
<div data-testid="tableGrid" style={{ height: 400, width: '100%' }}>
<DataGrid rows={data} columns={columns} pageSize={5} />
</div>
);
}
export default Table