import * as React from 'react' ; import { Dialog , DialogBody , DialogHeader , DialogProps , DialogContext } from '../dialog' ; import Button from '../Button' ; import Text from '../Text' ; interface MessageDialogProps extends DialogProps { title : string ; backBtn ? : boolean ; } interface MessageDialogBodyProps { backBtn ? : boolean ; } const MessageDialogBody = props => { const dialogContext = React . useContext ( DialogContext ) ; return ( < DialogBody > { props . children } { props . backBtn && ( < React . Fragment > < br /> < Button onClick = { dialogContext . closeDialog } > Back to Dashboard < /Button> < /React.Fragment>)} < /DialogBody>); } ; const MessageDialog = props => { const { title , backBtn , ... rest } = props ; return ( < Dialog { ... rest } > < DialogHeader > < Text type = { 'h1' } > { title } < /Text> < /DialogHeader> < MessageDialogBody backBtn = { backBtn } > { props . children } < /MessageDialogBody> < /Dialog>); } ; export default MessageDialog ;