forked from ddrilling/asb_cloud_front
Добавлена страница типов компаний
This commit is contained in:
parent
f90856f712
commit
bc827117ab
62
src/pages/AdminPanel/CompanyTypeController.jsx
Normal file
62
src/pages/AdminPanel/CompanyTypeController.jsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
||||||
|
import LoaderPortal from '../../components/LoaderPortal'
|
||||||
|
import { EditableTable, makeColumn, makeActionHandler, makeStringSorter } from '../../components/Table'
|
||||||
|
import { AdminCompanyTypeService } from '../../services/api'
|
||||||
|
import { arrayOrDefault } from '../../utils'
|
||||||
|
import { min1 } from '../../utils/validationRules'
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
makeColumn('Название', 'caption', {
|
||||||
|
width: 200,
|
||||||
|
editable: true,
|
||||||
|
sorter: makeStringSorter('caption'),
|
||||||
|
formItemRules: min1,
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
|
const pagination = {
|
||||||
|
defaultPageSize: 16,
|
||||||
|
showSizeChanger: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CompanyTypeController = () => {
|
||||||
|
const [companyTypes, setCompanyTypes] = useState([])
|
||||||
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
|
|
||||||
|
const updateTable = () => invokeWebApiWrapperAsync(
|
||||||
|
async() => {
|
||||||
|
const companyTypes = await AdminCompanyTypeService.getAll()
|
||||||
|
setCompanyTypes(arrayOrDefault(companyTypes))
|
||||||
|
},
|
||||||
|
setShowLoader,
|
||||||
|
`Не удалось загрузить список типов компаний`
|
||||||
|
)
|
||||||
|
|
||||||
|
useEffect(updateTable, [])
|
||||||
|
|
||||||
|
const handlerProps = {
|
||||||
|
service: AdminCompanyTypeService,
|
||||||
|
setLoader: setShowLoader,
|
||||||
|
errorMsg: `Не удалось выполнить операцию`,
|
||||||
|
onComplete: updateTable,
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LoaderPortal show={showLoader}>
|
||||||
|
<EditableTable
|
||||||
|
bordered
|
||||||
|
size={'small'}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={companyTypes}
|
||||||
|
pagination={pagination}
|
||||||
|
onRowAdd={makeActionHandler('insert', handlerProps)}
|
||||||
|
onRowEdit={makeActionHandler('put', handlerProps)}
|
||||||
|
onRowDelete={makeActionHandler('delete', handlerProps)}
|
||||||
|
/>
|
||||||
|
</LoaderPortal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CompanyTypeController
|
@ -10,6 +10,7 @@ const DepositController = lazy(() => import('./DepositController'))
|
|||||||
const UserController = lazy(() => import('./UserController'))
|
const UserController = lazy(() => import('./UserController'))
|
||||||
const WellController = lazy(() => import('./WellController'))
|
const WellController = lazy(() => import('./WellController'))
|
||||||
const RoleController = lazy(() => import('./RoleController'))
|
const RoleController = lazy(() => import('./RoleController'))
|
||||||
|
const CompanyTypeController = lazy(() => import('./CompanyTypeController'))
|
||||||
const PermissionController = lazy(() => import('./PermissionController'))
|
const PermissionController = lazy(() => import('./PermissionController'))
|
||||||
const VisitLog = lazy(() => import('./VisitLog'))
|
const VisitLog = lazy(() => import('./VisitLog'))
|
||||||
|
|
||||||
@ -35,6 +36,9 @@ export const AdminPanel = () => {
|
|||||||
<PrivateMenuItem key={'company'} permission={'company_editor'}>
|
<PrivateMenuItem key={'company'} permission={'company_editor'}>
|
||||||
<Link to={`${rootPath}/company`}>Компании</Link>
|
<Link to={`${rootPath}/company`}>Компании</Link>
|
||||||
</PrivateMenuItem>
|
</PrivateMenuItem>
|
||||||
|
<PrivateMenuItem key={'company_type'}>
|
||||||
|
<Link to={`${rootPath}/company_type`}>Типы компаний</Link>
|
||||||
|
</PrivateMenuItem>
|
||||||
<PrivateMenuItem key={'role'} permission={'role_editor'}>
|
<PrivateMenuItem key={'role'} permission={'role_editor'}>
|
||||||
<Link to={`${rootPath}/role`}>Роли</Link>
|
<Link to={`${rootPath}/role`}>Роли</Link>
|
||||||
</PrivateMenuItem>
|
</PrivateMenuItem>
|
||||||
@ -55,6 +59,7 @@ export const AdminPanel = () => {
|
|||||||
<PrivateRoute permission={ 'well_editor'} path={`${rootPath}/well` } component={ WellController} />
|
<PrivateRoute permission={ 'well_editor'} path={`${rootPath}/well` } component={ WellController} />
|
||||||
<PrivateRoute permission={ 'user_editor'} path={`${rootPath}/user` } component={ UserController} />
|
<PrivateRoute permission={ 'user_editor'} path={`${rootPath}/user` } component={ UserController} />
|
||||||
<PrivateRoute permission={ 'company_editor'} path={`${rootPath}/company` } component={ CompanyController} />
|
<PrivateRoute permission={ 'company_editor'} path={`${rootPath}/company` } component={ CompanyController} />
|
||||||
|
<PrivateRoute path={`${rootPath}/company_type`} component={CompanyTypeController} />
|
||||||
<PrivateRoute permission={ 'role_editor'} path={`${rootPath}/role` } component={ RoleController} />
|
<PrivateRoute permission={ 'role_editor'} path={`${rootPath}/role` } component={ RoleController} />
|
||||||
<PrivateRoute permission={'permission_editor'} path={`${rootPath}/permission`} component={PermissionController} />
|
<PrivateRoute permission={'permission_editor'} path={`${rootPath}/permission`} component={PermissionController} />
|
||||||
<PrivateRoute path={`${rootPath}/visit_log`} component={VisitLog} />
|
<PrivateRoute path={`${rootPath}/visit_log`} component={VisitLog} />
|
||||||
|
Loading…
Reference in New Issue
Block a user