-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDrejtori.js
126 lines (112 loc) · 5.44 KB
/
Drejtori.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import React,{Component} from 'react';
import { Table } from 'react-bootstrap';
import{Button,ButtonToolbar} from 'react-bootstrap';
import {EditDrejtoriModal} from './Modules/EditDrejtoriModal'
import { AddDrejtoriModal } from './Modules/AddDrejtoriModal';
import '../prova.css';
export class Drejtori extends Component{
constructor(props){
super(props);
this.state={deps:[], addModalShow:false, editModalShow:false}
}
refreshList(){
fetch('https://localhost:7222/api/Drejtori')
.then(response => response.json())
.then(data=>{
console.log("Works");
this.setState({deps:data});
});
}
componentDidMount(){
this.refreshList();
}
componentDidUpdate(){
this.refreshList();
}
deleteDrejtorin(lid){
if(window.confirm('Are you sure?')){
fetch('https://localhost:7222/api/Drejtori/' + lid,{
method:'DELETE',
header:{'Accept':'application/json',
'Content-Type':'application/json'}
})
}
}
render(){
const {deps, drID, sID, emri, mbiemri, qyteti, rruga, zipkodi, datelindja, gjinia}=this.state;
let addModalClose=()=>this.setState({addModalShow:false});
let editModalClose=()=>this.setState({editModalShow:false});
return(
<div >
<h2 className='h2Oficeri'>Drejtoret</h2>
<ButtonToolbar >
<Button className='shtoLlogarin' variant='primary'
onClick={()=>this.setState({addModalShow:true})}>
Shto Drejtorin
</Button>
<AddDrejtoriModal show={this.state.addModalShow}
onHide={addModalClose}/>
</ButtonToolbar>
<div className='div1'>
<Table className='mt-4' striped bordered hover size="s">
<thead className='theadID'>
<tr className='tr1ID'>
<th className='tr1ID'>DrejtoriID</th>
<th className='tr1ID'>SektoriID</th>
<th className='tr1ID'>Emri</th>
<th className='tr1ID'>Mbiemri</th>
<th className='tr1ID'>Qyteti</th>
<th className='tr1ID'>Rruga</th>
<th className='tr1ID'>Zipkodi</th>
<th className='tr1ID'>Datelindja</th>
<th className='tr1ID'>Gjinia</th>
<th className='tr1ID action'>Action</th>
</tr>
</thead>
<tbody>
{deps.map(l=>
<tr className='tr1ID' key={l.DrejtoriID}>
<td className='tr1ID'>{l.DrejtoriID}</td>
<td className='tr1ID'>{l.SektoriID}</td>
<td className='tr1ID'>{l.Emri}</td>
<td className='tr1ID'>{l.Mbiemri}</td>
<td className='tr1ID'>{l.Qyteti}</td>
<td className='tr1ID'>{l.Rruga}</td>
<td className='tr1ID'>{l.ZipKodi}</td>
<td className='tr1ID'>{l.DateLindja}</td>
<td className='tr1ID'>{l.Gjinia}</td>
<td className='tr1ID'>
<ButtonToolbar>
<Button className="mr-2" variant="info"
onClick={()=>this.setState({editModalShow:true,
drID:l.DrejtoriID, sID:l.SektoriID, emri:l.Emri, mbiemri:l.Mbiemri, qyteti:l.Qyteti,
rruga:l.Rruga, zipkodi:l.ZipKodi, datelindja:l.DateLindja, gjinia:l.Gjinia })}>
EDIT
</Button>
<Button className="mr-2 deleteButton" variant="danger"
onClick={()=>this.deleteDrejtorin(l.DrejtoriID)}>
DELETE
</Button>
<EditDrejtoriModal show={this.state.editModalShow}
onHide={editModalClose}
drID={drID}
sID={sID}
emri={emri}
mbiemri={mbiemri}
qyteti={qyteti}
rruga={rruga}
zipkodi={zipkodi}
datelindja={datelindja}
gjinia={gjinia}
/>
</ButtonToolbar>
</td>
</tr>
)}
</tbody>
</Table>
</div>
</div>
)
}
}