Revize 5bedee9e
Přidáno uživatelem plundrichov před více než 4 roky(ů)
client/src/UpcomingRequests.js | ||
---|---|---|
2 | 2 |
import './App.css'; |
3 | 3 |
import moment from 'moment'; |
4 | 4 |
import * as api_fetch from './api' |
5 |
import convertVacationType from './convertVacationType' |
|
5 | 6 |
|
6 | 7 |
function UpcomingRequests(props) { |
7 | 8 |
|
... | ... | |
14 | 15 |
|
15 | 16 |
api_fetch.loadAdminRequests().then((data) => { |
16 | 17 |
props.setUser(data.map(request => { |
17 |
|
|
18 |
const a = request.date; |
|
19 |
const b = [a.slice(0, 4), "-", a.slice(5, 7), "-", a.slice(8, 10)].join(''); |
|
18 |
|
|
19 |
const convertedStartDate = request.date.split("/").join("-"); |
|
20 | 20 |
|
21 | 21 |
return ( |
22 | 22 |
{ |
23 | 23 |
title: request.firstName + ' ' + request.lastName, |
24 | 24 |
id: request.id, |
25 | 25 |
type: convertVacationType(request.type), |
26 |
start: moment(b).format("D.M.YYYY"),
|
|
26 |
start: moment(convertedStartDate).format("D.M.YYYY"),
|
|
27 | 27 |
end: null, |
28 | 28 |
status: request.status = request.status.toLowerCase() |
29 | 29 |
}) |
... | ... | |
33 | 33 |
}); |
34 | 34 |
} |
35 | 35 |
|
36 |
function convertVacationType(vacationType) { |
|
37 |
switch (vacationType) { |
|
38 |
case 'SICK_DAY' : |
|
39 |
return 'sickday'; |
|
40 |
default: |
|
41 |
return 'holiday'; |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
|
|
46 | 36 |
|
47 | 37 |
// send accepted request to server |
48 | 38 |
const acceptRequest = async (user) => { |
... | ... | |
57 | 47 |
|
58 | 48 |
const userProps = { |
59 | 49 |
title: user.title, |
60 |
id: 0, |
|
61 |
type: user.type, |
|
62 |
type: user.type, |
|
63 | 50 |
type: user.type, |
64 | 51 |
start: user.start |
65 | 52 |
} |
... | ... | |
69 | 56 |
props.setUser((pendingRequest) => pendingRequest.filter((item) => item !== user)); |
70 | 57 |
}) |
71 | 58 |
} catch (e) { |
72 |
throw 'error catch GET DATA APP (getCurrentProfile)'
|
|
59 |
alert(e)
|
|
73 | 60 |
} |
74 | 61 |
} |
75 | 62 |
|
... | ... | |
102 | 89 |
<div className="offs-items column"> |
103 | 90 |
<div className="offs-item row"> |
104 | 91 |
<table> |
105 |
{/* {props.user.length > 0 |
|
106 |
? */} |
|
107 | 92 |
<tbody> |
108 | 93 |
<tr> |
109 | 94 |
<th>Name</th> |
... | ... | |
122 | 107 |
</tr> |
123 | 108 |
))} |
124 | 109 |
</tbody> |
125 |
{/* :
|
|
110 |
: |
|
126 | 111 |
<tbody> |
127 | 112 |
<p>There are no requests.</p> |
128 | 113 |
</tbody> |
129 |
} */} |
|
130 |
|
|
131 |
</table> |
|
114 |
|
|
115 |
</table> |
|
132 | 116 |
</div> |
133 | 117 |
</div> |
134 | 118 |
</div> |
135 | 119 |
) |
136 | 120 |
} |
137 | 121 |
|
138 |
export default UpcomingRequests; |
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
// return (shouldRemoveThisItem === true) ? false : true; |
|
144 |
//}) |
|
145 |
//) |
|
146 |
// props.setUser((pendingRequest) => pendingRequest.filter( |
|
147 |
|
|
148 |
// function(item) { |
|
149 |
// const shouldRemoveThisItem = item === user; |
|
150 |
|
|
151 |
// if (shouldRemoveThisItem === true) { |
|
152 |
// return false; |
|
153 |
// } else { |
|
154 |
// return true; |
|
155 |
// }}) |
|
156 |
// ) |
|
122 |
export default UpcomingRequests; |
Také k dispozici: Unified diff
re #58 Rewrited client app to React #58 // yoso internal app // in progress #60 // fixed