Add download button for csv and move plants request to results
This commit is contained in:
parent
35aa9cbe70
commit
2cacd25c16
2 changed files with 42 additions and 21 deletions
|
@ -2,16 +2,12 @@ import React from 'react'
|
|||
import { Container } from 'reactstrap';
|
||||
import Stepper from '../components/Stepper'
|
||||
import Header from '../components/Header'
|
||||
|
||||
import PlantRepository from '../repository/PlantRepository'
|
||||
|
||||
export default class MainPage extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
plants: [],
|
||||
filters: {}
|
||||
}
|
||||
|
||||
|
@ -19,35 +15,20 @@ export default class MainPage extends React.Component {
|
|||
this.resetFilterState = this.resetFilterState.bind(this);
|
||||
}
|
||||
|
||||
updatePlants() {
|
||||
PlantRepository.getFilteredPlants(this.state.filters).then(response => {
|
||||
if (response.status === 200) {
|
||||
this.setState({ plants: response.data });
|
||||
}
|
||||
}).catch(e => {
|
||||
this.setState({ plants: ["No plants found."] });
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
updateFilterState(newFilter) {
|
||||
this.setState({ filters: Object.assign(this.state.filters, newFilter) })
|
||||
this.updatePlants()
|
||||
}
|
||||
|
||||
resetFilterState() {
|
||||
this.setState({ filters: {} })
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.updatePlants()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Container fluid className='main-container p-0'>
|
||||
<Header/>
|
||||
<Stepper
|
||||
plants={this.state.plants}
|
||||
filters={this.state.filters}
|
||||
updateFilterState={this.updateFilterState}
|
||||
resetFilterState={this.resetFilterState} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue