added functionality to delete crm customer

main
alex 2024-08-12 20:19:23 +02:00
parent adf671bbd9
commit 9380798f96
4 changed files with 39 additions and 0 deletions

View File

@ -410,6 +410,10 @@
"infoQrCode": "Mit dem Smartphone scannen zum Anrufen" "infoQrCode": "Mit dem Smartphone scannen zum Anrufen"
} }
}, },
"popconfirmDeleteCustomer": {
"title": "Kunde löschen",
"description": "Sind Sie sicher, dass Sie diesen Kunden löschen wollen?"
},
"logCard": { "logCard": {
"popover": { "popover": {
"groupTaskId.title": "Gruppenaufgabe", "groupTaskId.title": "Gruppenaufgabe",

View File

@ -412,6 +412,10 @@
"telephone": "Telephone", "telephone": "Telephone",
"notes": "Notes" , "notes": "Notes" ,
"infoQrCode": "Scan with your smartphone to call" "infoQrCode": "Scan with your smartphone to call"
},
"popconfirmDeleteCustomer": {
"title": "Delete Customer",
"description": "Are you sure you want to delete this customer?"
} }
}, },
"logCard": { "logCard": {

View File

@ -56,6 +56,7 @@ export const ReceivedMessagesCommands = {
CrmLinkUsed: 52, CrmLinkUsed: 52,
CrmLinkDeleted: 53, CrmLinkDeleted: 53,
CustomerFeedbackAddFeedback: 54, CustomerFeedbackAddFeedback: 54,
CrmCustomerDeleted: 55,
}; };
// commands sent to the backend server // commands sent to the backend server
@ -1125,6 +1126,11 @@ export function handleWebSocketMessage(
case ReceivedMessagesCommands.CustomerFeedbackAddFeedback: case ReceivedMessagesCommands.CustomerFeedbackAddFeedback:
customerFeedbackContext.setCustomerFeedbacks((arr) => [...arr, body]); customerFeedbackContext.setCustomerFeedbacks((arr) => [...arr, body]);
break; break;
case ReceivedMessagesCommands.CrmCustomerDeleted:
crmContext.setCustomers((arr) =>
arr.filter((customer) => customer.Id !== body)
);
break;
default: default:
console.error("unknown command", cmd); console.error("unknown command", cmd);
break; break;

View File

@ -41,6 +41,7 @@ import {
SearchOutlined, SearchOutlined,
PhoneOutlined, PhoneOutlined,
DeleteOutlined, DeleteOutlined,
QuestionCircleOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { t } from "i18next"; import { t } from "i18next";
import { useCrmContext } from "../../Contexts/CrmContext"; import { useCrmContext } from "../../Contexts/CrmContext";
@ -877,6 +878,30 @@ function CustomerDrawer({ isOpen, setIsOpen, onClose, notificationApi }) {
width={720} width={720}
extra={ extra={
<Space> <Space>
<Popconfirm
title={t("crm.popconfirmDeleteCustomer.title")}
description={t("crm.popconfirmDeleteCustomer.description")}
icon={<QuestionCircleOutlined style={{ color: "red" }} />}
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 }}
>
<Button danger icon={<DeleteOutlined />}>
Delete
</Button>
</Popconfirm>
<CallProtocolModal <CallProtocolModal
formDealInfo={formDealInfo} formDealInfo={formDealInfo}
notificationApi={notificationApi} notificationApi={notificationApi}