StudentDelete.js
2.04 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React from 'react';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import { createMuiTheme } from '@material-ui/core/styles';
import {blue, pink} from '@material-ui/core/colors';
const theme = createMuiTheme({
palette: {
primary: {
main: blue[100],
},
secondary: {
main: pink[100],
},
},
});
class StudentDelete extends React.Component{
constructor(props){
super(props);
this.state = {
open: false
}
}
handleClickOpen = () => {
this.setState({
open:true
});
}
handleClose = () => {
this.setState({
open: false
})
}
deleteStudent(st_Code){
const url='/api/students/'+st_Code;
fetch(url,{
method:'DELETE'
});
this.props.stateRefresh();
}
render(){
return(
<div>
<Button variant="contained" color="secondary" onClick={this.handleClickOpen}>삭제</Button>
<Dialog open={this.state.open} onClose={this.handleClose}>
<DialogTitle onClose={this.handleClose}>
삭제 경고
</DialogTitle>
<DialogContent>
<Typography gutterBottom>
선택한 학생의 정보가 삭제됩니다!
</Typography>
</DialogContent>
<DialogActions>
<Button variant="contained" color="secondary" onClick={(e)=>{this.deleteStudent(this.props.st_Code)}}>삭제</Button>
<Button variant="outlined" color="secondary" onClick={this.handleClose}>닫기</Button>
</DialogActions>
</Dialog>
</div>
)
}
}
export default StudentDelete;