import React from 'react'; import { resolve, findProp } from '@/_helpers/utils'; import Skeleton from 'react-loading-skeleton'; export const Table = function Table({ id, component, onComponentClick, currentState, onEvent }) { const backgroundColor = component.definition.styles.backgroundColor.value; const color = component.definition.styles.textColor.value; const columns = component.definition.properties.columns.value; const actions = component.definition.properties.actions || { value: []}; const loadingStateProperty = component.definition.properties.loadingState; let loadingState = false; if(loadingStateProperty && currentState) { loadingState = resolve(loadingStateProperty.value, currentState); } console.log('currentState', currentState); let data = [] if(currentState) { data = resolve(component.definition.properties.data.value, currentState, []); console.log('resolved param', data); } function findColumnValue(row, column) { if(column.key) { return findProp(row, column.key); } else { return findProp(row, column.name); } } // Quick fix, need to remove later data = data ? data : []; const computedStyles = { backgroundColor, color } return (
onComponentClick(id, component) }> {columns.map((column) => )} {actions.value.length > 0 && } {data.map((row => { e.stopPropagation(); onEvent('onRowClicked', { component, data: row }); }}> {columns.map((column) => )} {actions.value.length > 0 && } ))} {/*
Records 1-10 of 242
*/}
{column.name}Actions
{findColumnValue(row, column)} {actions.value.map((action) => ( ))}
{loadingState &&
}
); };