2021-04-05 11:59:22 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Button, Modal } from 'react-bootstrap';
|
2021-04-05 12:17:33 +00:00
|
|
|
import constants from 'utils/strings/constants';
|
2021-04-05 11:59:22 +00:00
|
|
|
|
2021-04-07 07:18:45 +00:00
|
|
|
export interface MessageAttributes {
|
|
|
|
title?: string;
|
|
|
|
staticBackdrop?: boolean;
|
|
|
|
close?: { text?: string; variant?: string };
|
|
|
|
proceed?: { text: string; action: any };
|
|
|
|
}
|
2021-04-05 11:59:22 +00:00
|
|
|
interface Props {
|
|
|
|
show: boolean;
|
2021-04-05 12:10:32 +00:00
|
|
|
children?: any;
|
2021-04-05 11:59:22 +00:00
|
|
|
onHide: () => void;
|
2021-04-07 07:18:45 +00:00
|
|
|
attributes?: MessageAttributes;
|
2021-04-05 11:59:22 +00:00
|
|
|
}
|
|
|
|
export function MessageDialog({ attributes, children, ...props }: Props) {
|
|
|
|
return (
|
2021-04-05 15:20:58 +00:00
|
|
|
<Modal
|
|
|
|
{...props}
|
|
|
|
size="lg"
|
|
|
|
centered
|
|
|
|
backdrop={attributes?.staticBackdrop ? 'static' : 'true'}
|
|
|
|
>
|
2021-04-05 11:59:22 +00:00
|
|
|
<Modal.Body>
|
2021-04-05 13:17:18 +00:00
|
|
|
{attributes?.title && (
|
2021-04-05 11:59:22 +00:00
|
|
|
<Modal.Title>
|
|
|
|
<strong>{attributes.title}</strong>
|
|
|
|
</Modal.Title>
|
|
|
|
)}
|
2021-04-07 07:18:45 +00:00
|
|
|
{children && (
|
|
|
|
<>
|
|
|
|
<hr /> {children}
|
|
|
|
</>
|
|
|
|
)}
|
2021-04-05 11:59:22 +00:00
|
|
|
</Modal.Body>
|
2021-04-05 13:17:18 +00:00
|
|
|
{attributes && (
|
|
|
|
<Modal.Footer style={{ borderTop: 'none' }}>
|
2021-04-07 07:18:45 +00:00
|
|
|
{attributes.close && (
|
2021-04-05 15:23:53 +00:00
|
|
|
<Button
|
2021-04-07 07:18:45 +00:00
|
|
|
variant={`outline-${
|
|
|
|
attributes.close?.variant ?? 'secondary'
|
|
|
|
}`}
|
|
|
|
onClick={props.onHide}
|
2021-04-05 15:23:53 +00:00
|
|
|
>
|
2021-04-07 07:18:45 +00:00
|
|
|
{attributes.close?.text ?? constants.OK}
|
2021-04-05 13:17:18 +00:00
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
{attributes.proceed && (
|
|
|
|
<Button
|
2021-04-05 13:53:12 +00:00
|
|
|
variant="outline-success"
|
2021-04-05 13:17:18 +00:00
|
|
|
onClick={attributes.proceed.action}
|
|
|
|
>
|
|
|
|
{attributes.proceed.text}
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</Modal.Footer>
|
|
|
|
)}
|
2021-04-05 11:59:22 +00:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|