Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit ba84e56

Browse files
author
Stefano Casasola
committed
feat: add further implementations
1 parent 03e9bb6 commit ba84e56

8 files changed

Lines changed: 637 additions & 43 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
'airbnb',
99
'plugin:@typescript-eslint/recommended',
1010
'prettier',
11+
'prettier/react',
1112
'prettier/@typescript-eslint',
1213
'plugin:prettier/recommended',
1314
],

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3+
"eslint.enable": true,
34
"editor.codeActionsOnSave": {
45
"source.fixAll.eslint": true
56
},
6-
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
7+
"eslint.validate": [
8+
"javascript",
9+
"javascriptreact",
10+
"typescript",
11+
"typescriptreact"
12+
],
713
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@types/chart.js": "~2.9.7",
7777
"@types/enzyme": "~3.10.3",
7878
"@types/jest": "~25.1.0",
79+
"@types/lodash": "^4.14.149",
7980
"@types/node": "~13.7.0",
8081
"@types/react": "~16.9.17",
8182
"@types/react-dom": "~16.9.1",
@@ -140,6 +141,7 @@
140141
"chart.js": "~2.9.3",
141142
"date-fns": "^2.9.0",
142143
"formik": "~2.1.0",
144+
"lodash": "^4.17.15",
143145
"moment": "~2.24.0",
144146
"react-bootstrap-typeahead": "^3.4.7",
145147
"react-datepicker": "~2.12.0",

src/components/Table/Table.tsx

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import React from 'react'
22
// import styled from 'styled-components'
3-
import { useTable, Column, Row } from 'react-table'
3+
import { useTable, Row } from 'react-table'
4+
import { generateColumns } from './helper'
5+
// import { TableProperties } from './interfaces'
46

57
interface MyProps {
6-
columns: Column[]
8+
tableProperties: any
79
data: any
10+
// columns: any
811
}
912

10-
function ReactTable({ columns, data }: MyProps) {
11-
// Use the state and functions returned from useTable to build your UI
13+
function Table({ data, tableProperties }: MyProps) {
14+
console.log(tableProperties)
15+
// convertire con generateColumns
16+
const columns = generateColumns(tableProperties.columns)
17+
console.log('COLUMNS', columns)
1218
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
1319
columns,
1420
data,
1521
})
1622

17-
// Render the UI for your table
1823
return (
1924
<table {...getTableProps()}>
2025
<thead>
@@ -28,6 +33,7 @@ function ReactTable({ columns, data }: MyProps) {
2833
</thead>
2934
<tbody {...getTableBodyProps()}>
3035
{rows.map((row: Row) => {
36+
console.log(row)
3137
prepareRow(row)
3238
return (
3339
<tr {...row.getRowProps()}>
@@ -42,40 +48,4 @@ function ReactTable({ columns, data }: MyProps) {
4248
)
4349
}
4450

45-
function Table({ data }: any) {
46-
const columns = React.useMemo(
47-
() => [
48-
{
49-
Header: 'Name',
50-
columns: [
51-
{
52-
Header: 'First Name',
53-
accessor: 'firstName',
54-
},
55-
{
56-
Header: 'Last Name',
57-
accessor: 'lastName',
58-
},
59-
],
60-
},
61-
{
62-
Header: 'Info',
63-
columns: [
64-
{
65-
Header: 'Age',
66-
accessor: 'age',
67-
},
68-
{
69-
Header: 'Status',
70-
accessor: 'status',
71-
},
72-
],
73-
},
74-
],
75-
[],
76-
)
77-
78-
return <ReactTable columns={columns} data={data} />
79-
}
80-
8151
export { Table }

0 commit comments

Comments
 (0)