Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Fix inventory category updating incorrectly #170

Merged
Merged
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
29 changes: 23 additions & 6 deletions client/modules/food/components/inventory/FoodItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,30 @@ class FoodItems extends React.Component {
foodName: value => {
if (typeof value === 'string') {
// The user entered a food name that does not exist yet
this.setState({ modalInputFields: { ...this.state.modalInputFields, name: value, categoryId:"" } }, this.validate)
} else {
this.setState({
modalInputFields: {
...this.state.modalInputFields,
name: value,
categoryId: this.state.modalInputFields.categoryId
}
}, this.validate)
} else if (value !== null) {
// The user entered an existing food name and autosuggest provided the object for that food
this.setState({ modalInputFields: { ...this.state.modalInputFields,
name: value ? value.name : "",
categoryId: value ? value.categoryId : ""
} }, this.validate)
this.setState({
modalInputFields: {
...this.state.modalInputFields,
name: value ? value.name : "",
categoryId: value ? value.categoryId : ""
}
}, this.validate)
} else {
this.setState({
modalInputFields: {
...this.state.modalInputFields,
name: "",
categoryId: this.state.modalInputFields.categoryId
}
}, this.validate)
}
},
foodQuantity: e =>
Expand Down