diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx
index 2a9ca4c..4831ec6 100644
--- a/src/pages/Measure/MeasureTable.jsx
+++ b/src/pages/Measure/MeasureTable.jsx
@@ -18,8 +18,7 @@ const format='YYYY.MM.DD HH:mm'
export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasuresFunc}) => {
const [showLoader, setShowLoader] = useState(false);
- const [selectedTimeLineId, setSelectedTimeLineId] = useState(undefined)
- const [displayedValues, setDisplayedValues] = useState([]);
+ const [displayedValues, setDisplayedValues] = useState({});
const [editingColumns, setEditingColumns] = useState(columns);
const [isTableEditing, setIsTableEditing] = useState(false);
const [editingActionName, setEditingActionName] = useState('');
@@ -34,28 +33,20 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
)
useEffect(() => {
- let valuesToDisplay = []
+ const defaultValuesToDisplay = values[values.length-1]
- if(!selectedTimeLineId)
- valuesToDisplay = values && values.length
- ? values[values.length-1]
- : []
- else
- valuesToDisplay = values.find(el => el.id === selectedTimeLineId)
-
- setDisplayedValues(valuesToDisplay)
- setSelectedTimeLineId(valuesToDisplay?.id)
- }, [selectedTimeLineId, values])
+ setDisplayedValues(defaultValuesToDisplay)
+ }, [values])
useEffect(() => {
let switchableColumns = []
- isTableEditing && editingActionName !== 'delete'
+ isTableEditing
? switchableColumns = createEditingColumns(columns, () => )
: switchableColumns = createEditingColumns(columns, null)
if(editingActionName === 'edit')
- measuresForm.setFieldsValue(displayedValues.data);
+ measuresForm.setFieldsValue(displayedValues?.data);
else if(editingActionName === 'add')
measuresForm.resetFields()
@@ -67,7 +58,6 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
await MeasureService.markAsDelete(idWell, displayedValues.id)
updateMeasuresFunc()
setShowLoader(false)
- setIsTableEditing(false)
}
const checkIsDataDefault = () =>
@@ -177,7 +167,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
setSelectedTimeLineId(item.id)}
+ onClick={() => setDisplayedValues(item)}
dot={item?.id === displayedValues?.id
?
: null}
@@ -197,7 +187,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
onFinish={handleSubmitMeasuresForm}
>