mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
Merge last commit
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user