added type definations to confirm dailog component

This commit is contained in:
Abhinav-grd 2021-03-18 21:44:24 +05:30
parent dd18a2175e
commit 554e320c8c
2 changed files with 16 additions and 7 deletions

View file

@ -1,11 +1,18 @@
import React from 'react';
import React, { MouseEventHandler } from 'react';
import { Button, Modal } from 'react-bootstrap';
import constants from 'utils/strings/constants';
function ConfirmDialog({ callback, action, ...props }) {
interface Props {
callback?: Map<string, Function>;
action: string;
show: boolean;
onHide: MouseEventHandler<HTMLElement>;
}
function ConfirmDialog(props: Props) {
const { callback, action, ...rest } = props;
return (
<Modal
{...props}
{...rest}
size="lg"
aria-labelledby="contained-modal-title-vcenter"
centered
@ -19,9 +26,11 @@ function ConfirmDialog({ callback, action, ...props }) {
<Button variant="secondary" onClick={props.onHide}>
{constants.CLOSE}
</Button>
<Button variant="danger" onClick={callback[action]}>
{constants[String(action).toUpperCase()]}
</Button>
{action && (
<Button variant="danger" onClick={callback[action]}>
{constants[String(action).toUpperCase()]}
</Button>
)}
</Modal.Footer>
</Modal>
);

View file

@ -79,7 +79,7 @@ export default function Sidebar(props: Props) {
});
};
let callback = [];
let callback = new Map<string, Function>();
callback[Action.logout] = logout;
callback[Action.cancelSubscription] = cancelSubscription;
function openFeedbackURL() {