74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { useParams } from 'react-router-dom'
|
|
import FormButtons from './FormButtons'
|
|
import { FormProps } from './types'
|
|
import { useGridData } from './useFormData'
|
|
import { FormPageShell } from './shared/FormPageShell'
|
|
|
|
const FormEdit = (props: FormProps = { isSubForm: false }) => {
|
|
const mode = 'edit'
|
|
const { isSubForm, level, onActionView, onActionNew } = props
|
|
const params = useParams()
|
|
const listFormCode = props?.listFormCode ?? params?.listFormCode ?? ''
|
|
const id = props?.id ?? params?.id ?? ''
|
|
|
|
const {
|
|
fetchData,
|
|
setFormData,
|
|
handleSubmit,
|
|
loading,
|
|
gridDto,
|
|
dataSource,
|
|
commandColumnData,
|
|
filter,
|
|
formData,
|
|
formItems,
|
|
refForm,
|
|
permissionResults,
|
|
} = useGridData({
|
|
mode,
|
|
listFormCode,
|
|
id,
|
|
level,
|
|
isSubForm,
|
|
onSubmitAction: onActionView,
|
|
})
|
|
|
|
return (
|
|
<FormPageShell
|
|
mode={mode}
|
|
listFormCode={listFormCode}
|
|
isSubForm={isSubForm}
|
|
level={level}
|
|
loading={loading}
|
|
gridDto={gridDto}
|
|
formData={formData}
|
|
formItems={formItems}
|
|
refForm={refForm}
|
|
setFormData={setFormData}
|
|
noteEntityId={id}
|
|
actions={
|
|
permissionResults && (
|
|
<FormButtons
|
|
isSubForm={isSubForm}
|
|
mode={mode}
|
|
listFormCode={listFormCode}
|
|
id={formData?.Id}
|
|
gridDto={gridDto!}
|
|
commandColumnData={commandColumnData!}
|
|
dataSource={dataSource!}
|
|
permissions={permissionResults}
|
|
handleSubmit={handleSubmit}
|
|
refreshData={fetchData}
|
|
getSelectedRowKeys={() => [id]}
|
|
getSelectedRowsData={() => [formData]}
|
|
getFilter={() => filter}
|
|
onActionView={onActionView}
|
|
onActionNew={onActionNew}
|
|
/>
|
|
)
|
|
}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default FormEdit
|