Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #761 from metasfresh/dev-713
Browse files Browse the repository at this point in the history
#713 Error handling
  • Loading branch information
damianprzygodzki committed May 18, 2017
2 parents 510be75 + 03bec0d commit 7d92cda
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
25 changes: 14 additions & 11 deletions src/components/charts/RawChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class RawChart extends Component {

this.state = {
chartData: [],
intervalId: null
intervalId: null,
err: null
}
}

Expand All @@ -26,21 +27,23 @@ class RawChart extends Component {
return getTargetIndicatorsData(id)()
.then(response => {
return response.data.datasets[0].values
});
}).catch(err => {throw err});
}

return getKPIData(id)()
.then(response => {
return response.data.datasets[0].values
})
.catch(()=>{});
.catch(err => {throw err});
}

fetchData(){
this.getData()
.then(chartData => {
this.setState({ chartData });
});
this.setState({ chartData: chartData, err: null });
}).catch(err => {
this.setState({ err })
})
}

componentDidMount(){
Expand Down Expand Up @@ -135,13 +138,13 @@ class RawChart extends Component {
}

render(){
const {chartData} = this.state;
const {chartData, err} = this.state;

return err ?
this.renderError() :
(chartData && chartData.length > 0 ?
this.renderChart() : <div>No data</div>)

if(chartData){
return chartData.length > 0 && this.renderChart();
} else {
return this.renderError();
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/filters/FiltersItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ class FiltersItem extends Component {
const {filter} = this.state;

if(
filter &&
filter.parametersLayoutType === 'singleOverlayField' &&
filter &&
filter.parametersLayoutType === 'singleOverlayField' &&
!filter.parameters[0].value
){
return this.handleClear();
}

applyFilters(filter, () => {
closeFilterMenu();
});
Expand Down

0 comments on commit 7d92cda

Please sign in to comment.