diff --git a/src/components/ApplicationsContent/index.tsx b/src/components/ApplicationsContent/index.tsx index 941472f..883c5b9 100644 --- a/src/components/ApplicationsContent/index.tsx +++ b/src/components/ApplicationsContent/index.tsx @@ -3,10 +3,9 @@ import { DeleteOutlined, PlusSquareOutlined } from '@ant-design/icons' -import { Button, message, Spin, Table } from 'antd' +import {Button, message, Spin, Table} from 'antd' import { ColumnsType } from 'antd/es/table' -import { FormComponents } from 'isp-ui-kit' -import { EmptyData } from 'isp-ui-kit/dist/Layout' +import { FormComponents, Layout } from 'isp-ui-kit' import { FC, useState } from 'react' import { useForm } from 'react-hook-form' @@ -31,6 +30,7 @@ import tokensApi from '@services/tokensService.ts' import './applications-content.scss' const { FormInput, FormSelect } = FormComponents +const { EmptyData } = Layout interface ApplicationsContentPropTypes { id: number @@ -38,14 +38,14 @@ interface ApplicationsContentPropTypes { const ApplicationsContent: FC = (id) => { const { data: applications, isLoading: isLoadingApplicationsContent = [] } = - applicationsApi.useGetApplicationsByServiceIdQuery(id) + applicationsApi.useGetApplicationsByServiceIdQuery(id) const [createApplicationService] = - applicationsApi.useCreateApplicationServiceMutation() + applicationsApi.useCreateApplicationServiceMutation() const [updateApplication] = - applicationsApi.useUpdateApplicationsServiceMutation() + applicationsApi.useUpdateApplicationsServiceMutation() const [removeApplicationsService] = - applicationsApi.useRemoveApplicationsServiceMutation() + applicationsApi.useRemoveApplicationsServiceMutation() const [createToken] = tokensApi.useCreateTokenMutation() const [showApplicationsModal, setShowApplicationsModal] = useState({ addModal: false, @@ -53,7 +53,7 @@ const ApplicationsContent: FC = (id) => { addToken: false }) const [currentApplicationsApp, setCurrentApplicationsApp] = - useState() + useState() const { handleSubmit, @@ -64,9 +64,9 @@ const ApplicationsContent: FC = (id) => { }) const { handleSubmit: handleSubmitTokens, control: controlTokens } = - useForm({ - mode: 'onChange' - }) + useForm({ + mode: 'onChange' + }) const handleShowUpdateModalApplicationApp = (data: ApplicationAppType) => { setShowApplicationsModal({ @@ -95,22 +95,22 @@ const ApplicationsContent: FC = (id) => { id: currentApplicationsApp.id, name: data.name, description: data.description - ? data.description - : currentApplicationsApp.description, + ? data.description + : currentApplicationsApp.description, serviceId: id.id, type: 'SYSTEM' } updateApplication({ ...currentApplicationsApp, ...updateApplications }) - .unwrap() - .then(() => { - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: false + .unwrap() + .then(() => { + setShowApplicationsModal({ + ...showApplicationsModal, + updateModal: false + }) + reset() + message.info('Элемент сохранен') }) - reset() - message.info('Элемент сохранен') - }) - .catch(() => message.error('Ошибка обновления элемента')) + .catch(() => message.error('Ошибка обновления элемента')) } } @@ -123,9 +123,9 @@ const ApplicationsContent: FC = (id) => { } createApplicationService(newApplicationApp) - .unwrap() - .then(message.info('Элемент сохранен')) - .catch((e) => message.error(e)) + .unwrap() + .then(message.info('Элемент сохранен')) + .catch((e) => message.error(e)) setShowApplicationsModal({ ...showApplicationsModal, addModal: false @@ -133,11 +133,11 @@ const ApplicationsContent: FC = (id) => { reset() } const handleRemoveApplicationApp = (id: number) => - removeApplicationsService([id]) - .then(() => { - message.info('Элемент удален') - }) - .catch(message.error('Ошибка добавления элемента')) + removeApplicationsService([id]) + .then(() => { + message.info('Элемент удален') + }) + .catch(message.error('Ошибка добавления элемента')) const handleCreateToken = (data: NewApplicationTokenType) => { if (currentApplicationsApp) { @@ -147,17 +147,17 @@ const ApplicationsContent: FC = (id) => { } createToken(newToken) - .then(() => { - setShowApplicationsModal({ - ...showApplicationsModal, - addToken: false + .then(() => { + setShowApplicationsModal({ + ...showApplicationsModal, + addToken: false + }) + reset() + message.info('Элемент добавлен') + }) + .catch(() => { + message.error('Ошибка добавления элемента') }) - reset() - message.info('Элемент добавлен') - }) - .catch(() => { - message.error('Ошибка добавления элемента') - }) } } @@ -196,20 +196,20 @@ const ApplicationsContent: FC = (id) => { key: 'actions', render: (record) => { return ( - - + + ( + + + + ) + }} + className="appliactions-content__table" + rowKey={(record) => record.app.id} + pagination={false} + dataSource={applications} + columns={columns} + /> + + + setShowApplicationsModal({ + ...showApplicationsModal, + updateModal: false + }) + } > - Добавить - - -
( - - - - ) - }} - className="appliactions-content__table" - rowKey={(record) => record.app.id} - pagination={false} - dataSource={applications} - columns={columns} - /> + + + + + - - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: false - }) - } - > -
- - - -
+ + setShowApplicationsModal({ + ...showApplicationsModal, + addModal: false + }) + } + > +
+ + + +
- - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: false - }) - } - > -
- - - -
- - - setShowApplicationsModal({ - ...showApplicationsModal, - addToken: false - }) - } - > -
- - -
- + + setShowApplicationsModal({ + ...showApplicationsModal, + addToken: false + }) + } + > +
+ + +
+ ) }