colouring-montreal/app/src/frontend/ConfirmationModal.tsx

59 lines
2.0 KiB
TypeScript
Raw Normal View History

2019-08-16 08:20:44 -04:00
import React from 'react';
2019-08-16 10:20:54 -04:00
import './ConfirmationModal.css';
2019-08-16 08:20:44 -04:00
interface ConfirmationModalProps {
show: boolean,
title: string,
description: string,
confirmButtonText?: string,
confirmButtonClass?: string,
cancelButtonClass?: string,
onConfirm: () => void,
onCancel: () => void
}
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:20:54 -04:00
<div className={modalShowClass} tabIndex={-1} role="dialog">
2019-08-16 08:20:44 -04:00
<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"
2019-08-16 10:20:54 -04:00
className={`btn btn-block ${confirmButtonClass}`}
2019-08-16 08:20:44 -04:00
onClick={() => props.onConfirm()}
>{confirmButtonText}</button>
<button
type="button"
2019-08-16 10:20:54 -04:00
className={`btn btn-block ${cancelButtonClass}`}
2019-08-16 08:20:44 -04:00
onClick={() => props.onCancel()}
>Cancel</button>
</div>
</div>
</div>
</div>
);
};
export default ConfirmationModal;