From ec02fb7af08ac4127df420661c809b0ae6b633fe Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:41:42 +0800 Subject: [PATCH] MSP-3134 move folders --- src/components/CloseBtn/index.tsx | 22 -------- src/components/Modal/index.tsx | 43 ---------------- src/pages/HomePage/index.tsx | 24 ++++++--- .../CloseBtn/close-btn.scss | 0 src/ui/CloseBtn/index.tsx | 24 +++++++++ src/widgets/Modal/index.tsx | 51 +++++++++++++++++++ src/{components => widgets}/Modal/modal.scss | 0 7 files changed, 91 insertions(+), 73 deletions(-) delete mode 100644 src/components/CloseBtn/index.tsx delete mode 100644 src/components/Modal/index.tsx rename src/{components => ui}/CloseBtn/close-btn.scss (100%) create mode 100644 src/ui/CloseBtn/index.tsx create mode 100644 src/widgets/Modal/index.tsx rename src/{components => widgets}/Modal/modal.scss (100%) diff --git a/src/components/CloseBtn/index.tsx b/src/components/CloseBtn/index.tsx deleted file mode 100644 index 33f2441..0000000 --- a/src/components/CloseBtn/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Button} from "antd"; -import './close-btn.scss' -interface CloseBtnPropsType { - ariaLabel?: string - onClick: () => void -} -const CloseBtn = ({onClick, ariaLabel}: CloseBtnPropsType) => { - return ( - - ); -}; - -export default CloseBtn; \ No newline at end of file diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx deleted file mode 100644 index d47161c..0000000 --- a/src/components/Modal/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import {Dispatch, MouseEvent, ReactNode, SetStateAction } from "react"; -import {Button} from "antd"; -import CloseBtn from "@components/CloseBtn"; -import './modal.scss'; - -interface ModalPropsType { - onOk?: () => void - title: string - children: ReactNode - setIsOpenModal: Dispatch> - footer?: {onOkText: string, onCanselText: string} -} - -const Modal = ({ onOk, footer, title, children, setIsOpenModal }: ModalPropsType) => { - const closeModal = () => { - setIsOpenModal(false); - }; - - const handleModalClick = (event: MouseEvent) => { - event.stopPropagation(); - }; - - return ( -
-
-

{title}

-
- {children} -
- {footer && -
- - -
- } - -
- -
- ); -}; - -export default Modal; \ No newline at end of file diff --git a/src/pages/HomePage/index.tsx b/src/pages/HomePage/index.tsx index e6f4c17..8feaa73 100644 --- a/src/pages/HomePage/index.tsx +++ b/src/pages/HomePage/index.tsx @@ -1,17 +1,19 @@ -import {useState} from "react"; -import Modal from "src/widgets/Modal"; -import { Button, theme } from 'antd'; -import { useRole } from '@hooks/useRole.tsx'; +import { Button, theme } from 'antd' +import { useState } from 'react' + +import { useRole } from '@hooks/useRole.tsx' import { PermissionKeys } from '@type/roles.type.ts' -import './home.scss' +import Modal from 'src/widgets/Modal' + +import './home-page.scss' const HomePages = () => { const { hasPermission } = useRole() const { useToken } = theme const { token } = useToken() - const [isOpenModal, setIsOpenModal] = useState(false) + const [isOpenModal, setIsOpenModal] = useState(false) const isPageAvailable = hasPermission(PermissionKeys.user_view) @@ -24,9 +26,15 @@ const HomePages = () => { )}
Проверка шрифтов
- {isOpenModal &&
modal content
} + {isOpenModal && ( + +
modal content
+
+ )} - + ) } diff --git a/src/components/CloseBtn/close-btn.scss b/src/ui/CloseBtn/close-btn.scss similarity index 100% rename from src/components/CloseBtn/close-btn.scss rename to src/ui/CloseBtn/close-btn.scss diff --git a/src/ui/CloseBtn/index.tsx b/src/ui/CloseBtn/index.tsx new file mode 100644 index 0000000..7cfef8a --- /dev/null +++ b/src/ui/CloseBtn/index.tsx @@ -0,0 +1,24 @@ +import { Button } from 'antd' + +import './close-btn.scss' + +interface CloseBtnPropsType { + ariaLabel?: string + onClick: () => void +} +const CloseBtn = ({ onClick, ariaLabel }: CloseBtnPropsType) => { + return ( + + ) +} + +export default CloseBtn diff --git a/src/widgets/Modal/index.tsx b/src/widgets/Modal/index.tsx new file mode 100644 index 0000000..9e7aad8 --- /dev/null +++ b/src/widgets/Modal/index.tsx @@ -0,0 +1,51 @@ +import { Button } from 'antd' +import { Dispatch, MouseEvent, ReactNode, SetStateAction } from 'react' +import CloseBtn from 'src/ui/CloseBtn' + +import './modal.scss' + +interface ModalPropsType { + onOk?: () => void + title: string + children: ReactNode + setIsOpenModal: Dispatch> + footer?: { onOkText: string; onCanselText: string } +} + +const Modal = ({ + onOk, + footer, + title, + children, + setIsOpenModal +}: ModalPropsType) => { + const closeModal = () => { + setIsOpenModal(false) + } + + const handleModalClick = (event: MouseEvent) => { + event.stopPropagation() + } + + return ( +
+
+

{title}

+
{children}
+ {footer && ( +
+ + +
+ )} + +
+
+ ) +} + +export default Modal diff --git a/src/components/Modal/modal.scss b/src/widgets/Modal/modal.scss similarity index 100% rename from src/components/Modal/modal.scss rename to src/widgets/Modal/modal.scss