diff --git a/src/pages/AdminPanel/ClusterController.jsx b/src/pages/AdminPanel/ClusterController.jsx index 002238d..0d5553b 100644 --- a/src/pages/AdminPanel/ClusterController.jsx +++ b/src/pages/AdminPanel/ClusterController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -40,7 +40,7 @@ export const ClusterController = memo(() => { makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }), ] - const updateTable = () => invokeWebApiWrapperAsync( + const updateTable = useCallback(() => invokeWebApiWrapperAsync( async () => { const clusters = await AdminClusterService.getAll() setClusters(arrayOrDefault(clusters)) @@ -48,7 +48,7 @@ export const ClusterController = memo(() => { setShowLoader, `Не удалось загрузить список кустов`, 'Получение списка кустов' - ) + ), []) useEffect(() => invokeWebApiWrapperAsync( async () => { @@ -61,7 +61,7 @@ export const ClusterController = memo(() => { 'Получение списка месторождений' ), []) - useEffect(updateTable, []) + useEffect(updateTable, [updateTable]) const handlerProps = { service: AdminClusterService, diff --git a/src/pages/AdminPanel/CompanyController.jsx b/src/pages/AdminPanel/CompanyController.jsx index 1479287..2381bda 100644 --- a/src/pages/AdminPanel/CompanyController.jsx +++ b/src/pages/AdminPanel/CompanyController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -21,10 +21,10 @@ export const CompanyController = memo(() => { const [companies, setCompanies] = useState([]) const [showLoader, setShowLoader] = useState(false) - const updateTable = async () => { + const updateTable = useCallback(async () => { const companies = await AdminCompanyService.getAll() setCompanies(arrayOrDefault(companies)) - } + }, []) useEffect(() => invokeWebApiWrapperAsync( async() => { @@ -51,7 +51,7 @@ export const CompanyController = memo(() => { setShowLoader, `Не удалось загрузить список типов компаний`, 'Получение списка типов команд' - ), []) + ), [updateTable]) const handlerProps = { service: AdminCompanyService, diff --git a/src/pages/AdminPanel/CompanyTypeController.jsx b/src/pages/AdminPanel/CompanyTypeController.jsx index 6ee67bd..7c87d90 100644 --- a/src/pages/AdminPanel/CompanyTypeController.jsx +++ b/src/pages/AdminPanel/CompanyTypeController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -27,7 +27,7 @@ export const CompanyTypeController = memo(() => { const [companyTypes, setCompanyTypes] = useState([]) const [showLoader, setShowLoader] = useState(false) - const updateTable = () => invokeWebApiWrapperAsync( + const updateTable = useCallback(() => invokeWebApiWrapperAsync( async() => { const companyTypes = await AdminCompanyTypeService.getAll() setCompanyTypes(arrayOrDefault(companyTypes)) @@ -35,9 +35,9 @@ export const CompanyTypeController = memo(() => { setShowLoader, `Не удалось загрузить список типов компаний`, 'Получение списка типов компаний' - ) + ), []) - useEffect(updateTable, []) + useEffect(updateTable, [updateTable]) const handlerProps = { service: AdminCompanyTypeService, diff --git a/src/pages/AdminPanel/DepositController.jsx b/src/pages/AdminPanel/DepositController.jsx index 5a21b94..c472c30 100644 --- a/src/pages/AdminPanel/DepositController.jsx +++ b/src/pages/AdminPanel/DepositController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' @@ -21,7 +21,7 @@ export const DepositController = memo(() => { const [deposits, setDeposits] = useState([]) const [showLoader, setShowLoader] = useState(false) - const updateTable = () => invokeWebApiWrapperAsync( + const updateTable = useCallback(() => invokeWebApiWrapperAsync( async() => { const deposits = await AdminDepositService.getAll() setDeposits(arrayOrDefault(deposits)) @@ -29,9 +29,9 @@ export const DepositController = memo(() => { setShowLoader, `Не удалось загрузить список месторождении`, 'Получение списка месторождений' - ) + ), []) - useEffect(updateTable, []) + useEffect(updateTable, [updateTable]) const handlerProps = { service: AdminDepositService, diff --git a/src/pages/AdminPanel/PermissionController.jsx b/src/pages/AdminPanel/PermissionController.jsx index d55e63a..5bbf24e 100644 --- a/src/pages/AdminPanel/PermissionController.jsx +++ b/src/pages/AdminPanel/PermissionController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -30,7 +30,7 @@ export const PermissionController = memo(() => { const [showLoader, setShowLoader] = useState(false) const [permissions, setPermissions] = useState([]) - const updateTable = async () => invokeWebApiWrapperAsync( + const updateTable = useCallback(async () => invokeWebApiWrapperAsync( async () => { const permission = await AdminPermissionService.getAll() setPermissions(arrayOrDefault(permission)) @@ -38,9 +38,9 @@ export const PermissionController = memo(() => { setShowLoader, `Не удалось загрузить список прав`, 'Получение списка прав' - ) + ), []) - useEffect(() => updateTable(), []) + useEffect(() => updateTable(), [updateTable]) const handlerProps = { service: AdminPermissionService, diff --git a/src/pages/AdminPanel/RoleController.jsx b/src/pages/AdminPanel/RoleController.jsx index c5e6a30..dbfb0b2 100644 --- a/src/pages/AdminPanel/RoleController.jsx +++ b/src/pages/AdminPanel/RoleController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import LoaderPortal from '@components/LoaderPortal' import { PermissionView, RoleView } from '@components/views' @@ -15,20 +15,21 @@ export const RoleController = memo(() => { const [showLoader, setShowLoader] = useState(false) const [columns, setColumns] = useState([]) - const loadRoles = async () => { + const loadRoles = useCallback(async () => { const roles = await AdminUserRoleService.getAll() setRoles(arrayOrDefault(roles)) - } + }, []) useEffect(() => { setColumns([ - makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min1 }), + makeColumn('Название', 'caption', { width: 100, editable: true, formItemRules: min1 }), makeTagColumn('Включённые роли', 'roles', roles, 'id', 'caption', { - width: 200, + width: 400, editable: true, render: (role) => }, { allowClear: true }), makeTagColumn('Разрешения', 'permissions', permissions, 'id', 'name', { + width: 600, editable: true, render: (permission) => , }), @@ -44,7 +45,7 @@ export const RoleController = memo(() => { setShowLoader, `Не удалось загрузить список ролей`, 'Получение списка ролей' - ), []) + ), [loadRoles]) const handlerProps = { service: AdminUserRoleService, diff --git a/src/pages/AdminPanel/WellController/index.jsx b/src/pages/AdminPanel/WellController/index.jsx index 60265d6..0a5d8d6 100644 --- a/src/pages/AdminPanel/WellController/index.jsx +++ b/src/pages/AdminPanel/WellController/index.jsx @@ -35,6 +35,11 @@ const wellTypes = [ { value: 2, label: 'Горизонтальная' }, ] +const recordParser = (record) => ({ + ...record, + idTelemetry: record.telemetry?.id, +}) + export const WellController = memo(() => { const [columns, setColumns] = useState([]) const [wells, setWells] = useState([]) @@ -54,14 +59,14 @@ export const WellController = memo(() => { // TODO: Метод дубликации скважины } - const addititonalButtons = (record, editingKey) => ( + const addititonalButtons = memo((record, editingKey) => (