2025-08-21 12:26:25 +00:00
|
|
|
import { Container, Loading } from '@/components/shared'
|
2025-05-06 06:45:49 +00:00
|
|
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
|
|
|
|
import { Helmet } from 'react-helmet'
|
|
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
|
|
import FormButtons from './FormButtons'
|
|
|
|
|
import FormDevExpress from './FormDevExpress'
|
|
|
|
|
import SubForms from './SubForms'
|
|
|
|
|
import { FormProps } from './types'
|
|
|
|
|
import { useGridData } from './useGridData'
|
2025-09-23 10:30:57 +00:00
|
|
|
import { useCurrentMenuIcon } from '@/utils/hooks/useCurrentMenuIcon'
|
|
|
|
|
import { Badge } from '@/components/ui'
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
|
|
|
const FormEdit = (
|
|
|
|
|
props: FormProps = {
|
|
|
|
|
isSubForm: false,
|
|
|
|
|
onActionView: () => {},
|
|
|
|
|
onActionNew: () => {},
|
|
|
|
|
},
|
|
|
|
|
) => {
|
|
|
|
|
const mode = 'edit'
|
|
|
|
|
const { isSubForm, level } = props
|
|
|
|
|
const params = useParams()
|
|
|
|
|
const listFormCode = props?.listFormCode ?? params?.listFormCode ?? ''
|
|
|
|
|
const id = props?.id ?? params?.id ?? ''
|
2025-09-23 10:30:57 +00:00
|
|
|
const MenuIcon = useCurrentMenuIcon('w-5 h-5')
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
|
|
|
const { translate } = useLocalization()
|
|
|
|
|
const {
|
|
|
|
|
fetchData,
|
|
|
|
|
setFormData,
|
|
|
|
|
handleSubmit,
|
|
|
|
|
loading,
|
|
|
|
|
gridDto,
|
|
|
|
|
dataSource,
|
|
|
|
|
commandColumnData,
|
|
|
|
|
filter,
|
|
|
|
|
formData,
|
|
|
|
|
formItems,
|
|
|
|
|
refForm,
|
|
|
|
|
permissionResults,
|
|
|
|
|
} = useGridData({
|
|
|
|
|
mode: 'edit',
|
|
|
|
|
listFormCode,
|
|
|
|
|
id,
|
|
|
|
|
level,
|
|
|
|
|
isSubForm,
|
|
|
|
|
onSubmitAction: props?.onActionView,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (!listFormCode) {
|
|
|
|
|
return <></>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
|
return <Loading type="cover" loading={loading}></Loading>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!formData) {
|
|
|
|
|
return <>{translate('::Error:0002')}</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2025-08-21 12:26:25 +00:00
|
|
|
<Container>
|
2025-05-06 06:45:49 +00:00
|
|
|
{!isSubForm && (
|
|
|
|
|
<Helmet
|
2025-09-13 11:46:34 +00:00
|
|
|
titleTemplate="%s | Sözsoft Kurs Platform"
|
2025-05-06 06:45:49 +00:00
|
|
|
title={translate('::' + gridDto?.gridOptions.title)}
|
2025-09-13 11:46:34 +00:00
|
|
|
defaultTitle="Sözsoft Kurs Platform"
|
2025-05-06 06:45:49 +00:00
|
|
|
></Helmet>
|
|
|
|
|
)}
|
2025-09-23 10:30:57 +00:00
|
|
|
|
2025-09-23 09:26:20 +00:00
|
|
|
<div
|
|
|
|
|
className={`flex items-center pb-2 px-2 ${isSubForm ? 'justify-end' : 'justify-between'}`}
|
|
|
|
|
>
|
2025-09-23 10:30:57 +00:00
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
{MenuIcon}
|
|
|
|
|
{!isSubForm && (
|
|
|
|
|
<>
|
|
|
|
|
<h4 className="text-slate-700 text-sm font-medium leading-none">
|
|
|
|
|
{translate('::' + gridDto?.gridOptions?.title)}
|
|
|
|
|
</h4>
|
|
|
|
|
<Badge content={mode} />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-05-06 06:45:49 +00:00
|
|
|
{permissionResults && (
|
|
|
|
|
<FormButtons
|
2025-09-21 14:42:24 +00:00
|
|
|
isSubForm={isSubForm}
|
2025-05-06 06:45:49 +00:00
|
|
|
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={props?.onActionView}
|
|
|
|
|
onActionNew={props?.onActionNew}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-09-23 09:26:20 +00:00
|
|
|
<div className="px-2">
|
|
|
|
|
<FormDevExpress
|
|
|
|
|
mode={mode}
|
|
|
|
|
refForm={refForm}
|
|
|
|
|
formData={formData}
|
|
|
|
|
formItems={formItems}
|
|
|
|
|
setFormData={setFormData}
|
|
|
|
|
listFormCode={listFormCode}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-05-06 06:45:49 +00:00
|
|
|
<SubForms gridDto={gridDto!} formData={formData} level={level ?? 0} />
|
2025-08-21 12:26:25 +00:00
|
|
|
</Container>
|
2025-05-06 06:45:49 +00:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default FormEdit
|