From 8bf84f95087f09111a6b961effaefa44b439700b Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 26 Apr 2021 13:07:47 +0300 Subject: [PATCH] remove antd modal code --- src/client/Containers/Calculation/index.jsx | 17 +++++------------ src/client/Elements/Modal.jsx | 17 ----------------- src/client/hocs/Calculation/index.js | 11 +---------- src/client/hocs/Calculation/withModal.jsx | 14 -------------- src/client/hooks/Calculation/useModal.js | 13 ------------- .../stores/CalculationStore/Data/modal.js | 13 ------------- src/client/stores/CalculationStore/index.ts | 16 ++++++---------- src/core/types/Calculation/Store/index.ts | 10 +++------- 8 files changed, 15 insertions(+), 96 deletions(-) delete mode 100644 src/client/Elements/Modal.jsx delete mode 100644 src/client/hocs/Calculation/withModal.jsx delete mode 100644 src/client/hooks/Calculation/useModal.js delete mode 100644 src/client/stores/CalculationStore/Data/modal.js diff --git a/src/client/Containers/Calculation/index.jsx b/src/client/Containers/Calculation/index.jsx index e7d530d..5717e49 100644 --- a/src/client/Containers/Calculation/index.jsx +++ b/src/client/Containers/Calculation/index.jsx @@ -1,7 +1,5 @@ import Result from 'client/Components/Result'; import Spinner from 'client/Components/Spinner'; -import Modal from 'client/Elements/Modal'; -import withModal from 'client/hocs/Calculation/withModal'; import { useFetch } from 'client/hooks/Calculation/useFetch'; import { Box, Flex } from 'client/UIKit/grid'; import mq from 'client/UIKit/mq'; @@ -45,17 +43,12 @@ const Calculation = () => { return ; } - const ModalComponent = withModal(Modal); - return ( - <> - - - - - - - + + + + + ); }; diff --git a/src/client/Elements/Modal.jsx b/src/client/Elements/Modal.jsx deleted file mode 100644 index 5a2baeb..0000000 --- a/src/client/Elements/Modal.jsx +++ /dev/null @@ -1,17 +0,0 @@ -import { Modal as AntModal } from 'antd'; - -const Modal = ({ visible, text, closeModal, ...props }) => { - return ( - closeModal()} - onCancel={() => closeModal()} - > - {text} - - ); -}; - -export default Modal; diff --git a/src/client/hocs/Calculation/index.js b/src/client/hocs/Calculation/index.js index da4614c..52b0585 100644 --- a/src/client/hocs/Calculation/index.js +++ b/src/client/hocs/Calculation/index.js @@ -1,16 +1,7 @@ import withButton from './withButton'; import withComputedValue from './withComputedValue'; import withLink from './withLink'; -import withModal from './withModal'; import withTable from './withTable'; import withValue from './withValue'; -export { - withButton, - withLink, - withValue, - withComputedValue, - withModal, - withTable, -}; - +export { withButton, withLink, withValue, withComputedValue, withTable }; diff --git a/src/client/hocs/Calculation/withModal.jsx b/src/client/hocs/Calculation/withModal.jsx deleted file mode 100644 index 0bc1ef6..0000000 --- a/src/client/hocs/Calculation/withModal.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import { observer } from 'mobx-react-lite'; -import { useModal } from 'client/hooks/Calculation/useModal'; - -export default Modal => - observer(() => { - const { isModalVisible, modalText, closeModal } = useModal(); - return ( - - ); - }); diff --git a/src/client/hooks/Calculation/useModal.js b/src/client/hooks/Calculation/useModal.js deleted file mode 100644 index 3774f77..0000000 --- a/src/client/hooks/Calculation/useModal.js +++ /dev/null @@ -1,13 +0,0 @@ -import { useStores } from '../useStores'; - -export const useModal = () => { - const { calculationStore } = useStores(); - const { - modal: { isModalVisible, modalText }, - } = calculationStore; - - const closeModal = () => { - calculationStore.closeModal(); - }; - return { isModalVisible, modalText, closeModal }; -}; diff --git a/src/client/stores/CalculationStore/Data/modal.js b/src/client/stores/CalculationStore/Data/modal.js deleted file mode 100644 index 19e7564..0000000 --- a/src/client/stores/CalculationStore/Data/modal.js +++ /dev/null @@ -1,13 +0,0 @@ -const modalData = { modal: { isModalVisible: false, modalText: undefined } }; - -const modalActions = { - showModal(text) { - this.modal.modalText = text; - this.modal.isModalVisible = true; - }, - closeModal() { - this.modal.isModalVisible = false; - }, -}; - -export default Object.assign(modalData, modalActions); diff --git a/src/client/stores/CalculationStore/index.ts b/src/client/stores/CalculationStore/index.ts index 5a8ddcf..3d6b753 100644 --- a/src/client/stores/CalculationStore/index.ts +++ b/src/client/stores/CalculationStore/index.ts @@ -1,20 +1,17 @@ -import { TableNames } from 'core/types/Calculation/Store/tables'; -import { ElementStatus } from 'core/types/statuses'; +import { ElementParam, ICalculationStore } from 'core/types/Calculation/Store'; import { ElementsNames } from 'core/types/Calculation/Store/elements'; import { LinksNames } from 'core/types/Calculation/Store/links'; -import { ICalculationStore, ElementParam } from 'core/types/Calculation/Store'; import { Process } from 'core/types/Calculation/Store/process'; +import { TableNames } from 'core/types/Calculation/Store/tables'; +import { ElementStatus } from 'core/types/statuses'; import { isEqual } from 'lodash'; import { autorun, makeAutoObservable, reaction } from 'mobx'; - -import values from './Data/values'; -import tables from './Data/tables'; import staticData from './Data/static'; -import modal from './Data/modal'; - -import computedEffects from './Effects/computed'; +import tables from './Data/tables'; +import values from './Data/values'; import actionsEffects from './Effects/actions'; import autorunEffects from './Effects/autorun'; +import computedEffects from './Effects/computed'; import reactionEffects from './Effects/reactions'; export const calculationProcess = makeAutoObservable({ @@ -57,7 +54,6 @@ const CalculationStore: ICalculationStore = makeAutoObservable( tables, computedEffects, actionsEffects, - modal, { stores: { calculationProcess, diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts index 0e326b4..b3d4db8 100644 --- a/src/core/types/Calculation/Store/index.ts +++ b/src/core/types/Calculation/Store/index.ts @@ -1,19 +1,19 @@ +import { TCRMEntity } from '../../Entities/crmEntities'; import { CRMEntityNames } from '../../Entities/crmEntityNames'; import { ElementStatus } from '../../statuses'; -import { TCRMEntity } from '../../Entities/crmEntities'; import { ElementsNames, TElements } from './elements'; import { TElementFilter } from './filters'; import { IBaseOption } from './options'; import { TStaticData } from './staticData'; import { + ITable, ITableCell, StoreTables, TableNames, TableProps, TCellCallback, - ITable, } from './tables'; -import { TValue, TValues, ValuesNames, ResultValuesNames } from './values'; +import { ResultValuesNames, TValue, TValues, ValuesNames } from './values'; export type ElementParam = | 'value' @@ -68,10 +68,6 @@ interface ICalculationValues { elementName: ElementsNames, validation: boolean | undefined, ) => void; - - modal: { isModalVisible: boolean; modalText: string }; - showModal: (text: string) => void; - closeModal: () => void; } interface ICalculationTables {