Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/SetList/SetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ export default class SetList extends Component {
}

getClassificationResults = () => {
const data = this.props.location.state.results; // classification results passed in from Classify view
let categories = Object.keys(data);
const results = categories.map(category => {
return {category: category, data: data[category]};
});
this.setState({
results: results
});
if (this.props.location.state) {
const data = this.props.location.state.results; // classification results passed in from Classify view
let categories = Object.keys(data);
const results = categories.map(category => {
return {category: category, data: data[category]};
});
this.setState({
results: results
});
} else {
this.props.history.push('/');
}
};

renderResultsView = (index) => {
Expand Down
26 changes: 15 additions & 11 deletions src/SetList/SetResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ export default class SetResult extends Component {
}

componentWillMount() {
const jsonData = this.props.location.state.data;
const download = {
filename: this.generateDownloadFilename(jsonData),
rhef: this.generateDownloadHref(jsonData)
};
this.setState({
title: this.props.location.state.data.category,
results: this.props.location.state.data.data,
download: download
});
if (this.props.location.state) {
const jsonData = this.props.location.state.data;
const download = {
filename: this.generateDownloadFilename(jsonData),
rhef: this.generateDownloadHref(jsonData)
};
this.setState({
title: this.props.location.state.data.category,
results: this.props.location.state.data.data,
download: download
});
} else {
this.props.history.push('/');
}
}

generateDownloadFilename = (jsonData) => {
Expand Down Expand Up @@ -104,7 +108,7 @@ export default class SetResult extends Component {
</Button>
</Grid>
<Grid item>
{this.renderClassifications(this.state.results)}
{this.state.results ? this.renderClassifications(this.state.results) : null}
</Grid>
</Grid>
</div>
Expand Down