From 3c4b98366d9656758255778920fcf33477247c66 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Tue, 21 Dec 2021 15:46:05 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0?= =?UTF-8?q?=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AdminPanel/PermissionController.jsx | 60 +++++++++++++++++++ src/pages/AdminPanel/index.jsx | 23 ++++--- 2 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 src/pages/AdminPanel/PermissionController.jsx 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...}> - - - - - - - + + + + + + + +