- Modified NewStockAudit and NewStockAuditLevel components to include a default state of 'draft' in their defaultValues, enhancing the initialization process. - Updated StockAuditLevel model to make the 'tags' field required, ensuring necessary data is captured. - Improved data handling in the StockAuditLevel model by refining the value function for better clarity and maintainability.
82 lines
2.1 KiB
JavaScript
82 lines
2.1 KiB
JavaScript
import PropTypes from 'prop-types'
|
|
import ObjectInfo from '../../common/ObjectInfo'
|
|
import NewObjectForm from '../../common/NewObjectForm'
|
|
import WizardView from '../../common/WizardView'
|
|
|
|
const NewStockAudit = ({ onOk, reset, defaultValues }) => {
|
|
return (
|
|
<NewObjectForm
|
|
type='stockAudit'
|
|
reset={reset}
|
|
defaultValues={{
|
|
state: { type: 'draft' },
|
|
auditLines: [],
|
|
...defaultValues
|
|
}}
|
|
>
|
|
{({ handleSubmit, submitLoading, objectData, formValid }) => {
|
|
const steps = [
|
|
{
|
|
title: 'Required',
|
|
key: 'required',
|
|
content: (
|
|
<ObjectInfo
|
|
type='stockAudit'
|
|
column={1}
|
|
bordered={false}
|
|
isEditing={true}
|
|
required={true}
|
|
objectData={objectData}
|
|
visibleProperties={{ auditLines: false }}
|
|
/>
|
|
)
|
|
},
|
|
{
|
|
title: 'Summary',
|
|
key: 'summary',
|
|
content: (
|
|
<ObjectInfo
|
|
type='stockAudit'
|
|
column={1}
|
|
bordered={false}
|
|
visibleProperties={{
|
|
_id: false,
|
|
_reference: false,
|
|
createdAt: false,
|
|
postedAt: false,
|
|
updatedAt: false,
|
|
auditLines: false
|
|
}}
|
|
isEditing={false}
|
|
objectData={objectData}
|
|
/>
|
|
)
|
|
}
|
|
]
|
|
return (
|
|
<WizardView
|
|
steps={steps}
|
|
loading={submitLoading}
|
|
formValid={formValid}
|
|
title='New Stock Audit'
|
|
onSubmit={async () => {
|
|
const result = await handleSubmit()
|
|
if (result) {
|
|
onOk()
|
|
}
|
|
}}
|
|
/>
|
|
)
|
|
}}
|
|
</NewObjectForm>
|
|
)
|
|
}
|
|
|
|
NewStockAudit.propTypes = {
|
|
onOk: PropTypes.func.isRequired,
|
|
reset: PropTypes.bool,
|
|
defaultValues: PropTypes.object
|
|
}
|
|
|
|
export default NewStockAudit
|