From bc827117abbffb7b118150f0ff80ed2533f0eae6 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 13 Jan 2022 17:35:32 +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=82=D0=B8=D0=BF=D0=BE=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdminPanel/CompanyTypeController.jsx | 62 +++++++++++++++++++ src/pages/AdminPanel/index.jsx | 5 ++ 2 files changed, 67 insertions(+) create mode 100644 src/pages/AdminPanel/CompanyTypeController.jsx 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 = () => { +