import { useState, useEffect } from 'react' import { Button, Form, Timeline } from 'antd' import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' import LoaderPortal from '../../components/LoaderPortal' import { MeasureService } from '../../services/api' import '../../styles/index.css' import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasures}) => { const [showLoader, setShowLoader] = useState(false); const [selectedTimeLineId, setSelectedTimeLineId] = useState(0) const [displayedValues, setDisplayedValues] = useState([]); const [editingColumns, setEditingColumns] = useState(columns); const [isTableEditing, setIsTableEditing] = useState(false); const [editingActionName, setEditingActionName] = useState(''); const [measuresForm] = Form.useForm(); const createEditingColumns = (cols, renderDelegate) => cols.map(col => ({ render: renderDelegate, ...col }) ) useEffect(() => { let valuesToDisplay = [] if(selectedTimeLineId === 0) { valuesToDisplay = values.length ? values[values.length-1] : [] } else { valuesToDisplay = values.find(el => el.id === selectedTimeLineId) } setDisplayedValues(valuesToDisplay) }, [selectedTimeLineId, values]) useEffect(() => { let switchableColumns = [] isTableEditing && editingActionName !== 'Удалить' ? switchableColumns = createEditingColumns(columns, () => ) : switchableColumns = createEditingColumns(columns, null) setEditingColumns(switchableColumns) }, [isTableEditing, columns, editingActionName]) const buttonsConfig = [ {name:'Добавить', key:'add'}, {name:'Редактировать', key:'edit'}, {name:'Удалить', key:'delete'} ] const createButtons = (config, onClickDelegate) => { return (