diff --git a/src/components/Dashboard/Inventory/PurchaseOrders/AcknowledgePurchaseOrder.jsx b/src/components/Dashboard/Inventory/PurchaseOrders/AcknowledgePurchaseOrder.jsx new file mode 100644 index 0000000..5126da9 --- /dev/null +++ b/src/components/Dashboard/Inventory/PurchaseOrders/AcknowledgePurchaseOrder.jsx @@ -0,0 +1,46 @@ +import { useState, useContext } from 'react' +import PropTypes from 'prop-types' +import { ApiServerContext } from '../../context/ApiServerContext' +import { message } from 'antd' +import MessageDialogView from '../../common/MessageDialogView.jsx' + +const AcknowledgePurchaseOrder = ({ onOk, objectData }) => { + const [acknowledgeLoading, setAcknowledgeLoading] = useState(false) + const { sendObjectFunction } = useContext(ApiServerContext) + + const handleAcknowledge = async () => { + setAcknowledgeLoading(true) + try { + const result = await sendObjectFunction( + objectData._id, + 'PurchaseOrder', + 'acknowledge' + ) + if (result) { + message.success('Purchase order acknowledged successfully') + onOk(result) + } + } catch (error) { + console.error('Error acknowledging purchase order:', error) + } finally { + setAcknowledgeLoading(false) + } + } + + return ( + + ) +} + +AcknowledgePurchaseOrder.propTypes = { + onOk: PropTypes.func.isRequired, + objectData: PropTypes.object +} + +export default AcknowledgePurchaseOrder diff --git a/src/components/Dashboard/Inventory/PurchaseOrders/CancelPurchaseOrder.jsx b/src/components/Dashboard/Inventory/PurchaseOrders/CancelPurchaseOrder.jsx new file mode 100644 index 0000000..7b54171 --- /dev/null +++ b/src/components/Dashboard/Inventory/PurchaseOrders/CancelPurchaseOrder.jsx @@ -0,0 +1,46 @@ +import { useState, useContext } from 'react' +import PropTypes from 'prop-types' +import { ApiServerContext } from '../../context/ApiServerContext' +import { message } from 'antd' +import MessageDialogView from '../../common/MessageDialogView.jsx' + +const CancelPurchaseOrder = ({ onOk, objectData }) => { + const [cancelLoading, setCancelLoading] = useState(false) + const { sendObjectFunction } = useContext(ApiServerContext) + + const handleCancel = async () => { + setCancelLoading(true) + try { + const result = await sendObjectFunction( + objectData._id, + 'PurchaseOrder', + 'cancel' + ) + if (result) { + message.success('Purchase order cancelled successfully') + onOk(result) + } + } catch (error) { + console.error('Error cancelling purchase order:', error) + } finally { + setCancelLoading(false) + } + } + + return ( + + ) +} + +CancelPurchaseOrder.propTypes = { + onOk: PropTypes.func.isRequired, + objectData: PropTypes.object +} + +export default CancelPurchaseOrder diff --git a/src/components/Dashboard/Inventory/PurchaseOrders/PostPurchaseOrder.jsx b/src/components/Dashboard/Inventory/PurchaseOrders/PostPurchaseOrder.jsx new file mode 100644 index 0000000..d65f5bd --- /dev/null +++ b/src/components/Dashboard/Inventory/PurchaseOrders/PostPurchaseOrder.jsx @@ -0,0 +1,46 @@ +import { useState, useContext } from 'react' +import PropTypes from 'prop-types' +import { ApiServerContext } from '../../context/ApiServerContext' +import { message } from 'antd' +import MessageDialogView from '../../common/MessageDialogView.jsx' + +const PostPurchaseOrder = ({ onOk, objectData }) => { + const [postLoading, setPostLoading] = useState(false) + const { sendObjectFunction } = useContext(ApiServerContext) + + const handlePost = async () => { + setPostLoading(true) + try { + const result = await sendObjectFunction( + objectData._id, + 'PurchaseOrder', + 'post' + ) + if (result) { + message.success('Purchase order posted successfully') + onOk(result) + } + } catch (error) { + console.error('Error posting purchase order:', error) + } finally { + setPostLoading(false) + } + } + + return ( + + ) +} + +PostPurchaseOrder.propTypes = { + onOk: PropTypes.func.isRequired, + objectData: PropTypes.object +} + +export default PostPurchaseOrder