Modify frontend api call for plants to be filtered
This commit is contained in:
parent
12ebe31cf5
commit
10ae4f46ce
2 changed files with 4 additions and 3 deletions
|
@ -19,7 +19,7 @@ export default class MainPage extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePlants() {
|
updatePlants() {
|
||||||
PlantRepsostory.getPlants().then(response => {
|
PlantRepsostory.getFilteredPlants(this.state.filters).then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.setState({ plants: response.data });
|
this.setState({ plants: response.data });
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ export default class MainPage extends React.Component {
|
||||||
|
|
||||||
updateFilterState(newFilter) {
|
updateFilterState(newFilter) {
|
||||||
this.setState({ filters: { ...this.state.filters, ...newFilter } })
|
this.setState({ filters: { ...this.state.filters, ...newFilter } })
|
||||||
|
this.updatePlants()
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import Repository from "./Repository";
|
||||||
|
|
||||||
const PlantRepsostory = {
|
const PlantRepsostory = {
|
||||||
|
|
||||||
getPlants() {
|
getFilteredPlants(filters) {
|
||||||
return Repository.get(`/plants/`);
|
return Repository.get(`/plants/`, { params: filters });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue