Merge last commit

This commit is contained in:
canove
2020-07-24 16:43:07 -03:00
parent 9292c2c27d
commit 829d6b6070
2 changed files with 15 additions and 12 deletions

View File

@@ -52,14 +52,9 @@ const useStyles = makeStyles(theme => ({
}, },
})); }));
const ContactModal = ({ const ContactModal = ({ modalOpen, onClose, contactId }) => {
modalOpen,
setModalOpen,
handleAddContact,
onClose,
contactId,
}) => {
const classes = useStyles(); const classes = useStyles();
const initialState = { const initialState = {
name: "", name: "",
number: "", number: "",
@@ -90,10 +85,14 @@ const ContactModal = ({
}; };
const handleSaveContact = async values => { const handleSaveContact = async values => {
if (contactId) { try {
await api.put(`/contacts/${contactId}`, values); if (contactId) {
} else { await api.put(`/contacts/${contactId}`, values);
await api.post("/contacts", values); } else {
await api.post("/contacts", values);
}
} catch (err) {
alert(err);
} }
handleClose(); handleClose();
}; };

View File

@@ -179,7 +179,11 @@ const Contacts = () => {
}; };
const handleDeleteContact = async contactId => { const handleDeleteContact = async contactId => {
await api.delete(`/contacts/${contactId}`); try {
await api.delete(`/contacts/${contactId}`);
} catch (err) {
alert(err);
}
setDeletingContact(null); setDeletingContact(null);
}; };