import React from 'react'; import { Grid, Row, Col } from 'react-bootstrap'; import { TreeView, Card, Fa, WaitIcon } from '../../../components'; import SessionUtils from '../../session-utils'; import { server } from '../../../commons/server'; /** * Display a card with a consolidated number of cases by administrative units * and units, grouped by suspected and confirmed TB, DR-TB and NTM */ export default class CasesDistribution extends React.Component { constructor(props) { super(props); this.nodeRender = this.nodeRender.bind(this); } componentWillMount() { const auId = this.props.scope === 'ADMINUNIT' ? this.props.route.queryParam('id') : null; const self = this; this.fetchView(auId) .then(res => self.setState({ root: res })); this.setState({ root: null }); } fetchView(adminUnitId) { const params = adminUnitId ? '/adminunit?adminUnitId=' + adminUnitId : ''; return server.post('/api/cases/view' + params); } getNodes(parent) { return server.post('/api/cases/view/places?parentId=' + parent.id); } nodeRender(node) { const hash = node.type === 'UNIT' ? SessionUtils.unitHash(node.id, '/cases') : SessionUtils.adminUnitHash(node.id, '/cases'); return ( {node.name} ); } outerRender(content, node) { function addRow(value) { return