diff --git a/src/pages/AdminPanel/CompanyTypeController.jsx b/src/pages/AdminPanel/CompanyTypeController.jsx new file mode 100644 index 0000000..b067614 --- /dev/null +++ b/src/pages/AdminPanel/CompanyTypeController.jsx @@ -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 ( + + + + ) +} + +export default CompanyTypeController diff --git a/src/pages/AdminPanel/index.jsx b/src/pages/AdminPanel/index.jsx index 1a55ea4..c699e3c 100644 --- a/src/pages/AdminPanel/index.jsx +++ b/src/pages/AdminPanel/index.jsx @@ -10,6 +10,7 @@ const DepositController = lazy(() => import('./DepositController')) const UserController = lazy(() => import('./UserController')) const WellController = lazy(() => import('./WellController')) const RoleController = lazy(() => import('./RoleController')) +const CompanyTypeController = lazy(() => import('./CompanyTypeController')) const PermissionController = lazy(() => import('./PermissionController')) const VisitLog = lazy(() => import('./VisitLog')) @@ -35,6 +36,9 @@ export const AdminPanel = () => { Компании + + Типы компаний + Роли @@ -55,6 +59,7 @@ export const AdminPanel = () => { +