dispatch/client/js/components/modals/Confirm.js

27 lines
634 B
JavaScript
Raw Normal View History

2020-05-03 07:05:16 +00:00
import React from 'react';
import Modal from 'react-modal';
import useModal from 'components/modals/useModal';
import Button from 'components/ui/Button';
2020-05-03 07:05:16 +00:00
const Confirm = () => {
const [modal, payload, closeModal] = useModal('confirm');
const { question, confirmation, onConfirm } = payload;
const handleConfirm = () => {
closeModal(false);
onConfirm();
2020-05-03 07:05:16 +00:00
};
return (
2020-05-03 07:05:16 +00:00
<Modal {...modal}>
<p>{question}</p>
<Button onClick={handleConfirm}>{confirmation || 'OK'}</Button>
2020-05-03 07:05:16 +00:00
<Button category="normal" onClick={closeModal}>
Cancel
</Button>
2020-05-03 07:05:16 +00:00
</Modal>
);
};
2020-05-03 07:05:16 +00:00
export default Confirm;