diff --git a/src/pages/Cluster/functions.jsx b/src/pages/Cluster/functions.jsx index e92d316..8aba6b7 100644 --- a/src/pages/Cluster/functions.jsx +++ b/src/pages/Cluster/functions.jsx @@ -3,7 +3,7 @@ import { OperationStatService } from '@api' const maxPrefix = 'isMax' const minPrefix = 'isMin' -export const getPrecision = (number) => Number.isNaN(number ?? NaN) ? '-' : number.toFixed(2) +export const getPrecision = (number) => Number.isFinite(number) ? number.toFixed(2) : '-' export const getOperations = async (idWell) => { const ops = await OperationStatService.getTvd(idWell) diff --git a/src/pages/Deposit.jsx b/src/pages/Deposit.jsx index 463438c..f337ed3 100644 --- a/src/pages/Deposit.jsx +++ b/src/pages/Deposit.jsx @@ -3,6 +3,7 @@ import { Link } from 'react-router-dom' import { useState, useEffect, memo } from 'react' import { ClusterService } from '@api' +import { arrayOrDefault } from '@utils' import { PointerIcon } from '@components/icons' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' @@ -43,7 +44,7 @@ export const Deposit = memo(() => { useEffect(() => invokeWebApiWrapperAsync( async () => { const data = await ClusterService.getClusters() - setClustersData(data) + setClustersData(arrayOrDefault(data)) setViewParams(calcViewParams(data)) }, setShowLoader, @@ -54,7 +55,7 @@ export const Deposit = memo(() => {
- {clustersData.map(cluster => + {clustersData.map(cluster => ( { {cluster.caption} - )} + ))}
diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index 09432fe..31e30a8 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -1,20 +1,20 @@ +import { memo, useState } from 'react' +import { Link, useHistory } from 'react-router-dom' import { Card, Form, Input, Button } from 'antd' import { UserOutlined, LockOutlined } from '@ant-design/icons' -import { useState } from 'react' -import { Link, useHistory } from 'react-router-dom' import { AuthService } from '@api' +import { setUser } from '@utils/storage' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' import { loginRules, passwordRules } from '@utils/validationRules' -import { setUser } from '@utils/storage' import '@styles/index.css' import logo from '@images/logo_32.png' const logoIcon = {'АСБ'} -export const Login = () => { +export const Login = memo(() => { const history = useHistory() const [showLoader, setShowLoader] = useState(false) @@ -51,6 +51,6 @@ export const Login = () => { ) -} +}) export default Login diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 191afc8..5d31991 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react' +import { useState, useEffect, memo } from 'react' import { Button, Form, Input, Popconfirm, Timeline } from 'antd' import { CheckSquareOutlined, @@ -9,20 +9,20 @@ import { DeleteOutlined } from '@ant-design/icons' -import LoaderPortal from '../../components/LoaderPortal' -import { MeasureService } from '../../services/api' -import { invokeWebApiWrapperAsync } from '../../components/factory' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { MeasureService } from '@api' +import { formatDate } from '@utils' import { View } from './View' -import '../../styles/index.css' -import '../../styles/measure.css' -import { formatDate } from '../../utils' +import '@styles/index.css' +import '@styles/measure.css' const createEditingColumns = (cols, renderDelegate) => cols.map(col => ({ render: renderDelegate, ...col })) -export const MeasureTable = ({idWell, group, updateMeasuresFunc, additionalButtons}) => { +export const MeasureTable = memo(({idWell, group, updateMeasuresFunc, additionalButtons}) => { const [showLoader, setShowLoader] = useState(false) const [displayedValues, setDisplayedValues] = useState({}) const [editingColumns, setEditingColumns] = useState(group.columns) @@ -160,4 +160,6 @@ export const MeasureTable = ({idWell, group, updateMeasuresFunc, additionalButto ) -} +}) + +export default MeasureTable diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index 06beb48..104b3ad 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -1,5 +1,5 @@ import { Button } from 'antd' -import { useState, useEffect } from 'react' +import { useState, useEffect, memo } from 'react' import { TableOutlined } from '@ant-design/icons' import { MeasureService } from '@api' @@ -41,7 +41,7 @@ const defaultData = [ } ] -export const Measure = ({ idWell }) => { +export const Measure = memo(({ idWell }) => { const [showLoader, setShowLoader] = useState(false) const [isMeasuresUpdating, setIsMeasuresUpdating] = useState(true) const [data, setData] = useState(defaultData) @@ -85,6 +85,6 @@ export const Measure = ({ idWell }) => { /> ) -} +}) export default Measure diff --git a/src/pages/Messages.jsx b/src/pages/Messages.jsx index a3664c5..5e80d6a 100644 --- a/src/pages/Messages.jsx +++ b/src/pages/Messages.jsx @@ -3,8 +3,8 @@ import { useState, useEffect, memo } from 'react' import { Table, Select, DatePicker, Input } from 'antd' import { MessageService } from '@api' -import { invokeWebApiWrapperAsync } from '@components/factory' import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' import '@styles/message.css' @@ -103,8 +103,8 @@ export const Messages = memo(({ idWell }) => { return ( <> -
-

Фильтр сообщений

+
+

Фильтр сообщений