Modify frontend api call for plants to be filtered

This commit is contained in:
Dana Lambert 2021-10-19 16:07:13 +13:00
parent 12ebe31cf5
commit 10ae4f46ce
2 changed files with 4 additions and 3 deletions

View file

@ -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() {

View file

@ -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 });
} }
} }