From b968fbf053e619442e2e68a6614319e1bed7ff1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Fri, 28 May 2021 15:56:40 +0500 Subject: [PATCH] clean Wells.jsx --- src/pages/Wells.jsx | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/pages/Wells.jsx b/src/pages/Wells.jsx index 6ffef25..579e5b4 100644 --- a/src/pages/Wells.jsx +++ b/src/pages/Wells.jsx @@ -27,39 +27,8 @@ const columns = [ }, ]; -const groupBy = (table, ...keys) => { - let key = keys[0] - - let groups = table.reduce((rv, item) => { - let keyValue = item[key] - let group = rv.find(o=>o.title === keyValue) - if(!group) - { - group = { - title: keyValue, - value: keys.length === 1 ? item : `${key} ${keyValue} ${item['id']}`, - selectable: keys.length === 1, - children:[]} - rv.push(group) - } - if(keys.length > 1) - group.children.push(item); - return rv; - }, []); - - if(keys.length > 1){ - for(let group of groups){ - group.children = groupBy(group.children, ...keys.slice(1)) - } - } - - return groups -}; - - export default function Wells(props){ const [wells, setWells] = useState([]) - const [setWellsTree] = useState([]) // wellsTree, const [loader, setLoader] = useState(false) const history = useHistory() @@ -67,10 +36,8 @@ export default function Wells(props){ setLoader(true) try{ let newWells = (await WellService.getWells()).map(w =>{return {key:w.id, ...w}}) - let wellsTree = groupBy(newWells, 'deposit', 'cluster', 'caption') console.log(Wells.wellsTree) setWells( newWells ) - setWellsTree(wellsTree) } catch(e){ console.error(`${e.message}`);