colouring-montreal/app/src/frontend/components/confirmation-modal.tsx

62 lines
2.2 KiB
TypeScript
Raw Normal View History

2019-08-16 08:20:44 -04:00
import React from 'react';
import './confirmation-modal.css';
2019-08-16 08:20:44 -04:00
interface ConfirmationModalProps {
2019-11-07 03:13:30 -05:00
show: boolean;
title: string;
description: string;
confirmButtonText?: string;
confirmButtonClass?: string;
cancelButtonClass?: string;
onConfirm: () => void;
onCancel: () => void;
2019-08-16 08:20:44 -04:00
}
const ConfirmationModal: React.FunctionComponent<ConfirmationModalProps> = ({
confirmButtonText = 'OK',
confirmButtonClass = 'btn-primary',
cancelButtonClass = '',
...props
}) => {
2019-08-16 10:20:54 -04:00
const modalShowClass = props.show ? 'modal-show': 'modal-hide';
2019-08-16 08:20:44 -04:00
return (
2019-08-16 10:40:38 -04:00
<div className={`modal ${modalShowClass}`} tabIndex={-1} role="dialog">
<div className="modal-backdrop">
<div className="modal-dialog" role="document">
<div className="modal-content">
<div className="modal-header">
<h5 className="modal-title">{props.title}</h5>
<button
type="button"
className="close"
aria-label="Close"
onClick={() => props.onCancel()}
>
<span aria-hidden="true">&times;</span>
</button>
</div>
<div className="modal-body">
<p>{props.description}</p>
</div>
<div className="modal-footer">
<button
type="button"
className={`btn btn-block ${confirmButtonClass}`}
onClick={() => props.onConfirm()}
>{confirmButtonText}</button>
<button
type="button"
className={`btn btn-block ${cancelButtonClass}`}
onClick={() => props.onCancel()}
>Cancel</button>
</div>
2019-08-16 08:20:44 -04:00
</div>
</div>
</div>
</div>
);
};
export default ConfirmationModal;