Tom Butcher 972fdb62ad Add Stock Audit Level Management Features and Enhance Stock Audit Components
- Introduced Stock Audit Level management components, including StockAuditLevels, NewStockAuditLevel, and StockAuditLevelInfo, to facilitate the creation and management of stock audit levels.
- Enhanced existing StockAudit components by adding a PostStockAudit feature for posting stock audits and updating the NewStockAudit form to handle draft states.
- Updated StockAuditInfo to include new properties and improved visibility settings for audit lines, enhancing user experience and data representation.
- Refactored ObjectModels and sidebar configurations to integrate Stock Audit Levels into the management dashboard, improving navigation and accessibility.
- Added new utility functions and improved data handling across components to ensure seamless integration and performance.
2026-09-01 15:41:35 +01:00

47 lines
1.3 KiB
JavaScript

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 PostStockAudit = ({ onOk, objectData }) => {
const [postLoading, setPostLoading] = useState(false)
const { sendObjectFunction } = useContext(ApiServerContext)
const handlePost = async () => {
setPostLoading(true)
try {
const result = await sendObjectFunction(
objectData._id,
'StockAudit',
'post'
)
if (result) {
message.success('Stock audit posted')
onOk(result)
}
} catch (error) {
console.error('Error posting stock audit:', error)
} finally {
setPostLoading(false)
}
}
return (
<MessageDialogView
title={'Post this stock audit?'}
description={`Posting will create stock events for audit lines with variance, adjust stock for each SKU at the selected location, and mark this audit as complete.`}
onOk={handlePost}
okText='Post'
okLoading={postLoading}
/>
)
}
PostStockAudit.propTypes = {
onOk: PropTypes.func.isRequired,
objectData: PropTypes.object
}
export default PostStockAudit