2022-06-20 15:17:33 +00:00
|
|
|
import React from 'react';
|
2022-07-03 17:29:23 +00:00
|
|
|
import { Dialog, RenderDialogProps } from './';
|
2022-06-20 15:17:33 +00:00
|
|
|
import { Button } from '@/components/elements/button/index';
|
|
|
|
|
2022-07-03 17:29:23 +00:00
|
|
|
type ConfirmationProps = Omit<RenderDialogProps, 'description' | 'children'> & {
|
2022-06-20 15:17:33 +00:00
|
|
|
children: React.ReactNode;
|
|
|
|
confirm?: string | undefined;
|
2022-06-20 21:26:47 +00:00
|
|
|
onConfirmed: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
2022-06-26 19:13:52 +00:00
|
|
|
};
|
2022-06-20 15:17:33 +00:00
|
|
|
|
|
|
|
export default ({ confirm = 'Okay', children, onConfirmed, ...props }: ConfirmationProps) => {
|
|
|
|
return (
|
|
|
|
<Dialog {...props} description={typeof children === 'string' ? children : undefined}>
|
|
|
|
{typeof children !== 'string' && children}
|
2022-07-02 21:24:12 +00:00
|
|
|
<Dialog.Footer>
|
2022-06-20 15:17:33 +00:00
|
|
|
<Button.Text onClick={props.onClose}>Cancel</Button.Text>
|
|
|
|
<Button.Danger onClick={onConfirmed}>{confirm}</Button.Danger>
|
2022-07-02 21:24:12 +00:00
|
|
|
</Dialog.Footer>
|
2022-06-20 15:17:33 +00:00
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
};
|