@@ -9,94 +9,91 @@ import TextField from '@mui/material/TextField';
9
9
import Typography from '@mui/material/Typography' ;
10
10
11
11
const PublicTalkEditor = ( { isNew, handleSaveData, public_talk, language } ) => {
12
- const [ isEdit , setIsEdit ] = useState ( isNew ) ;
13
- const [ title , setTitle ] = useState ( '' ) ;
12
+ const [ isEdit , setIsEdit ] = useState ( isNew ) ;
13
+ const [ title , setTitle ] = useState ( '' ) ;
14
14
15
- const handleEdit = ( ) => {
16
- setIsEdit ( true ) ;
17
- } ;
15
+ const handleEdit = ( ) => {
16
+ setIsEdit ( true ) ;
17
+ } ;
18
18
19
- const handleCancel = ( ) => {
20
- setIsEdit ( false ) ;
21
- if ( isNew ) setTitle ( '' ) ;
22
- if ( ! isNew ) setTitle ( public_talk [ language . toUpperCase ( ) ] ?. title || '' ) ;
23
- } ;
19
+ const handleCancel = ( ) => {
20
+ setIsEdit ( false ) ;
21
+ if ( isNew ) setTitle ( '' ) ;
22
+ if ( ! isNew ) setTitle ( public_talk [ language . toUpperCase ( ) ] ?. title || '' ) ;
23
+ } ;
24
24
25
- const handleSave = ( ) => {
26
- handleSaveData ( title ) ;
27
- setIsEdit ( isNew ? true : false ) ;
28
- setTitle ( '' ) ;
29
- } ;
25
+ const handleSave = ( ) => {
26
+ handleSaveData ( language , title ) ;
27
+ setIsEdit ( isNew ? true : false ) ;
28
+ setTitle ( '' ) ;
29
+ } ;
30
30
31
- useEffect ( ( ) => {
32
- if ( isNew ) setTitle ( '' ) ;
33
- if ( ! isNew ) setTitle ( public_talk [ language . toUpperCase ( ) ] ?. title || '' ) ;
34
- } , [ isNew , public_talk , language ] ) ;
31
+ useEffect ( ( ) => {
32
+ if ( isNew ) setTitle ( '' ) ;
33
+ if ( ! isNew ) setTitle ( public_talk [ language . toUpperCase ( ) ] ?. title || '' ) ;
34
+ } , [ isNew , public_talk , language ] ) ;
35
35
36
- useEffect ( ( ) => {
37
- setIsEdit ( isNew ) ;
38
- } , [ isNew ] ) ;
36
+ useEffect ( ( ) => {
37
+ setIsEdit ( isNew ) ;
38
+ } , [ isNew ] ) ;
39
39
40
- return (
41
- < Box >
42
- < Box sx = { { display : 'flex' , gap : '5px' , alignItems : 'flex-start' } } >
43
- { language !== 'E' && (
44
- < Typography
45
- sx = { {
46
- backgroundColor : '#3f51b5' ,
47
- width : '60px' ,
48
- textAlign : 'center' ,
49
- fontSize : '20px' ,
50
- fontWeight : 'bold' ,
51
- color : 'white' ,
52
- padding : '0 10px' ,
53
- height : '40px' ,
54
- lineHeight : '40px' ,
55
- borderRadius : '5px' ,
56
- } }
57
- >
58
- { language . toUpperCase ( ) }
59
- </ Typography >
60
- ) }
61
- < Box sx = { { width : '100%' } } >
62
- < TextField
63
- label = "Source"
64
- variant = "outlined"
65
- size = "small"
66
- fullWidth
67
- InputProps = { { readOnly : ! isEdit } }
68
- value = { title }
69
- onChange = { ( e ) => setTitle ( e . target . value ) }
70
- />
71
- { ! isNew && public_talk [ language ] && (
72
- < Typography
73
- align = "right"
74
- sx = { { fontSize : '14px' , marginTop : '8px' , fontStyle : 'italic' , marginRight : '10px' } }
75
- >
76
- { new Date ( public_talk [ language ] . modified ) . toLocaleString ( ) }
77
- </ Typography >
78
- ) }
79
- </ Box >
40
+ return (
41
+ < Box >
42
+ < Box sx = { { display : 'flex' , gap : '5px' , alignItems : 'flex-start' } } >
43
+ { language !== 'E' && (
44
+ < Typography
45
+ sx = { {
46
+ backgroundColor : '#3f51b5' ,
47
+ width : '60px' ,
48
+ textAlign : 'center' ,
49
+ fontSize : '20px' ,
50
+ fontWeight : 'bold' ,
51
+ color : 'white' ,
52
+ padding : '0 10px' ,
53
+ height : '40px' ,
54
+ lineHeight : '40px' ,
55
+ borderRadius : '5px' ,
56
+ } }
57
+ >
58
+ { language . toUpperCase ( ) }
59
+ </ Typography >
60
+ ) }
61
+ < Box sx = { { width : '100%' } } >
62
+ < TextField
63
+ label = 'Source'
64
+ variant = 'outlined'
65
+ size = 'small'
66
+ fullWidth
67
+ InputProps = { { readOnly : ! isEdit } }
68
+ value = { title }
69
+ onChange = { ( e ) => setTitle ( e . target . value ) }
70
+ />
71
+ { ! isNew && public_talk [ language ] && (
72
+ < Typography align = 'right' sx = { { fontSize : '14px' , marginTop : '8px' , fontStyle : 'italic' , marginRight : '10px' } } >
73
+ { new Date ( public_talk [ language ] . modified ) . toLocaleString ( ) }
74
+ </ Typography >
75
+ ) }
76
+ </ Box >
80
77
81
- { ! isEdit && (
82
- < IconButton aria-label = " edit" color = " info" onClick = { handleEdit } >
83
- < EditIcon />
84
- </ IconButton >
85
- ) }
86
- { isEdit && ! isNew && (
87
- < IconButton aria-label = " save" color = " error" onClick = { handleCancel } >
88
- < ClearIcon />
89
- </ IconButton >
90
- ) }
91
- { isEdit && (
92
- < IconButton aria-label = " save" color = " success" onClick = { handleSave } >
93
- { isNew && < AddCircleIcon /> }
94
- { ! isNew && < CheckIcon /> }
95
- </ IconButton >
96
- ) }
97
- </ Box >
98
- </ Box >
99
- ) ;
78
+ { ! isEdit && (
79
+ < IconButton aria-label = ' edit' color = ' info' onClick = { handleEdit } >
80
+ < EditIcon />
81
+ </ IconButton >
82
+ ) }
83
+ { isEdit && ! isNew && (
84
+ < IconButton aria-label = ' save' color = ' error' onClick = { handleCancel } >
85
+ < ClearIcon />
86
+ </ IconButton >
87
+ ) }
88
+ { isEdit && (
89
+ < IconButton aria-label = ' save' color = ' success' onClick = { handleSave } >
90
+ { isNew && < AddCircleIcon /> }
91
+ { ! isNew && < CheckIcon /> }
92
+ </ IconButton >
93
+ ) }
94
+ </ Box >
95
+ </ Box >
96
+ ) ;
100
97
} ;
101
98
102
99
export default PublicTalkEditor ;
0 commit comments