Commit 3cf2f8cd authored by Martin Fahl's avatar Martin Fahl

changes behaviour for submitting with empty name

parent 036dc8a5
......@@ -32,8 +32,6 @@ const AddDialog = ({ name, quantity, isOpen, handleClose, handleCancel, handleAd
/>
</Grid>
</Grid>
</form>
</DialogContent>
<DialogActions>
......
......@@ -26,6 +26,13 @@ const getNewQuantity = createSelector(
}
)
const handleAdd = (name, quantity, dispatch) => {
if (name !== "") {
dispatch(closeAddDialog());
dispatch(addItem(name, quantity))
}
}
const mapStateToProps = state => ({
isOpen: getIsOpen(state),
name: getNewName(state),
......@@ -35,10 +42,7 @@ const mapStateToProps = state => ({
const mapDispatchToProps = (dispatch) => ({
handleClose: () => dispatch(closeAddDialog()),
handleCancel: () => dispatch(closeAddDialog()),
handleAdd: (name, quantity) => {
dispatch(closeAddDialog());
dispatch(addItem(name, quantity))
},
handleAdd: (name, quantity) => handleAdd(name, quantity, dispatch),
updateName: event => dispatch(updateAddDialogName(event.target.value)),
updateQuantity: event => dispatch(updateAddDialogQuantity(Number(event.target.value)))
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment