File tree Expand file tree Collapse file tree 4 files changed +84
-0
lines changed Expand file tree Collapse file tree 4 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
+
4
+ import { Confirmation } from './Modals' ;
5
+
6
+ const Modal = props => {
7
+ const { type, ...other } = props ;
8
+
9
+ switch ( type ) {
10
+ case 'confirmation' :
11
+ return < Confirmation { ...props } /> ;
12
+ break ;
13
+ }
14
+ } ;
15
+
16
+ Modal . propTypes = {
17
+ type : PropTypes . oneOf ( [ 'confirmation' ] ) ,
18
+ title : PropTypes . string . isRequired ,
19
+ body : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . element ] ) . isRequired ,
20
+ } ;
21
+
22
+ export default Modal ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
+
4
+ import {
5
+ Button ,
6
+ Dialog ,
7
+ DialogActions ,
8
+ DialogContent ,
9
+ DialogContentText ,
10
+ DialogTitle ,
11
+ } from '@material-ui/core' ;
12
+
13
+ const Confirmation = props => {
14
+ const {
15
+ title,
16
+ body,
17
+ confirmText,
18
+ confirmed,
19
+ cancelText,
20
+ cancelled,
21
+ } = props ;
22
+
23
+ return (
24
+ < Dialog
25
+ open
26
+ onClose = { cancelled }
27
+ aria-labelledby = "alert-dialog-title"
28
+ aria-describedby = "alert-dialog-description"
29
+ >
30
+ < DialogTitle id = "alert-dialog-title" > { title } </ DialogTitle >
31
+
32
+ < DialogContent >
33
+ < DialogContentText id = "alert-dialog-description" >
34
+ { body }
35
+ </ DialogContentText >
36
+ </ DialogContent >
37
+
38
+ < DialogActions >
39
+ < Button onClick = { cancelled } color = "primary" >
40
+ { cancelText ? cancelText : Lang . get ( 'resources.cancel' ) }
41
+ </ Button >
42
+
43
+ < Button onClick = { confirmed } color = "secondary" autoFocus >
44
+ { confirmText ? confirmText : Lang . get ( 'resources.confirm' ) }
45
+ </ Button >
46
+ </ DialogActions >
47
+ </ Dialog >
48
+ ) ;
49
+ } ;
50
+
51
+ Confirmation . propTypes = {
52
+ title : PropTypes . string . isRequired ,
53
+ body : PropTypes . string . isRequired ,
54
+ confirmText : PropTypes . string ,
55
+ confirmed : PropTypes . func ,
56
+ cancelText : PropTypes . string ,
57
+ cancelled : PropTypes . func ,
58
+ } ;
59
+
60
+ export default Confirmation ;
Original file line number Diff line number Diff line change
1
+ export { default as Confirmation } from './Confirmation' ;
Original file line number Diff line number Diff line change
1
+ export { default as Modal } from './Modal' ;
1
2
export { default as Snackbar } from './Snackbar' ;
2
3
export { default as Table } from './Table' ;
3
4
export { default as TableToolbar } from './TableToolbar/TableToolbar' ;
You can’t perform that action at this time.
0 commit comments