-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace header, title to modal components
- Loading branch information
Showing
5 changed files
with
148 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { Modal as BootstrapModal } from 'react-bootstrap'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { selectIsOpen, closeModal, selectType } from '../../store/slices/modalsSlice'; | ||
import { MODALS } from './constants'; | ||
|
||
const Modal = () => { | ||
const ModalComponent = () => { | ||
const dispatch = useDispatch(); | ||
const isOpen = useSelector(selectIsOpen); | ||
const type = useSelector(selectType); | ||
const { t } = useTranslation(); | ||
|
||
const handleClose = () => { | ||
dispatch(closeModal()); | ||
}; | ||
|
||
const Component = MODALS[type]; | ||
const ModalContent = MODALS[type]; | ||
|
||
return ( | ||
<BootstrapModal show={isOpen} onHide={handleClose} centered> | ||
<BootstrapModal.Header closeButton> | ||
<BootstrapModal.Title> | ||
{t(`modals.${type}ChannelTitle`)} | ||
</BootstrapModal.Title> | ||
</BootstrapModal.Header> | ||
<BootstrapModal.Body> | ||
{Component && <Component handleClose={handleClose} />} | ||
</BootstrapModal.Body> | ||
{ModalContent && <ModalContent handleClose={handleClose} />} | ||
</BootstrapModal> | ||
); | ||
}; | ||
|
||
export default Modal; | ||
export default ModalComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters