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

View File

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