Convert withModal to useModal
This commit is contained in:
parent
9cf42df1ea
commit
530e08b9ee
32 changed files with 791 additions and 737 deletions
|
@ -1,27 +1,26 @@
|
|||
import React, { useCallback } from 'react';
|
||||
import withModal from 'components/modals/withModal';
|
||||
import React from 'react';
|
||||
import Modal from 'react-modal';
|
||||
import useModal from 'components/modals/useModal';
|
||||
import Button from 'components/ui/Button';
|
||||
|
||||
const Confirm = ({
|
||||
payload: { question, confirmation, onConfirm },
|
||||
onClose
|
||||
}) => {
|
||||
const handleConfirm = useCallback(() => {
|
||||
onClose(false);
|
||||
const Confirm = () => {
|
||||
const [modal, payload, closeModal] = useModal('confirm');
|
||||
const { question, confirmation, onConfirm } = payload;
|
||||
|
||||
const handleConfirm = () => {
|
||||
closeModal(false);
|
||||
onConfirm();
|
||||
}, []);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal {...modal}>
|
||||
<p>{question}</p>
|
||||
<Button onClick={handleConfirm}>{confirmation || 'OK'}</Button>
|
||||
<Button category="normal" onClick={onClose}>
|
||||
<Button category="normal" onClick={closeModal}>
|
||||
Cancel
|
||||
</Button>
|
||||
</>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default withModal({
|
||||
name: 'confirm'
|
||||
})(Confirm);
|
||||
export default Confirm;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue