ToolJet/frontend/src/Editor/Components/Table.jsx

57 lines
1.6 KiB
React
Raw Normal View History

2021-04-03 05:25:41 +00:00
import React from 'react';
import { resolve } from '@/_helpers/utils';
2021-04-03 05:25:41 +00:00
2021-04-04 06:26:46 +00:00
export const Table = function Table({ id, component, onComponentClick, currentState }) {
2021-04-03 05:25:41 +00:00
const backgroundColor = component.definition.styles.backgroundColor.value;
const color = component.definition.styles.textColor.value;
2021-04-04 06:26:46 +00:00
console.log('currentState', currentState);
let data = []
if(currentState) {
2021-04-04 17:07:03 +00:00
data = resolve(component.definition.properties.data.value, currentState, []);
2021-04-04 06:26:46 +00:00
console.log('resolved param', data);
}
2021-04-04 17:07:03 +00:00
// Quick fix, need to remove later
data = data ? data : [];
2021-04-03 05:25:41 +00:00
const computedStyles = {
backgroundColor,
color
}
return (
<div class="table-responsive table-bordered" style={{...computedStyles, width: '700px'}} onClick={() => onComponentClick(id, component) }>
<table
class="table table-vcenter table-nowrap">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>email</th>
2021-04-03 05:25:41 +00:00
</tr>
</thead>
<tbody>
{data.map((row => <tr>
<td>
{row.id}
2021-04-03 05:25:41 +00:00
</td>
<td>
{row.name}
2021-04-03 05:25:41 +00:00
</td>
<td class="text-muted" >
2021-04-04 06:26:46 +00:00
{row.domain}
2021-04-03 05:25:41 +00:00
</td>
</tr>))}
2021-04-03 05:25:41 +00:00
</tbody>
2021-04-04 06:26:46 +00:00
{/* <div className="table-footer p-2">
2021-04-03 05:25:41 +00:00
Records 1-10 of 242
2021-04-04 06:26:46 +00:00
</div> */}
2021-04-03 05:25:41 +00:00
</table>
</div>
);
};