diff --git a/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx b/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx
index 5f1e0a4a..64edc6f8 100644
--- a/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx
+++ b/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx
@@ -92,10 +92,6 @@ const InvoiceInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx b/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx
index bbc4d0a4..31503971 100644
--- a/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx
+++ b/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx
@@ -85,10 +85,6 @@ const PaymentInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx b/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx
index c086c2d4..4b86aa65 100644
--- a/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx
+++ b/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx
@@ -77,10 +77,6 @@ const TaxRecordInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx b/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx
index 1ba17839..52491635 100644
--- a/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx
+++ b/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx
@@ -78,10 +78,6 @@ const OrderItemInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx b/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx
index d64e0ca1..99ae075f 100644
--- a/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx
+++ b/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx
@@ -98,10 +98,6 @@ const ProductStockInfo = () => {
objectFormRef?.current.handleUpdate()
return true
},
- delete: () => {
- objectFormRef?.current.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx b/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx
index 91201b80..51c6583d 100644
--- a/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx
+++ b/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx
@@ -103,10 +103,6 @@ const PurchaseOrderInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx b/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx
index 054b02be..9a0d832d 100644
--- a/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx
+++ b/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx
@@ -96,10 +96,6 @@ const PurchaseOrderInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- },
newOrderItem: () => {
setNewOrderItemOpen(true)
return true
diff --git a/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx b/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx
index f4d8a644..95bfd1a3 100644
--- a/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx
+++ b/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx
@@ -88,10 +88,6 @@ const ShipmentInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx b/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx
index 0d7ed3ed..e8830c38 100644
--- a/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx
+++ b/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx
@@ -88,10 +88,6 @@ const StockTransferInfo = () => {
objectFormRef?.current.handleUpdate()
return true
},
- delete: () => {
- objectFormRef?.current.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx b/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx
index e830cd80..0503d4a8 100644
--- a/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx
+++ b/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx
@@ -79,10 +79,6 @@ const CourierServiceInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Couriers/CourierInfo.jsx b/src/components/Dashboard/Management/Couriers/CourierInfo.jsx
index 7a737d22..1c7a8ae0 100644
--- a/src/components/Dashboard/Management/Couriers/CourierInfo.jsx
+++ b/src/components/Dashboard/Management/Couriers/CourierInfo.jsx
@@ -75,10 +75,6 @@ const CourierInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx b/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx
index c3b1fd5c..ab4b5990 100644
--- a/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx
+++ b/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx
@@ -74,10 +74,6 @@ const FilamentSkuInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx b/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx
index 5c1b17aa..7fc7dff8 100644
--- a/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx
+++ b/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx
@@ -93,10 +93,6 @@ const FilamentInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Files/FileInfo.jsx b/src/components/Dashboard/Management/Files/FileInfo.jsx
index 412a372c..781ad24f 100644
--- a/src/components/Dashboard/Management/Files/FileInfo.jsx
+++ b/src/components/Dashboard/Management/Files/FileInfo.jsx
@@ -87,10 +87,6 @@ const FileInfo = () => {
fetchFileContent(objectFormState?.objectData, true)
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Hosts/HostInfo.jsx b/src/components/Dashboard/Management/Hosts/HostInfo.jsx
index a0ab9dad..4df4fd47 100644
--- a/src/components/Dashboard/Management/Hosts/HostInfo.jsx
+++ b/src/components/Dashboard/Management/Hosts/HostInfo.jsx
@@ -88,10 +88,6 @@ const HostInfo = () => {
objectFormRef?.current.handleUpdate()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Materials/MaterialInfo.jsx b/src/components/Dashboard/Management/Materials/MaterialInfo.jsx
index 3c23a2f4..da7ebdd1 100644
--- a/src/components/Dashboard/Management/Materials/MaterialInfo.jsx
+++ b/src/components/Dashboard/Management/Materials/MaterialInfo.jsx
@@ -77,10 +77,6 @@ const MaterialInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Notes/NoteInfo.jsx b/src/components/Dashboard/Management/Notes/NoteInfo.jsx
index f23e145b..b36c139d 100644
--- a/src/components/Dashboard/Management/Notes/NoteInfo.jsx
+++ b/src/components/Dashboard/Management/Notes/NoteInfo.jsx
@@ -78,10 +78,6 @@ const NoteInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx b/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx
index 3a58a40a..ed7d05f1 100644
--- a/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx
+++ b/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx
@@ -69,10 +69,6 @@ const PartSkuInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/PermissionSettings/PermissionSettingInfo.jsx b/src/components/Dashboard/Management/PermissionSettings/PermissionSettingInfo.jsx
index 21af764f..c6bfe75e 100644
--- a/src/components/Dashboard/Management/PermissionSettings/PermissionSettingInfo.jsx
+++ b/src/components/Dashboard/Management/PermissionSettings/PermissionSettingInfo.jsx
@@ -81,10 +81,6 @@ const PermissionSettingInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx b/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx
index ede02d46..c041e98d 100644
--- a/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx
+++ b/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx
@@ -74,10 +74,6 @@ const ProductCategoryInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx b/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx
index 592a7c17..a39eaae2 100644
--- a/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx
+++ b/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx
@@ -75,10 +75,6 @@ const ProductSkuInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx b/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx
index e7de6139..c3b0b289 100644
--- a/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx
+++ b/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx
@@ -74,10 +74,6 @@ const TaxRateInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/UserGroups/UserGroupInfo.jsx b/src/components/Dashboard/Management/UserGroups/UserGroupInfo.jsx
index d521e906..b871c97c 100644
--- a/src/components/Dashboard/Management/UserGroups/UserGroupInfo.jsx
+++ b/src/components/Dashboard/Management/UserGroups/UserGroupInfo.jsx
@@ -81,10 +81,6 @@ const UserGroupInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Management/Vendors/VendorInfo.jsx b/src/components/Dashboard/Management/Vendors/VendorInfo.jsx
index 6f70de56..7c26d66f 100644
--- a/src/components/Dashboard/Management/Vendors/VendorInfo.jsx
+++ b/src/components/Dashboard/Management/Vendors/VendorInfo.jsx
@@ -74,10 +74,6 @@ const VendorInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx b/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx
index a36d3e72..d9f00d6e 100644
--- a/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx
+++ b/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx
@@ -112,10 +112,6 @@ const FilamentProfileInfo = () => {
objectFormRef.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx b/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx
index 2e64b24e..fd027b9a 100644
--- a/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx
+++ b/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx
@@ -90,10 +90,6 @@ const PrinterProfileInfo = () => {
objectFormRef.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Sales/Clients/ClientInfo.jsx b/src/components/Dashboard/Sales/Clients/ClientInfo.jsx
index b9d04dab..4d280a1e 100644
--- a/src/components/Dashboard/Sales/Clients/ClientInfo.jsx
+++ b/src/components/Dashboard/Sales/Clients/ClientInfo.jsx
@@ -74,10 +74,6 @@ const ClientInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx b/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx
index 84fad8c2..055dd655 100644
--- a/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx
+++ b/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx
@@ -88,10 +88,6 @@ const ListingVarientInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx
index 414470e9..0e9a3c47 100644
--- a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx
+++ b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx
@@ -86,10 +86,6 @@ const ListingInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx b/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx
index a71c7c32..e55e92e2 100644
--- a/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx
+++ b/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx
@@ -143,10 +143,6 @@ const MarketplaceInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- },
connect: () => {
startAuthorization()
return true
diff --git a/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx b/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx
index 6ebec2de..602c5fe3 100644
--- a/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx
+++ b/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx
@@ -101,10 +101,6 @@ const SalesOrderInfo = () => {
objectFormRef?.current?.handleUpdate?.()
return true
},
- delete: () => {
- objectFormRef?.current?.handleDelete?.()
- return true
- }
}
return (
diff --git a/src/components/Dashboard/common/ActionHandler.jsx b/src/components/Dashboard/common/ActionHandler.jsx
index 34686cc4..fda1ec98 100644
--- a/src/components/Dashboard/common/ActionHandler.jsx
+++ b/src/components/Dashboard/common/ActionHandler.jsx
@@ -16,7 +16,9 @@ const ActionHandler = forwardRef(
) => {
const location = useLocation()
const navigate = useNavigate()
- const action = new URLSearchParams(location.search).get(actionParam)
+ const searchParams = new URLSearchParams(location.search)
+ const action = searchParams.get(actionParam)
+ const actionObjectType = searchParams.get('actionObjectType')
// Ref to track last executed action
const lastExecutedAction = useRef(null)
@@ -44,6 +46,7 @@ const ActionHandler = forwardRef(
if (
loading == false &&
action &&
+ !actionObjectType &&
actions[action] &&
lastExecutedAction.current !== action
) {
@@ -71,6 +74,7 @@ const ActionHandler = forwardRef(
}, [
loading,
action,
+ actionObjectType,
actions,
actionParam,
clearAfterExecute,
diff --git a/src/components/Dashboard/common/DeleteObject.jsx b/src/components/Dashboard/common/DeleteObject.jsx
new file mode 100644
index 00000000..a53a6b7e
--- /dev/null
+++ b/src/components/Dashboard/common/DeleteObject.jsx
@@ -0,0 +1,76 @@
+import { useState, useContext } from 'react'
+import PropTypes from 'prop-types'
+import { useLocation, useNavigate } from 'react-router-dom'
+import { ApiServerContext } from '../context/ApiServerContext'
+import { useMessageContext } from '../context/MessageContext'
+import { useActions } from '../context/ActionsContext'
+import { getModelByName } from '../../../database/ObjectModels'
+import MessageDialogView from './MessageDialogView.jsx'
+import BinIcon from '../../Icons/BinIcon'
+
+const capitalizeFirstLetter = (value) => {
+ return String(value).charAt(0).toUpperCase() + String(value).slice(1)
+}
+
+const DeleteObject = ({ onOk, objectData, objectType: objectTypeProp }) => {
+ const [deleteLoading, setDeleteLoading] = useState(false)
+ const { deleteObject } = useContext(ApiServerContext)
+ const { showSuccess, showError } = useMessageContext()
+ const { currentObjectType } = useActions()
+ const location = useLocation()
+ const navigate = useNavigate()
+
+ const objectType =
+ objectTypeProp ||
+ new URLSearchParams(location.search).get('actionObjectType') ||
+ currentObjectType
+
+ const model = objectType ? getModelByName(objectType) : null
+ const modelLabel = model?.label || 'object'
+ const objectName =
+ objectData?.name || objectData?._reference || objectData?._id
+
+ const handleDelete = async () => {
+ if (!objectData?._id || !objectType) return
+ setDeleteLoading(true)
+ try {
+ await deleteObject(objectData._id, objectType)
+ showSuccess(
+ `${capitalizeFirstLetter(modelLabel.toLowerCase())} deleted successfully!`
+ )
+ const onInfoPage = model?.url && location.pathname === `${model.url}/info`
+ if (onInfoPage) {
+ navigate(model.url)
+ } else {
+ onOk()
+ }
+ } catch (error) {
+ console.error('Error deleting object:', error)
+ showError(`Failed to delete ${modelLabel.toLowerCase()}.`)
+ } finally {
+ setDeleteLoading(false)
+ }
+ }
+
+ return (
+ }
+ title={`Are you sure you want to delete this ${modelLabel.toLowerCase()}?`}
+ description={
+ objectName ? `This will permanently delete ${objectName}.` : undefined
+ }
+ onOk={handleDelete}
+ okText='Delete'
+ okLoading={deleteLoading}
+ danger
+ />
+ )
+}
+
+DeleteObject.propTypes = {
+ onOk: PropTypes.func.isRequired,
+ objectData: PropTypes.object,
+ objectType: PropTypes.string
+}
+
+export default DeleteObject
diff --git a/src/components/Dashboard/common/DeleteObjectModal.jsx b/src/components/Dashboard/common/DeleteObjectModal.jsx
deleted file mode 100644
index b1fe7946..00000000
--- a/src/components/Dashboard/common/DeleteObjectModal.jsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import PropTypes from 'prop-types'
-import { Modal, Button, Space, Typography } from 'antd'
-import { getModelByName } from '../../../database/ObjectModels'
-import BinIcon from '../../Icons/BinIcon'
-
-const { Text } = Typography
-
-const DeleteObjectModal = ({ open, onOk, onCancel, loading, objectType }) => {
- const model = getModelByName(objectType)
- return (
-
-
- {`Confirm Delete ${model.label}`}
-
- }
- onOk={onOk}
- onCancel={onCancel}
- okText='Delete'
- cancelText='Cancel'
- okType='danger'
- closable={false}
- centered
- maskClosable={false}
- footer={[
- ,
-
- ]}
- >
-
- Are you sure you want to delete this {model.label.toLowerCase()}?
-
-
- )
-}
-
-DeleteObjectModal.propTypes = {
- open: PropTypes.bool.isRequired,
- onOk: PropTypes.func.isRequired,
- onCancel: PropTypes.func.isRequired,
- loading: PropTypes.bool,
- objectType: PropTypes.string.isRequired
-}
-
-export default DeleteObjectModal
diff --git a/src/components/Dashboard/common/MessageDialogView.jsx b/src/components/Dashboard/common/MessageDialogView.jsx
index c9a28a18..0fef57a6 100644
--- a/src/components/Dashboard/common/MessageDialogView.jsx
+++ b/src/components/Dashboard/common/MessageDialogView.jsx
@@ -10,7 +10,8 @@ const MessageDialogView = ({
description,
onOk,
okText,
- okLoading
+ okLoading,
+ danger = false
}) => {
return (
@@ -20,7 +21,12 @@ const MessageDialogView = ({
{description && {description}}
-
@@ -34,7 +40,8 @@ MessageDialogView.propTypes = {
description: PropTypes.node,
onOk: PropTypes.func.isRequired,
okText: PropTypes.string,
- okLoading: PropTypes.bool
+ okLoading: PropTypes.bool,
+ danger: PropTypes.bool
}
export default MessageDialogView
diff --git a/src/components/Dashboard/common/ObjectForm.jsx b/src/components/Dashboard/common/ObjectForm.jsx
index 7f1382ba..8c91ac7b 100644
--- a/src/components/Dashboard/common/ObjectForm.jsx
+++ b/src/components/Dashboard/common/ObjectForm.jsx
@@ -11,7 +11,6 @@ import { Form } from 'antd'
import { ApiServerContext } from '../context/ApiServerContext'
import { AuthContext } from '../context/AuthContext'
import { useMessageContext } from '../context/MessageContext'
-import DeleteObjectModal from './DeleteObjectModal'
import merge from 'lodash/merge'
import mergeWith from 'lodash/mergeWith'
import set from 'lodash/set'
@@ -157,12 +156,9 @@ const ObjectForm = forwardRef(
const [form] = Form.useForm()
const formUpdateValues = Form.useWatch([], form)
const { showSuccess, showError } = useMessageContext()
- const [deleteModalOpen, setDeleteModalOpen] = useState(false)
- const [deleteLoading, setDeleteLoading] = useState(false)
const {
fetchObject,
updateObject,
- deleteObject,
setObjectActivity,
clearObjectActivity,
fetchObjectActivities,
@@ -777,34 +773,10 @@ const ObjectForm = forwardRef(
onStateChangeRef.current({ editLoading: false })
}
- const handleDelete = () => {
- setDeleteModalOpen(true)
- }
-
- const confirmDelete = async () => {
- setDeleteLoading(true)
- try {
- await deleteObject(id, type)
- setDeleteModalOpen(false)
- showSuccess(`${getModelMessageLabel(type)} deleted successfully!`)
- navigate(-2)
- // Optionally: trigger a callback to parent to remove this object from view
- } catch (err) {
- console.error(err)
- showError(
- `Failed to delete ${getModelMessageLabel(type).toLowerCase()}.`
- )
- } finally {
- setDeleteLoading(false)
- }
- }
-
useImperativeHandle(ref, () => ({
startEditing,
cancelEditing,
handleUpdate,
- handleDelete,
- confirmDelete,
handleFetchObject,
editLoading,
fetchLoading,
@@ -815,14 +787,6 @@ const ObjectForm = forwardRef(
return (
<>
- setDeleteModalOpen(false)}
- loading={deleteLoading}
- objectType={type}
- objectName={objectData?.name || objectData?.label || ''}
- />