components.core.PageDialog.jsx Maven / Gradle / Ivy
The newest version!
import React from 'react'
import { useSelector } from 'react-redux'
import PropTypes from 'prop-types'
import get from 'lodash/get'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'
import classNames from 'classnames'
import Toolbar from '../buttons/Toolbar'
import { getGlobalFieldByPath } from '../../ducks/models/selectors'
import propsResolver from '../../utils/propsResolver'
import withOverlayMethods from './withOverlayMethods'
const usePageDialog = ({ modelLink, ...props }) => {
const model = useSelector(getGlobalFieldByPath(modelLink))
return model ? propsResolver(props, model) : props
}
function PageDialog({ visible, props = {} }) {
const { title, text, size = 'sm', scrollable = false } = usePageDialog(props)
return (
{title && (
{title}
)}
{text && (
{text}
)}
)
}
PageDialog.propTypes = {
visible: PropTypes.bool,
props: PropTypes.shape({
title: PropTypes.string,
text: PropTypes.string,
size: PropTypes.string,
scrollable: PropTypes.bool,
modelLink: PropTypes.string,
}),
}
export default withOverlayMethods(PageDialog)