-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLlogaria.js
107 lines (93 loc) · 4.18 KB
/
Llogaria.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
import React,{Component} from 'react';
import { Table } from 'react-bootstrap';
import{Button,ButtonToolbar} from 'react-bootstrap';
import {EditLlogariaModal} from './Modules/EditLlogariaModal'
import { AddLlogariaModal } from './Modules/AddLlogariaModal';
import '../prova.css';
export class Llogaria extends Component{
constructor(props){
super(props);
this.state={deps:[], addModalShow:false, editModalShow:false}
}
refreshList(){
fetch('https://localhost:7222/api/Llogaria')
.then(response => response.json())
.then(data=>{
console.log("Works");
this.setState({deps:data});
});
}
componentDidMount(){
this.refreshList();
}
componentDidUpdate(){
this.refreshList();
}
deleteLlogarin(lid){
if(window.confirm('Are you sure?')){
fetch('https://localhost:7222/api/llogaria/' + lid,{
method:'DELETE',
header:{'Accept':'application/json',
'Content-Type':'application/json'}
})
}
}
render(){
const {deps, ofID, username, passwordi}=this.state;
let addModalClose=()=>this.setState({addModalShow:false});
let editModalClose=()=>this.setState({editModalShow:false});
return(
<div >
<h2 className='h2Oficeri'>Oficeret qe kane qasje ne aplikacion!</h2>
<ButtonToolbar >
<Button className='shtoLlogarin' variant='primary'
onClick={()=>this.setState({addModalShow:true})}>
Shto Llogarin
</Button>
<AddLlogariaModal 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'>OficeriID</th>
<th className='tr1ID'>Username</th>
<th className='tr1ID'>Password</th>
<th className='tr1ID action'>Action</th>
</tr>
</thead>
<tbody>
{deps.map(l=>
<tr className='tr1ID' key={l.OficeriID}>
<td className='tr1ID'>{l.OficeriID}</td>
<td className='tr1ID'>{l.username}</td>
<td className='tr1ID'>{l.passwordi}</td>
<td className='tr1ID'>
<ButtonToolbar>
<Button className="mr-2" variant="info"
onClick={()=>this.setState({editModalShow:true,
ofID:l.OficeriID, username:l.username, passwordi:l.passwordi })}>
EDIT
</Button>
<Button className="mr-2 deleteButton" variant="danger"
onClick={()=>this.deleteLlogarin(l.OficeriID)}>
DELETE
</Button>
<EditLlogariaModal show={this.state.editModalShow}
onHide={editModalClose}
ofID={ofID}
username={username}
passwordi={passwordi}
/>
</ButtonToolbar>
</td>
</tr>
)}
</tbody>
</Table>
</div>
</div>
)
}
}