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 && - - {footer.onCanselText} - {footer.onOkText} - - } - - - - - ); -}; - -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 + + )} - setIsOpenModal(true)}>Open Modal + setIsOpenModal(true)}> + Open Modal + ) } 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 && ( + + + {footer.onCanselText} + + + {footer.onOkText} + + + )} + + + + ) +} + +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