import { useState, useEffect } from "react" import { Button, Timeline } from 'antd' import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' import '../../styles/index.css' import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' export const MeasureTable = ({title, columns, values}) => { var defaultDisplay = values && values.length ? values[values.length-1] : [] const [displayedValues, setDisplayedValues] = useState([]); const [editingColumns, setEditingColumns] = useState(columns); const [isTableEditing, setIsTableEditing] = useState(false); useEffect(() => { setDisplayedValues(defaultDisplay) }, [defaultDisplay]) useEffect(() => { let switchableColumns = [] if(isTableEditing) { switchableColumns = columns.map(col => ({ render: () => , ...col }) ) } else { switchableColumns = columns.map(col => ({ render: null, ...col }) ) } setEditingColumns(switchableColumns) }, [isTableEditing]) const createButtons = (buttonNames, buttonContainerStyle, isEditing) => { return
{buttonNames.map(name => )}
} const crudButtons =
const confirmButtons =
return <>  

{title}

 
{isTableEditing ? confirmButtons : crudButtons }
{values.map((item, index) => setDisplayedValues(values.find(el => el.id === item.id))} dot={item.id === displayedValues.id ? : null} value={moment.utc(item.timestamp).local().format(format)} > {moment.utc(item.timestamp).local().format(format)} )}
}