diff --git a/src/pages/AdminPanel/PermissionController.jsx b/src/pages/AdminPanel/PermissionController.jsx new file mode 100644 index 0000000..3d9e236 --- /dev/null +++ b/src/pages/AdminPanel/PermissionController.jsx @@ -0,0 +1,60 @@ +import { useEffect, useState } from 'react' +import { invokeWebApiWrapperAsync } from '../../components/factory' +import LoaderPortal from '../../components/LoaderPortal' +import { + EditableTable, + makeActionHandler, + makeColumn, + makeStringSorter +} from '../../components/Table' +import { AdminPermissionService } from '../../services/api' + +const columns = [ + makeColumn('Название', 'name', { + editable: true, + sorter: makeStringSorter('name'), + }), + makeColumn('Описание', 'description', { + editable: true, + sorter: makeStringSorter('description'), + }), +] + +export const PermissionController = () => { + const [showLoader, setShowLoader] = useState(false) + const [permissions, setPermissions] = useState([]) + + const updateTable = () => invokeWebApiWrapperAsync( + async () => { + const permission = await AdminPermissionService.getAll() + setPermissions(permission ?? []) + }, + setShowLoader, + `Не удалось загрузить список прав` + ) + + useEffect(updateTable, []) + + const handlerProps = { + service: AdminPermissionService, + setLoader: setShowLoader, + errorMsg: `Не удалось выполнить операцию`, + onComplete: updateTable + } + + return ( + + + + ) +} + +export default PermissionController diff --git a/src/pages/AdminPanel/index.jsx b/src/pages/AdminPanel/index.jsx index 0f8bcfd..3f316ea 100644 --- a/src/pages/AdminPanel/index.jsx +++ b/src/pages/AdminPanel/index.jsx @@ -9,6 +9,7 @@ const DepositController = lazy(() => import('./DepositController')) const UserController = lazy(() => import('./UserController')) const WellController = lazy(() => import('./WellController')) const RoleController = lazy(() => import('./RoleController')) +const PermissionController = lazy(() => import('./PermissionController')) const VisitLog = lazy(() => import('./VisitLog')) export const AdminPanel = () => { @@ -34,9 +35,12 @@ export const AdminPanel = () => { Компании - Права + Роли - + + Права + + Журнал посещений @@ -45,13 +49,14 @@ export const AdminPanel = () => { Loading...}> - - - - - - - + + + + + + + +