Skip to content

Commit

Permalink
fix(): withApollo
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed May 18, 2019
1 parent 3ffaa90 commit b929d5c
Showing 1 changed file with 43 additions and 25 deletions.
68 changes: 43 additions & 25 deletions src/js/pages/EnvironHealth.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { Row, Container } from 'react-bootstrap';
import { Query, withApollo } from 'react-apollo';
import { Query, withApollo, graphql } from 'react-apollo';

//Components
import { Boxx } from '../components/widget/Boxx/Boxx';
import { StatsBox } from '../components/widget/StatsBox/StatsBox';
import { ThreeDimenEnvComponent } from '../components/recharts/Scatter_Env';

//Query
import { env_age_latrines_clinic as ealc} from '../queries/records';
import { env_age_latrines_clinic as ealc, allEnvsByOrganization} from '../queries/records';


const styles = {
Expand All @@ -30,37 +30,55 @@ const styles = {
}


export class EnvironHealthAnalytics extends React.Component {
class EnvironHealthAnalytics extends React.Component {
constructor(props){
super(props)
this.state = {
data:null
results:null,
organization:"Puente"
}

}
/*https://github.com/apollographql/react-apollo/issues/1411*/
componentWillMount = async () => {
const {client} = this.props;
let res = await client.query({query: allEnvsByOrganization,variables: {organization:this.state.organization }});
this.setState({results: res.data.getEnvByOrganization})
console.log(this.state.results);
}


componentDidMount(){

}

dataWrangle(){
var data = this.state.results

}
render() {
return (
<Container style={styles.container}>
{/*<Row style={styles.row}>
<Boxx/>
<Boxx/>
</Row>*/}
<Row style={styles.row}>
<Query query={ealc}>
{({ data, loading, error }) => {
if (loading) return <p>Loading...</p>;
if (error) return <p>Error :(</p>;
//console.log(data.getEvalMedicalRecords);
return (
<ThreeDimenEnvComponent data={data} />
);
}}
</Query>
</Row>
</Container>
<Container style={styles.container}>
<Row style={styles.row}>
{/**
<StatsBox/>
<StatsBox/> */}
</Row>
<Row style={styles.row}>
<Query query={ealc}>
{({ data, loading, error }) => {
if (loading) return <p>Loading...</p>;
if (error) return <p>Error :(</p>;
//console.log(data.getEvalMedicalRecords);
return (
<ThreeDimenEnvComponent data={data} />
);
}}
</Query>
</Row>
</Container>
);
}
}
}

export default withApollo(EnvironHealthAnalytics);

0 comments on commit b929d5c

Please sign in to comment.