diff --git a/frontend/src/pages/MainPage.js b/frontend/src/pages/MainPage.js index e5351e3..929a0bb 100644 --- a/frontend/src/pages/MainPage.js +++ b/frontend/src/pages/MainPage.js @@ -19,7 +19,7 @@ export default class MainPage extends React.Component { } updatePlants() { - PlantRepsostory.getPlants().then(response => { + PlantRepsostory.getFilteredPlants(this.state.filters).then(response => { if (response.status === 200) { this.setState({ plants: response.data }); } @@ -30,6 +30,7 @@ export default class MainPage extends React.Component { updateFilterState(newFilter) { this.setState({ filters: { ...this.state.filters, ...newFilter } }) + this.updatePlants() } componentDidMount() { diff --git a/frontend/src/repository/PlantRepository.js b/frontend/src/repository/PlantRepository.js index 65c1b98..e8cccc4 100644 --- a/frontend/src/repository/PlantRepository.js +++ b/frontend/src/repository/PlantRepository.js @@ -2,8 +2,8 @@ import Repository from "./Repository"; const PlantRepsostory = { - getPlants() { - return Repository.get(`/plants/`); + getFilteredPlants(filters) { + return Repository.get(`/plants/`, { params: filters }); } }