2021-04-02 17:22:34 +05:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2021-04-08 12:29:19 +05:00
|
|
|
import { WellService } from '../services/api'
|
2021-04-02 17:22:34 +05:00
|
|
|
import Loader from '../components/Loader'
|
|
|
|
import { Table } from 'antd';
|
|
|
|
import { useHistory } from 'react-router-dom'
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Месторождение',
|
|
|
|
dataIndex: 'deposit',
|
|
|
|
key: 'deposit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Куст',
|
|
|
|
dataIndex: 'cluster',
|
|
|
|
key: 'cluster',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Скважина',
|
|
|
|
dataIndex: 'caption',
|
|
|
|
key: 'caption',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Данные',
|
|
|
|
dataIndex: 'lastData',
|
|
|
|
key: 'lastData',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export default function Wells(props){
|
|
|
|
const [wells, setWells] = useState([])
|
|
|
|
const [loader, setLoader] = useState(false)
|
|
|
|
const history = useHistory()
|
|
|
|
|
|
|
|
let updateWellsList = async () => {
|
|
|
|
setLoader(true)
|
|
|
|
try{
|
2021-04-09 17:59:35 +05:00
|
|
|
var newWells = (await WellService.get()).map(w =>{return {key:w.id, ...w}})
|
|
|
|
setWells( newWells )
|
2021-04-02 17:22:34 +05:00
|
|
|
}
|
|
|
|
catch(e){
|
|
|
|
console.error(`${e.message}`);
|
|
|
|
}
|
|
|
|
setLoader(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
useEffect(()=>{updateWellsList()}, [])
|
|
|
|
|
|
|
|
return(<>
|
|
|
|
<h2>Wells</h2>
|
|
|
|
<Table
|
|
|
|
dataSource={wells}
|
|
|
|
columns={columns}
|
|
|
|
onRow={(record, rowIndex) => {
|
|
|
|
return {
|
2021-04-08 12:29:19 +05:00
|
|
|
onClick: event => {history.push(`well/${record.id}`)},
|
2021-04-02 17:22:34 +05:00
|
|
|
};
|
|
|
|
}}/>
|
|
|
|
{loader&&<Loader/>}
|
|
|
|
</>)
|
|
|
|
}
|