/
index.js
55 lines (49 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { PropTypes } from 'react'
import styled from 'styled-components'
import { Button } from 'components'
import { Modal } from 'containers'
const Options = styled.div`
display: flex;
justify-content: flex-end;
margin-top: 1rem;
> *:first-child {
margin-right: 0.5rem;
}
`
const ConfirmModal = ({
children,
onConfirm,
onClose,
confirmLabel,
cancelLabel,
confirmProps,
cancelProps,
...props
}) => {
return (
<Modal {...props}>
{children || 'Do you want to proceed?'}
<Options>
<Button onClick={onConfirm} {...confirmProps}>{confirmLabel}</Button>
<Button onClick={onClose} transparent {...cancelProps}>{cancelLabel}</Button>
</Options>
</Modal>
)
}
ConfirmModal.propTypes = {
children: PropTypes.node,
name: PropTypes.string.isRequired,
onConfirm: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
confirmLabel: PropTypes.string,
cancelLabel: PropTypes.string,
confirmProps: PropTypes.object,
cancelProps: PropTypes.object
}
ConfirmModal.defaultProps = {
confirmLabel: 'Confirm',
cancelLabel: 'Cancel',
confirmProps: {},
cancelProps: {}
}
export default ConfirmModal