2020-03-23 02:10:49 +00:00
|
|
|
import React from 'react';
|
2020-03-27 22:32:33 +00:00
|
|
|
import Modal, { RequiredModalProps } from '@/components/elements/Modal';
|
2020-07-04 22:05:44 +00:00
|
|
|
import tw from 'twin.macro';
|
|
|
|
import Button from '@/components/elements/Button';
|
2020-03-23 02:10:49 +00:00
|
|
|
|
2020-03-27 22:32:33 +00:00
|
|
|
type Props = {
|
2020-03-23 02:10:49 +00:00
|
|
|
title: string;
|
|
|
|
buttonText: string;
|
|
|
|
children: string;
|
|
|
|
onConfirmed: () => void;
|
2020-03-27 22:32:33 +00:00
|
|
|
showSpinnerOverlay?: boolean;
|
|
|
|
} & RequiredModalProps;
|
2020-03-23 02:10:49 +00:00
|
|
|
|
2020-03-27 22:32:33 +00:00
|
|
|
const ConfirmationModal = ({ title, appear, children, visible, buttonText, onConfirmed, showSpinnerOverlay, onDismissed }: Props) => (
|
2020-03-23 02:10:49 +00:00
|
|
|
<Modal
|
2020-03-27 22:32:33 +00:00
|
|
|
appear={appear || true}
|
2020-03-23 02:10:49 +00:00
|
|
|
visible={visible}
|
2020-03-27 22:32:33 +00:00
|
|
|
showSpinnerOverlay={showSpinnerOverlay}
|
|
|
|
onDismissed={() => onDismissed()}
|
2020-03-23 02:10:49 +00:00
|
|
|
>
|
2020-07-04 22:05:44 +00:00
|
|
|
<h3 css={tw`mb-6`}>{title}</h3>
|
|
|
|
<p css={tw`text-sm`}>{children}</p>
|
|
|
|
<div css={tw`flex items-center justify-end mt-8`}>
|
|
|
|
<Button isSecondary onClick={() => onDismissed()}>
|
2020-03-23 02:10:49 +00:00
|
|
|
Cancel
|
2020-07-04 22:05:44 +00:00
|
|
|
</Button>
|
|
|
|
<Button color={'red'} css={tw`ml-4`} onClick={() => onConfirmed()}>
|
2020-03-23 02:10:49 +00:00
|
|
|
{buttonText}
|
2020-07-04 22:05:44 +00:00
|
|
|
</Button>
|
2020-03-23 02:10:49 +00:00
|
|
|
</div>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default ConfirmationModal;
|