diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 3c296a3..de3e654 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -410,6 +410,10 @@ "infoQrCode": "Mit dem Smartphone scannen zum Anrufen" } }, + "popconfirmDeleteCustomer": { + "title": "Kunde löschen", + "description": "Sind Sie sicher, dass Sie diesen Kunden löschen wollen?" + }, "logCard": { "popover": { "groupTaskId.title": "Gruppenaufgabe", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index c62a702..a83fe52 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -412,6 +412,10 @@ "telephone": "Telephone", "notes": "Notes" , "infoQrCode": "Scan with your smartphone to call" + }, + "popconfirmDeleteCustomer": { + "title": "Delete Customer", + "description": "Are you sure you want to delete this customer?" } }, "logCard": { diff --git a/src/Handlers/WebSocketMessageHandler.js b/src/Handlers/WebSocketMessageHandler.js index 6350506..988171b 100644 --- a/src/Handlers/WebSocketMessageHandler.js +++ b/src/Handlers/WebSocketMessageHandler.js @@ -56,6 +56,7 @@ export const ReceivedMessagesCommands = { CrmLinkUsed: 52, CrmLinkDeleted: 53, CustomerFeedbackAddFeedback: 54, + CrmCustomerDeleted: 55, }; // commands sent to the backend server @@ -1125,6 +1126,11 @@ export function handleWebSocketMessage( case ReceivedMessagesCommands.CustomerFeedbackAddFeedback: customerFeedbackContext.setCustomerFeedbacks((arr) => [...arr, body]); break; + case ReceivedMessagesCommands.CrmCustomerDeleted: + crmContext.setCustomers((arr) => + arr.filter((customer) => customer.Id !== body) + ); + break; default: console.error("unknown command", cmd); break; diff --git a/src/Pages/CrmTest/CrmTest.js b/src/Pages/CrmTest/CrmTest.js index 794257b..5fb37a0 100644 --- a/src/Pages/CrmTest/CrmTest.js +++ b/src/Pages/CrmTest/CrmTest.js @@ -41,6 +41,7 @@ import { SearchOutlined, PhoneOutlined, DeleteOutlined, + QuestionCircleOutlined, } from "@ant-design/icons"; import { t } from "i18next"; import { useCrmContext } from "../../Contexts/CrmContext"; @@ -877,6 +878,30 @@ function CustomerDrawer({ isOpen, setIsOpen, onClose, notificationApi }) { width={720} extra={ + } + okText={t("common.button.delete")} + cancelText={t("common.button.cancel")} + onConfirm={() => { + myFetch( + `/crm/customer/delete/${crmContext.openDrawerCustomerId.current}`, + "DELETE" + ) + .then(() => { + handleCloseDrawer(); + onClose(); + }) + .catch((status) => handleRequestError(status)); + }} + okButtonProps={{ danger: true }} + > + + +