1
|
|
|
import React, { createRef, Fragment, useEffect, useState } from 'react'; |
2
|
|
|
import paginationFactory, { PaginationProvider } from 'react-bootstrap-table2-paginator'; |
3
|
|
|
import BootstrapTable from 'react-bootstrap-table-next'; |
4
|
|
|
import { |
5
|
|
|
Breadcrumb, |
6
|
|
|
BreadcrumbItem, |
7
|
|
|
Row, |
8
|
|
|
Col, |
9
|
|
|
Card, |
10
|
|
|
CardBody, |
11
|
|
|
Button, |
12
|
|
|
ButtonGroup, |
13
|
|
|
Form, |
14
|
|
|
FormGroup, |
15
|
|
|
Input, |
16
|
|
|
Label, |
17
|
|
|
CustomInput, |
18
|
|
|
DropdownItem, |
19
|
|
|
DropdownMenu, |
20
|
|
|
DropdownToggle, |
21
|
|
|
InputGroup, |
22
|
|
|
UncontrolledDropdown, |
23
|
|
|
Spinner, |
24
|
|
|
} from 'reactstrap'; |
25
|
|
|
import Datetime from 'react-datetime'; |
26
|
|
|
import moment from 'moment'; |
27
|
|
|
import Cascader from 'rc-cascader'; |
28
|
|
|
import { Link } from 'react-router-dom'; |
29
|
|
|
import Badge from 'reactstrap/es/Badge'; |
30
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
31
|
|
|
import FalconCardHeader from '../../common/FalconCardHeader'; |
32
|
|
|
import uuid from 'uuid/v1'; |
33
|
|
|
import { getCookieValue, createCookie } from '../../../helpers/utils'; |
34
|
|
|
import withRedirect from '../../../hoc/withRedirect'; |
35
|
|
|
import { getPaginationArray } from '../../../helpers/utils'; |
36
|
|
|
import { withTranslation } from 'react-i18next'; |
37
|
|
|
import { toast } from 'react-toastify'; |
38
|
|
|
import ButtonIcon from '../../common/ButtonIcon'; |
39
|
|
|
import { APIBaseURL } from '../../../config'; |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
const EquipmentFault = ({ setRedirect, setRedirectUrl, t }) => { |
43
|
|
|
let current_moment = moment(); |
44
|
|
|
useEffect(() => { |
45
|
|
|
let is_logged_in = getCookieValue('is_logged_in'); |
46
|
|
|
let user_name = getCookieValue('user_name'); |
47
|
|
|
let user_display_name = getCookieValue('user_display_name'); |
48
|
|
|
let user_uuid = getCookieValue('user_uuid'); |
49
|
|
|
let token = getCookieValue('token'); |
50
|
|
|
if (is_logged_in === null || !is_logged_in) { |
51
|
|
|
setRedirectUrl(`/authentication/basic/login`); |
52
|
|
|
setRedirect(true); |
53
|
|
|
} else { |
54
|
|
|
//update expires time of cookies |
55
|
|
|
createCookie('is_logged_in', true, 1000 * 60 * 60 * 8); |
56
|
|
|
createCookie('user_name', user_name, 1000 * 60 * 60 * 8); |
57
|
|
|
createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8); |
58
|
|
|
createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8); |
59
|
|
|
createCookie('token', token, 1000 * 60 * 60 * 8); |
60
|
|
|
} |
61
|
|
|
}); |
62
|
|
|
// State |
63
|
|
|
// Query Parameters |
64
|
|
|
const [selectedSpaceName, setSelectedSpaceName] = useState(undefined); |
65
|
|
|
const [selectedSpaceID, setSelectedSpaceID] = useState(undefined); |
66
|
|
|
const [equipmentList, setEquipmentList] = useState([]); |
67
|
|
|
const [selectedEquipment, setSelectedEquipment] = useState(undefined); |
68
|
|
|
const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month')); |
69
|
|
|
const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment); |
70
|
|
|
const [cascaderOptions, setCascaderOptions] = useState(undefined); |
71
|
|
|
|
72
|
|
|
// buttons |
73
|
|
|
const [submitButtonDisabled, setSubmitButtonDisabled] = useState(true); |
74
|
|
|
const [spinnerHidden, setSpinnerHidden] = useState(true); |
75
|
|
|
const [exportButtonHidden, setExportButtonHidden] = useState(true); |
76
|
|
|
|
77
|
|
|
//Results |
78
|
|
|
const [detailedDataTableData, setDetailedDataTableData] = useState([]); |
79
|
|
|
const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]); |
80
|
|
|
const [excelBytesBase64, setExcelBytesBase64] = useState(undefined); |
81
|
|
|
|
82
|
|
|
useEffect(() => { |
83
|
|
|
let isResponseOK = false; |
84
|
|
|
fetch(APIBaseURL + '/spaces/tree', { |
85
|
|
|
method: 'GET', |
86
|
|
|
headers: { |
87
|
|
|
"Content-type": "application/json", |
88
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
89
|
|
|
"Token": getCookieValue('token') |
90
|
|
|
}, |
91
|
|
|
body: null, |
92
|
|
|
|
93
|
|
|
}).then(response => { |
94
|
|
|
console.log(response); |
95
|
|
|
if (response.ok) { |
96
|
|
|
isResponseOK = true; |
97
|
|
|
} |
98
|
|
|
return response.json(); |
99
|
|
|
}).then(json => { |
100
|
|
|
console.log(json); |
101
|
|
|
if (isResponseOK) { |
102
|
|
|
// rename keys |
103
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
104
|
|
|
setCascaderOptions(json); |
105
|
|
|
setSelectedSpaceName([json[0]].map(o => o.label)); |
106
|
|
|
setSelectedSpaceID([json[0]].map(o => o.value)); |
107
|
|
|
// get Equipments by root Space ID |
108
|
|
|
let isResponseOK = false; |
109
|
|
|
fetch(APIBaseURL + '/spaces/' + [json[0]].map(o => o.value) + '/equipments', { |
110
|
|
|
method: 'GET', |
111
|
|
|
headers: { |
112
|
|
|
"Content-type": "application/json", |
113
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
114
|
|
|
"Token": getCookieValue('token') |
115
|
|
|
}, |
116
|
|
|
body: null, |
117
|
|
|
|
118
|
|
|
}).then(response => { |
119
|
|
|
if (response.ok) { |
120
|
|
|
isResponseOK = true; |
121
|
|
|
} |
122
|
|
|
return response.json(); |
123
|
|
|
}).then(json => { |
124
|
|
|
if (isResponseOK) { |
125
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
126
|
|
|
console.log(json); |
127
|
|
|
setEquipmentList(json[0]); |
128
|
|
|
if (json[0].length > 0) { |
129
|
|
|
setSelectedEquipment(json[0][0].value); |
130
|
|
|
// enable submit button |
131
|
|
|
setSubmitButtonDisabled(false); |
132
|
|
|
} else { |
133
|
|
|
setSelectedEquipment(undefined); |
134
|
|
|
// disable submit button |
135
|
|
|
setSubmitButtonDisabled(true); |
136
|
|
|
} |
137
|
|
|
} else { |
138
|
|
|
toast.error(json.description) |
139
|
|
|
} |
140
|
|
|
}).catch(err => { |
141
|
|
|
console.log(err); |
142
|
|
|
}); |
143
|
|
|
// end of get Equipments by root Space ID |
144
|
|
|
} else { |
145
|
|
|
toast.error(json.description); |
146
|
|
|
} |
147
|
|
|
}).catch(err => { |
148
|
|
|
console.log(err); |
149
|
|
|
}); |
150
|
|
|
|
151
|
|
|
}, []); |
152
|
|
|
const orderFormatter = (dataField, { id, name, email }) => ( |
153
|
|
|
<Fragment> |
154
|
|
|
<Link to="/e-commerce/order-details"> |
155
|
|
|
<strong>#{id}</strong> |
156
|
|
|
</Link>{' '} |
157
|
|
|
by <strong>{name}</strong> |
158
|
|
|
<br /> |
159
|
|
|
<a href={`mailto:${email}`}>{email}</a> |
160
|
|
|
</Fragment> |
161
|
|
|
); |
162
|
|
|
|
163
|
|
|
const shippingFormatter = (address, { shippingType }) => ( |
164
|
|
|
<Fragment> |
165
|
|
|
{address} |
166
|
|
|
<p className="mb-0 text-500">{shippingType}</p> |
167
|
|
|
</Fragment> |
168
|
|
|
); |
169
|
|
|
|
170
|
|
|
const badgeFormatter = status => { |
171
|
|
|
let color = ''; |
172
|
|
|
let icon = ''; |
173
|
|
|
let text = ''; |
174
|
|
|
switch (status) { |
175
|
|
|
case 'success': |
176
|
|
|
color = 'success'; |
177
|
|
|
icon = 'check'; |
178
|
|
|
text = 'Completed'; |
179
|
|
|
break; |
180
|
|
|
case 'hold': |
181
|
|
|
color = 'secondary'; |
182
|
|
|
icon = 'ban'; |
183
|
|
|
text = 'On hold'; |
184
|
|
|
break; |
185
|
|
|
case 'processing': |
186
|
|
|
color = 'primary'; |
187
|
|
|
icon = 'redo'; |
188
|
|
|
text = 'Processing'; |
189
|
|
|
break; |
190
|
|
|
case 'pending': |
191
|
|
|
color = 'warning'; |
192
|
|
|
icon = 'stream'; |
193
|
|
|
text = 'Pending'; |
194
|
|
|
break; |
195
|
|
|
default: |
196
|
|
|
color = 'warning'; |
197
|
|
|
icon = 'stream'; |
198
|
|
|
text = 'Pending'; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
return ( |
202
|
|
|
<Badge color={`soft-${color}`} className="rounded-capsule fs--1 d-block"> |
203
|
|
|
{text} |
204
|
|
|
<FontAwesomeIcon icon={icon} transform="shrink-2" className="ml-1" /> |
205
|
|
|
</Badge> |
206
|
|
|
); |
207
|
|
|
}; |
208
|
|
|
|
209
|
|
|
const actionFormatter = (dataField, { id }) => ( |
210
|
|
|
// Control your row with this id |
211
|
|
|
<UncontrolledDropdown> |
212
|
|
|
<DropdownToggle color="link" size="sm" className="text-600 btn-reveal mr-3"> |
213
|
|
|
<FontAwesomeIcon icon="ellipsis-h" className="fs--1" /> |
214
|
|
|
</DropdownToggle> |
215
|
|
|
<DropdownMenu right className="border py-2"> |
216
|
|
|
<DropdownItem onClick={() => console.log('Completed: ', id)}>Completed</DropdownItem> |
217
|
|
|
<DropdownItem onClick={() => console.log('Processing: ', id)}>Processing</DropdownItem> |
218
|
|
|
<DropdownItem onClick={() => console.log('On hold: ', id)}>On hold</DropdownItem> |
219
|
|
|
<DropdownItem onClick={() => console.log('Pending: ', id)}>Pending</DropdownItem> |
220
|
|
|
<DropdownItem divider /> |
221
|
|
|
<DropdownItem onClick={() => console.log('Delete: ', id)} className="text-danger"> |
222
|
|
|
Delete |
223
|
|
|
</DropdownItem> |
224
|
|
|
</DropdownMenu> |
225
|
|
|
</UncontrolledDropdown> |
226
|
|
|
); |
227
|
|
|
|
228
|
|
|
const options = { |
229
|
|
|
custom: true, |
230
|
|
|
sizePerPage: 10, |
231
|
|
|
totalSize: detailedDataTableData.length |
232
|
|
|
}; |
233
|
|
|
|
234
|
|
|
const SelectRowInput = ({ indeterminate, rowIndex, ...rest }) => ( |
235
|
|
|
<div className="custom-control custom-checkbox"> |
236
|
|
|
<input |
237
|
|
|
className="custom-control-input" |
238
|
|
|
{...rest} |
239
|
|
|
onChange={() => { }} |
240
|
|
|
ref={input => { |
241
|
|
|
if (input) input.indeterminate = indeterminate; |
242
|
|
|
}} |
243
|
|
|
/> |
244
|
|
|
<label className="custom-control-label" /> |
245
|
|
|
</div> |
246
|
|
|
); |
247
|
|
|
|
248
|
|
|
const selectRow = onSelect => ({ |
249
|
|
|
mode: 'checkbox', |
250
|
|
|
classes: 'py-2 align-middle', |
251
|
|
|
clickToSelect: false, |
252
|
|
|
selectionHeaderRenderer: ({ mode, ...rest }) => <SelectRowInput type="checkbox" {...rest} />, |
253
|
|
|
selectionRenderer: ({ mode, ...rest }) => <SelectRowInput type={mode} {...rest} />, |
254
|
|
|
onSelect: onSelect, |
255
|
|
|
onSelectAll: onSelect |
256
|
|
|
}); |
257
|
|
|
|
258
|
|
|
const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0'; |
259
|
|
|
|
260
|
|
|
// State |
261
|
|
|
let table = createRef(); |
262
|
|
|
|
263
|
|
|
const [isSelected, setIsSelected] = useState(false); |
264
|
|
|
const handleNextPage = ({ page, onPageChange }) => () => { |
265
|
|
|
onPageChange(page + 1); |
266
|
|
|
}; |
267
|
|
|
|
268
|
|
|
const handlePrevPage = ({ page, onPageChange }) => () => { |
269
|
|
|
onPageChange(page - 1); |
270
|
|
|
}; |
271
|
|
|
|
272
|
|
|
const onSelect = () => { |
273
|
|
|
setImmediate(() => { |
274
|
|
|
setIsSelected(!!table.current.selectionContext.selected.length); |
275
|
|
|
}); |
276
|
|
|
}; |
277
|
|
|
|
278
|
|
|
let onSpaceCascaderChange = (value, selectedOptions) => { |
279
|
|
|
setSelectedSpaceName(selectedOptions.map(o => o.label).join('/')); |
280
|
|
|
setSelectedSpaceID(value[value.length - 1]); |
281
|
|
|
|
282
|
|
|
let isResponseOK = false; |
283
|
|
|
fetch(APIBaseURL + '/spaces/' + value[value.length - 1] + '/equipments', { |
284
|
|
|
method: 'GET', |
285
|
|
|
headers: { |
286
|
|
|
"Content-type": "application/json", |
287
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
288
|
|
|
"Token": getCookieValue('token') |
289
|
|
|
}, |
290
|
|
|
body: null, |
291
|
|
|
|
292
|
|
|
}).then(response => { |
293
|
|
|
if (response.ok) { |
294
|
|
|
isResponseOK = true; |
295
|
|
|
} |
296
|
|
|
return response.json(); |
297
|
|
|
}).then(json => { |
298
|
|
|
if (isResponseOK) { |
299
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
300
|
|
|
console.log(json) |
301
|
|
|
setEquipmentList(json[0]); |
302
|
|
|
if (json[0].length > 0) { |
303
|
|
|
setSelectedEquipment(json[0][0].value); |
304
|
|
|
// enable submit button |
305
|
|
|
setSubmitButtonDisabled(false); |
306
|
|
|
} else { |
307
|
|
|
setSelectedEquipment(undefined); |
308
|
|
|
// disable submit button |
309
|
|
|
setSubmitButtonDisabled(true); |
310
|
|
|
} |
311
|
|
|
} else { |
312
|
|
|
toast.error(json.description) |
313
|
|
|
} |
314
|
|
|
}).catch(err => { |
315
|
|
|
console.log(err); |
316
|
|
|
}); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
let onReportingPeriodBeginsDatetimeChange = (newDateTime) => { |
320
|
|
|
setReportingPeriodBeginsDatetime(newDateTime); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
let onReportingPeriodEndsDatetimeChange = (newDateTime) => { |
324
|
|
|
setReportingPeriodEndsDatetime(newDateTime); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
var getValidReportingPeriodBeginsDatetimes = function (currentDate) { |
328
|
|
|
return currentDate.isBefore(moment(reportingPeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a')); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
var getValidReportingPeriodEndsDatetimes = function (currentDate) { |
332
|
|
|
return currentDate.isAfter(moment(reportingPeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a')); |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
// Handler |
336
|
|
|
const handleSubmit = e => { |
337
|
|
|
e.preventDefault(); |
338
|
|
|
console.log('handleSubmit'); |
339
|
|
|
console.log(selectedSpaceID); |
340
|
|
|
console.log(selectedEquipment); |
341
|
|
|
console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss')); |
342
|
|
|
console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss')); |
343
|
|
|
|
344
|
|
|
// disable submit button |
345
|
|
|
setSubmitButtonDisabled(true); |
346
|
|
|
// show spinner |
347
|
|
|
setSpinnerHidden(false); |
348
|
|
|
// hide export buttion |
349
|
|
|
setExportButtonHidden(true) |
350
|
|
|
|
351
|
|
|
// Reinitialize tables |
352
|
|
|
setDetailedDataTableData([]); |
353
|
|
|
|
354
|
|
|
let isResponseOK = false; |
355
|
|
|
fetch(APIBaseURL + '/reports/fddequipmentfault?' + |
356
|
|
|
'equipmentid' + selectedEquipment + |
357
|
|
|
'&reportingperiodstartdatetime=' + reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') + |
358
|
|
|
'&reportingperiodenddatetime=' + reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'), { |
359
|
|
|
method: 'GET', |
360
|
|
|
headers: { |
361
|
|
|
"Content-type": "application/json", |
362
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
363
|
|
|
"Token": getCookieValue('token') |
364
|
|
|
}, |
365
|
|
|
body: null, |
366
|
|
|
|
367
|
|
|
}).then(response => { |
368
|
|
|
if (response.ok) { |
369
|
|
|
isResponseOK = true; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
// enable submit button |
373
|
|
|
setSubmitButtonDisabled(false); |
374
|
|
|
// hide spinner |
375
|
|
|
setSpinnerHidden(true); |
376
|
|
|
// show export buttion |
377
|
|
|
setExportButtonHidden(false) |
378
|
|
|
|
379
|
|
|
return response.json(); |
380
|
|
|
}).then(json => { |
381
|
|
|
if (isResponseOK) { |
382
|
|
|
console.log(json); |
383
|
|
|
|
384
|
|
|
setDetailedDataTableData([ |
385
|
|
|
{ |
386
|
|
|
id: uuid().split('-')[0], |
387
|
|
|
// id: 181, |
388
|
|
|
name: 'Ricky Antony', |
389
|
|
|
email: '[email protected]', |
390
|
|
|
date: '20/04/2019', |
391
|
|
|
address: 'Ricky Antony, 2392 Main Avenue, Penasauka, New Jersey 02149', |
392
|
|
|
shippingType: 'Via Flat Rate', |
393
|
|
|
status: 'success', |
394
|
|
|
amount: 99 |
395
|
|
|
}, |
396
|
|
|
{ |
397
|
|
|
id: uuid().split('-')[0], |
398
|
|
|
// id: 182, |
399
|
|
|
name: 'Kin Rossow', |
400
|
|
|
email: '[email protected]', |
401
|
|
|
date: '20/04/2019', |
402
|
|
|
address: 'Kin Rossow, 1 Hollywood Blvd,Beverly Hills, California 90210', |
403
|
|
|
shippingType: 'Via Free Shipping', |
404
|
|
|
status: 'success', |
405
|
|
|
amount: 120 |
406
|
|
|
}, |
407
|
|
|
{ |
408
|
|
|
id: uuid().split('-')[0], |
409
|
|
|
// id: 183, |
410
|
|
|
name: 'Merry Diana', |
411
|
|
|
email: '[email protected]', |
412
|
|
|
date: '30/04/2019', |
413
|
|
|
address: 'Merry Diana, 1 Infinite Loop, Cupertino, California 90210', |
414
|
|
|
shippingType: 'Via Link Road', |
415
|
|
|
status: 'hold', |
416
|
|
|
amount: 70 |
417
|
|
|
}, |
418
|
|
|
{ |
419
|
|
|
id: uuid().split('-')[0], |
420
|
|
|
// id: 184, |
421
|
|
|
name: 'Bucky Robert', |
422
|
|
|
email: '[email protected]', |
423
|
|
|
date: '30/04/2019', |
424
|
|
|
address: 'Bucky Robert, 1 Infinite Loop, Cupertino, California 90210', |
425
|
|
|
shippingType: 'Via Free Shipping', |
426
|
|
|
status: 'pending', |
427
|
|
|
amount: 92 |
428
|
|
|
}, |
429
|
|
|
{ |
430
|
|
|
id: uuid().split('-')[0], |
431
|
|
|
// id: 185, |
432
|
|
|
name: 'Rocky Zampa', |
433
|
|
|
email: '[email protected]', |
434
|
|
|
date: '30/04/2019', |
435
|
|
|
address: 'Rocky Zampa, 1 Infinite Loop, Cupertino, California 90210', |
436
|
|
|
shippingType: 'Via Free Road', |
437
|
|
|
status: 'hold', |
438
|
|
|
amount: 120 |
439
|
|
|
}, |
440
|
|
|
{ |
441
|
|
|
id: uuid().split('-')[0], |
442
|
|
|
// id: 186, |
443
|
|
|
name: 'Ricky John', |
444
|
|
|
email: '[email protected]', |
445
|
|
|
date: '30/04/2019', |
446
|
|
|
address: 'Ricky John, 1 Infinite Loop, Cupertino, California 90210', |
447
|
|
|
shippingType: 'Via Free Shipping', |
448
|
|
|
status: 'processing', |
449
|
|
|
amount: 145 |
450
|
|
|
}, |
451
|
|
|
{ |
452
|
|
|
id: uuid().split('-')[0], |
453
|
|
|
// id: 187, |
454
|
|
|
name: 'Cristofer Henric', |
455
|
|
|
email: '[email protected]', |
456
|
|
|
date: '30/04/2019', |
457
|
|
|
address: 'Cristofer Henric, 1 Infinite Loop, Cupertino, California 90210', |
458
|
|
|
shippingType: 'Via Flat Rate', |
459
|
|
|
status: 'success', |
460
|
|
|
amount: 55 |
461
|
|
|
}, |
462
|
|
|
{ |
463
|
|
|
id: uuid().split('-')[0], |
464
|
|
|
// id: 188, |
465
|
|
|
name: 'Brate Lee', |
466
|
|
|
email: '[email protected]', |
467
|
|
|
date: '29/04/2019', |
468
|
|
|
address: 'Brate Lee, 1 Infinite Loop, Cupertino, California 90210', |
469
|
|
|
shippingType: 'Via Link Road', |
470
|
|
|
status: 'hold', |
471
|
|
|
amount: 90 |
472
|
|
|
}, |
473
|
|
|
{ |
474
|
|
|
id: uuid().split('-')[0], |
475
|
|
|
// id: 189, |
476
|
|
|
name: 'Thomas Stephenson', |
477
|
|
|
email: '[email protected]', |
478
|
|
|
date: '29/04/2019', |
479
|
|
|
address: 'Thomas Stephenson, 116 Ballifeary Road, Bamff', |
480
|
|
|
shippingType: 'Via Flat Rate', |
481
|
|
|
status: 'processing', |
482
|
|
|
amount: 52 |
483
|
|
|
}, |
484
|
|
|
{ |
485
|
|
|
id: uuid().split('-')[0], |
486
|
|
|
// id: 190, |
487
|
|
|
name: 'Evie Singh', |
488
|
|
|
email: '[email protected]', |
489
|
|
|
date: '29/04/2019', |
490
|
|
|
address: 'Evie Singh, 54 Castledore Road, Tunstead', |
491
|
|
|
shippingType: 'Via Flat Rate', |
492
|
|
|
status: 'success', |
493
|
|
|
amount: 90 |
494
|
|
|
}, |
495
|
|
|
{ |
496
|
|
|
id: uuid().split('-')[0], |
497
|
|
|
// id: 191, |
498
|
|
|
name: 'David Peters', |
499
|
|
|
email: '[email protected]', |
500
|
|
|
date: '29/04/2019', |
501
|
|
|
address: 'David Peters, Rhyd Y Groes, Rhosgoch, LL66 0AT', |
502
|
|
|
shippingType: 'Via Link Road', |
503
|
|
|
status: 'success', |
504
|
|
|
amount: 69 |
505
|
|
|
}, |
506
|
|
|
{ |
507
|
|
|
id: uuid().split('-')[0], |
508
|
|
|
// id: 192, |
509
|
|
|
name: 'Jennifer Johnson', |
510
|
|
|
email: '[email protected]', |
511
|
|
|
date: '28/04/2019', |
512
|
|
|
address: 'Jennifer Johnson, Rhyd Y Groes, Rhosgoch, LL66 0AT', |
513
|
|
|
shippingType: 'Via Flat Rate', |
514
|
|
|
status: 'processing', |
515
|
|
|
amount: 112 |
516
|
|
|
}, |
517
|
|
|
{ |
518
|
|
|
id: uuid().split('-')[0], |
519
|
|
|
// id: 193, |
520
|
|
|
name: ' Demarcus Okuneva', |
521
|
|
|
email: '[email protected]', |
522
|
|
|
date: '28/04/2019', |
523
|
|
|
address: ' Demarcus Okuneva, 90555 Upton Drive Jeffreyview, UT 08771', |
524
|
|
|
shippingType: 'Via Flat Rate', |
525
|
|
|
status: 'success', |
526
|
|
|
amount: 99 |
527
|
|
|
}, |
528
|
|
|
{ |
529
|
|
|
id: uuid().split('-')[0], |
530
|
|
|
// id: 194, |
531
|
|
|
name: 'Simeon Harber', |
532
|
|
|
email: '[email protected]', |
533
|
|
|
date: '27/04/2019', |
534
|
|
|
address: 'Simeon Harber, 702 Kunde Plain Apt. 634 East Bridgetview, HI 13134-1862', |
535
|
|
|
shippingType: 'Via Free Shipping', |
536
|
|
|
status: 'hold', |
537
|
|
|
amount: 129 |
538
|
|
|
}, |
539
|
|
|
{ |
540
|
|
|
id: uuid().split('-')[0], |
541
|
|
|
// id: 195, |
542
|
|
|
name: 'Lavon Haley', |
543
|
|
|
email: '[email protected]', |
544
|
|
|
date: '27/04/2019', |
545
|
|
|
address: 'Lavon Haley, 30998 Adonis Locks McGlynnside, ID 27241', |
546
|
|
|
shippingType: 'Via Free Shipping', |
547
|
|
|
status: 'pending', |
548
|
|
|
amount: 70 |
549
|
|
|
}, |
550
|
|
|
{ |
551
|
|
|
id: uuid().split('-')[0], |
552
|
|
|
// id: 196, |
553
|
|
|
name: 'Ashley Kirlin', |
554
|
|
|
email: '[email protected]', |
555
|
|
|
date: '26/04/2019', |
556
|
|
|
address: 'Ashley Kirlin, 43304 Prosacco Shore South Dejuanfurt, MO 18623-0505', |
557
|
|
|
shippingType: 'Via Link Road', |
558
|
|
|
status: 'processing', |
559
|
|
|
amount: 39 |
560
|
|
|
}, |
561
|
|
|
{ |
562
|
|
|
id: uuid().split('-')[0], |
563
|
|
|
// id: 197, |
564
|
|
|
name: 'Johnnie Considine', |
565
|
|
|
email: '[email protected]', |
566
|
|
|
date: '26/04/2019', |
567
|
|
|
address: 'Johnnie Considine, 6008 Hermann Points Suite 294 Hansenville, TN 14210', |
568
|
|
|
shippingType: 'Via Flat Rate', |
569
|
|
|
status: 'pending', |
570
|
|
|
amount: 70 |
571
|
|
|
}, |
572
|
|
|
{ |
573
|
|
|
id: uuid().split('-')[0], |
574
|
|
|
// id: 198, |
575
|
|
|
name: 'Trace Farrell', |
576
|
|
|
email: '[email protected]', |
577
|
|
|
date: '26/04/2019', |
578
|
|
|
address: 'Trace Farrell, 431 Steuber Mews Apt. 252 Germanland, AK 25882', |
579
|
|
|
shippingType: 'Via Free Shipping', |
580
|
|
|
status: 'success', |
581
|
|
|
amount: 70 |
582
|
|
|
}, |
583
|
|
|
{ |
584
|
|
|
id: uuid().split('-')[0], |
585
|
|
|
// id: 199, |
586
|
|
|
name: 'Estell Nienow', |
587
|
|
|
email: '[email protected]', |
588
|
|
|
date: '26/04/2019', |
589
|
|
|
address: 'Estell Nienow, 4167 Laverna Manor Marysemouth, NV 74590', |
590
|
|
|
shippingType: 'Via Free Shipping', |
591
|
|
|
status: 'success', |
592
|
|
|
amount: 59 |
593
|
|
|
}, |
594
|
|
|
{ |
595
|
|
|
id: uuid().split('-')[0], |
596
|
|
|
// id: 200, |
597
|
|
|
name: 'Daisha Howe', |
598
|
|
|
email: '[email protected]', |
599
|
|
|
date: '25/04/2019', |
600
|
|
|
address: 'Daisha Howe, 829 Lavonne Valley Apt. 074 Stehrfort, RI 77914-0379', |
601
|
|
|
shippingType: 'Via Free Shipping', |
602
|
|
|
status: 'success', |
603
|
|
|
amount: 39 |
604
|
|
|
}, |
605
|
|
|
{ |
606
|
|
|
id: uuid().split('-')[0], |
607
|
|
|
// id: 201, |
608
|
|
|
name: 'Miles Haley', |
609
|
|
|
email: '[email protected]', |
610
|
|
|
date: '24/04/2019', |
611
|
|
|
address: 'Miles Haley, 53150 Thad Squares Apt. 263 Archibaldfort, MO 00837', |
612
|
|
|
shippingType: 'Via Flat Rate', |
613
|
|
|
status: 'success', |
614
|
|
|
amount: 55 |
615
|
|
|
}, |
616
|
|
|
{ |
617
|
|
|
id: uuid().split('-')[0], |
618
|
|
|
// id: 202, |
619
|
|
|
name: 'Brenda Watsica', |
620
|
|
|
email: '[email protected]', |
621
|
|
|
date: '24/04/2019', |
622
|
|
|
address: "Brenda Watsica, 9198 O'Kon Harbors Morarborough, IA 75409-7383", |
623
|
|
|
shippingType: 'Via Free Shipping', |
624
|
|
|
status: 'success', |
625
|
|
|
amount: 89 |
626
|
|
|
}, |
627
|
|
|
{ |
628
|
|
|
id: uuid().split('-')[0], |
629
|
|
|
// id: 203, |
630
|
|
|
name: "Ellie O'Reilly", |
631
|
|
|
email: '[email protected]', |
632
|
|
|
date: '24/04/2019', |
633
|
|
|
address: "Ellie O'Reilly, 1478 Kaitlin Haven Apt. 061 Lake Muhammadmouth, SC 35848", |
634
|
|
|
shippingType: 'Via Free Shipping', |
635
|
|
|
status: 'success', |
636
|
|
|
amount: 47 |
637
|
|
|
}, |
638
|
|
|
{ |
639
|
|
|
id: uuid().split('-')[0], |
640
|
|
|
// id: 204, |
641
|
|
|
name: 'Garry Brainstrow', |
642
|
|
|
email: '[email protected]', |
643
|
|
|
date: '23/04/2019', |
644
|
|
|
address: 'Garry Brainstrow, 13572 Kurt Mews South Merritt, IA 52491', |
645
|
|
|
shippingType: 'Via Free Shipping', |
646
|
|
|
status: 'success', |
647
|
|
|
amount: 139 |
648
|
|
|
}, |
649
|
|
|
{ |
650
|
|
|
id: uuid().split('-')[0], |
651
|
|
|
// id: 205, |
652
|
|
|
name: 'Estell Pollich', |
653
|
|
|
email: '[email protected]', |
654
|
|
|
date: '23/04/2019', |
655
|
|
|
address: 'Estell Pollich, 13572 Kurt Mews South Merritt, IA 52491', |
656
|
|
|
shippingType: 'Via Free Shipping', |
657
|
|
|
status: 'hold', |
658
|
|
|
amount: 49 |
659
|
|
|
}, |
660
|
|
|
{ |
661
|
|
|
id: uuid().split('-')[0], |
662
|
|
|
// id: 206, |
663
|
|
|
name: 'Ara Mueller', |
664
|
|
|
email: '[email protected]', |
665
|
|
|
date: '23/04/2019', |
666
|
|
|
address: 'Ara Mueller, 91979 Kohler Place Waelchiborough, CT 41291', |
667
|
|
|
shippingType: 'Via Flat Rate', |
668
|
|
|
status: 'hold', |
669
|
|
|
amount: 19 |
670
|
|
|
}, |
671
|
|
|
{ |
672
|
|
|
id: uuid().split('-')[0], |
673
|
|
|
// id: 207, |
674
|
|
|
name: 'Lucienne Blick', |
675
|
|
|
email: '[email protected]', |
676
|
|
|
date: '23/04/2019', |
677
|
|
|
address: 'Lucienne Blick, 6757 Giuseppe Meadows Geraldinemouth, MO 48819-4970', |
678
|
|
|
shippingType: 'Via Flat Rate', |
679
|
|
|
status: 'hold', |
680
|
|
|
amount: 59 |
681
|
|
|
}, |
682
|
|
|
{ |
683
|
|
|
id: uuid().split('-')[0], |
684
|
|
|
// id: 208, |
685
|
|
|
name: 'Laverne Haag', |
686
|
|
|
email: '[email protected]', |
687
|
|
|
date: '22/04/2019', |
688
|
|
|
address: 'Laverne Haag, 2327 Kaylee Mill East Citlalli, AZ 89582-3143', |
689
|
|
|
shippingType: 'Via Flat Rate', |
690
|
|
|
status: 'hold', |
691
|
|
|
amount: 49 |
692
|
|
|
}, |
693
|
|
|
{ |
694
|
|
|
id: uuid().split('-')[0], |
695
|
|
|
// id: 209, |
696
|
|
|
name: 'Brandon Bednar', |
697
|
|
|
email: '[email protected]', |
698
|
|
|
date: '22/04/2019', |
699
|
|
|
address: 'Brandon Bednar, 25156 Isaac Crossing Apt. 810 Lonborough, CO 83774-5999', |
700
|
|
|
shippingType: 'Via Flat Rate', |
701
|
|
|
status: 'hold', |
702
|
|
|
amount: 39 |
703
|
|
|
}, |
704
|
|
|
{ |
705
|
|
|
id: uuid().split('-')[0], |
706
|
|
|
// id: 210, |
707
|
|
|
name: 'Dimitri Boehm', |
708
|
|
|
email: '[email protected]', |
709
|
|
|
date: '23/04/2019', |
710
|
|
|
address: 'Dimitri Boehm, 71603 Wolff Plains Apt. 885 Johnstonton, MI 01581', |
711
|
|
|
shippingType: 'Via Flat Rate', |
712
|
|
|
status: 'hold', |
713
|
|
|
amount: 111 |
714
|
|
|
} |
715
|
|
|
]); |
716
|
|
|
setDetailedDataTableColumns([ |
717
|
|
|
{ |
718
|
|
|
dataField: 'id', |
719
|
|
|
text: 'Space', |
720
|
|
|
classes: 'py-2 align-middle', |
721
|
|
|
formatter: orderFormatter, |
722
|
|
|
sort: true |
723
|
|
|
}, |
724
|
|
|
{ |
725
|
|
|
dataField: 'date', |
726
|
|
|
text: 'Date', |
727
|
|
|
classes: 'py-2 align-middle', |
728
|
|
|
sort: true |
729
|
|
|
}, |
730
|
|
|
{ |
731
|
|
|
dataField: 'address', |
732
|
|
|
text: 'Description', |
733
|
|
|
classes: 'py-2 align-middle', |
734
|
|
|
formatter: shippingFormatter, |
735
|
|
|
sort: true |
736
|
|
|
}, |
737
|
|
|
{ |
738
|
|
|
dataField: 'status', |
739
|
|
|
text: 'Status', |
740
|
|
|
classes: 'py-2 align-middle', |
741
|
|
|
formatter: badgeFormatter, |
742
|
|
|
sort: true |
743
|
|
|
}, |
744
|
|
|
{ |
745
|
|
|
dataField: '', |
746
|
|
|
text: '', |
747
|
|
|
classes: 'py-2 align-middle', |
748
|
|
|
formatter: actionFormatter, |
749
|
|
|
align: 'right' |
750
|
|
|
} |
751
|
|
|
]); |
752
|
|
|
|
753
|
|
|
setExcelBytesBase64(json['excel_bytes_base64']); |
754
|
|
|
} else { |
755
|
|
|
toast.error(json.description) |
756
|
|
|
} |
757
|
|
|
}).catch(err => { |
758
|
|
|
console.log(err); |
759
|
|
|
}); |
760
|
|
|
}; |
761
|
|
|
|
762
|
|
|
const handleExport = e => { |
763
|
|
|
e.preventDefault(); |
764
|
|
|
const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
765
|
|
|
const fileName = 'equipmentfault.xlsx' |
766
|
|
|
var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64; |
767
|
|
|
fetch(fileUrl) |
768
|
|
|
.then(response => response.blob()) |
769
|
|
|
.then(blob => { |
770
|
|
|
var link = window.document.createElement("a"); |
771
|
|
|
link.href = window.URL.createObjectURL(blob, { type: mimeType }); |
772
|
|
|
link.download = fileName; |
773
|
|
|
document.body.appendChild(link); |
774
|
|
|
link.click(); |
775
|
|
|
document.body.removeChild(link); |
776
|
|
|
}); |
777
|
|
|
}; |
778
|
|
|
|
779
|
|
|
|
780
|
|
|
|
781
|
|
|
return ( |
782
|
|
|
<Fragment> |
783
|
|
|
<div> |
784
|
|
|
<Breadcrumb> |
785
|
|
|
<BreadcrumbItem>{t('Fault Detection & Diagnostics')}</BreadcrumbItem><BreadcrumbItem active>{t('Equipment Faults Data')}</BreadcrumbItem> |
786
|
|
|
</Breadcrumb> |
787
|
|
|
</div> |
788
|
|
|
<Card className="bg-light mb-3"> |
789
|
|
|
<CardBody className="p-3"> |
790
|
|
|
<Form onSubmit={handleSubmit}> |
791
|
|
|
<Row form> |
792
|
|
|
<Col xs="auto"> |
793
|
|
|
<FormGroup className="form-group"> |
794
|
|
|
<Label className={labelClasses} for="space"> |
795
|
|
|
{t('Space')} |
796
|
|
|
</Label> |
797
|
|
|
<br /> |
798
|
|
|
<Cascader options={cascaderOptions} |
799
|
|
|
onChange={onSpaceCascaderChange} |
800
|
|
|
changeOnSelect |
801
|
|
|
expandTrigger="hover"> |
802
|
|
|
<Input value={selectedSpaceName || ''} readOnly /> |
803
|
|
|
</Cascader> |
804
|
|
|
</FormGroup> |
805
|
|
|
</Col> |
806
|
|
|
<Col xs="auto"> |
807
|
|
|
<FormGroup> |
808
|
|
|
<Label className={labelClasses} for="equipmentSelect"> |
809
|
|
|
{t('Equipment')} |
810
|
|
|
</Label> |
811
|
|
|
<CustomInput type="select" id="equipmentSelect" name="equipmentSelect" onChange={({ target }) => setSelectedEquipment(target.value)} |
812
|
|
|
> |
813
|
|
|
{equipmentList.map((equipment, index) => ( |
814
|
|
|
<option value={equipment.value} key={equipment.value}> |
815
|
|
|
{equipment.label} |
816
|
|
|
</option> |
817
|
|
|
))} |
818
|
|
|
</CustomInput> |
819
|
|
|
</FormGroup> |
820
|
|
|
</Col> |
821
|
|
|
<Col xs="auto"> |
822
|
|
|
<FormGroup className="form-group"> |
823
|
|
|
<Label className={labelClasses} for="reportingPeriodBeginsDatetime"> |
824
|
|
|
{t('Reporting Period Begins')} |
825
|
|
|
</Label> |
826
|
|
|
<Datetime id='reportingPeriodBeginsDatetime' |
827
|
|
|
value={reportingPeriodBeginsDatetime} |
828
|
|
|
onChange={onReportingPeriodBeginsDatetimeChange} |
829
|
|
|
isValidDate={getValidReportingPeriodBeginsDatetimes} |
830
|
|
|
closeOnSelect={true} /> |
831
|
|
|
</FormGroup> |
832
|
|
|
</Col> |
833
|
|
|
<Col xs="auto"> |
834
|
|
|
<FormGroup className="form-group"> |
835
|
|
|
<Label className={labelClasses} for="reportingPeriodEndsDatetime"> |
836
|
|
|
{t('Reporting Period Ends')} |
837
|
|
|
</Label> |
838
|
|
|
<Datetime id='reportingPeriodEndsDatetime' |
839
|
|
|
value={reportingPeriodEndsDatetime} |
840
|
|
|
onChange={onReportingPeriodEndsDatetimeChange} |
841
|
|
|
isValidDate={getValidReportingPeriodEndsDatetimes} |
842
|
|
|
closeOnSelect={true} /> |
843
|
|
|
</FormGroup> |
844
|
|
|
</Col> |
845
|
|
|
<Col xs="auto"> |
846
|
|
|
<FormGroup> |
847
|
|
|
<br></br> |
848
|
|
|
<ButtonGroup id="submit"> |
849
|
|
|
<Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button> |
850
|
|
|
</ButtonGroup> |
851
|
|
|
</FormGroup> |
852
|
|
|
</Col> |
853
|
|
|
<Col xs="auto"> |
854
|
|
|
<FormGroup> |
855
|
|
|
<br></br> |
856
|
|
|
<Spinner color="primary" hidden={spinnerHidden} /> |
857
|
|
|
</FormGroup> |
858
|
|
|
</Col> |
859
|
|
|
<Col xs="auto"> |
860
|
|
|
<br></br> |
861
|
|
|
<ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default" |
862
|
|
|
hidden={exportButtonHidden} |
863
|
|
|
onClick={handleExport} > |
864
|
|
|
{t('Export')} |
865
|
|
|
</ButtonIcon> |
866
|
|
|
</Col> |
867
|
|
|
</Row> |
868
|
|
|
</Form> |
869
|
|
|
</CardBody> |
870
|
|
|
</Card> |
871
|
|
|
<Card className="mb-3"> |
872
|
|
|
<FalconCardHeader title={t('Fault List')} light={false}> |
873
|
|
|
{isSelected ? ( |
874
|
|
|
<InputGroup size="sm" className="input-group input-group-sm"> |
875
|
|
|
<CustomInput type="select" id="bulk-select"> |
876
|
|
|
<option>Bulk actions</option> |
877
|
|
|
<option value="Refund">Refund</option> |
878
|
|
|
<option value="Delete">Delete</option> |
879
|
|
|
<option value="Archive">Archive</option> |
880
|
|
|
</CustomInput> |
881
|
|
|
<Button color="falcon-default" size="sm" className="ml-2"> |
882
|
|
|
Apply |
883
|
|
|
</Button> |
884
|
|
|
</InputGroup> |
885
|
|
|
) : ( |
886
|
|
|
<Fragment> |
887
|
|
|
|
888
|
|
|
</Fragment> |
889
|
|
|
)} |
890
|
|
|
</FalconCardHeader> |
891
|
|
|
<CardBody className="p-0"> |
892
|
|
|
<PaginationProvider pagination={paginationFactory(options)}> |
893
|
|
|
{({ paginationProps, paginationTableProps }) => { |
894
|
|
|
const lastIndex = paginationProps.page * paginationProps.sizePerPage; |
895
|
|
|
|
896
|
|
|
return ( |
897
|
|
|
<Fragment> |
898
|
|
|
<div className="table-responsive"> |
899
|
|
|
<BootstrapTable |
900
|
|
|
ref={table} |
901
|
|
|
bootstrap4 |
902
|
|
|
keyField="id" |
903
|
|
|
data={detailedDataTableData} |
904
|
|
|
columns={detailedDataTableColumns} |
905
|
|
|
selectRow={selectRow(onSelect)} |
906
|
|
|
bordered={false} |
907
|
|
|
classes="table-dashboard table-striped table-sm fs--1 border-bottom mb-0 table-dashboard-th-nowrap" |
908
|
|
|
rowClasses="btn-reveal-trigger" |
909
|
|
|
headerClasses="bg-200 text-900" |
910
|
|
|
{...paginationTableProps} |
911
|
|
|
/> |
912
|
|
|
</div> |
913
|
|
|
<Row noGutters className="px-1 py-3 flex-center"> |
914
|
|
|
<Col xs="auto"> |
915
|
|
|
<Button |
916
|
|
|
color="falcon-default" |
917
|
|
|
size="sm" |
918
|
|
|
onClick={handlePrevPage(paginationProps)} |
919
|
|
|
disabled={paginationProps.page === 1} |
920
|
|
|
> |
921
|
|
|
<FontAwesomeIcon icon="chevron-left" /> |
922
|
|
|
</Button> |
923
|
|
|
{getPaginationArray(paginationProps.totalSize, paginationProps.sizePerPage).map(pageNo => ( |
924
|
|
|
<Button |
925
|
|
|
color={paginationProps.page === pageNo ? 'falcon-primary' : 'falcon-default'} |
926
|
|
|
size="sm" |
927
|
|
|
className="ml-2" |
928
|
|
|
onClick={() => paginationProps.onPageChange(pageNo)} |
929
|
|
|
key={pageNo} |
930
|
|
|
> |
931
|
|
|
{pageNo} |
932
|
|
|
</Button> |
933
|
|
|
))} |
934
|
|
|
<Button |
935
|
|
|
color="falcon-default" |
936
|
|
|
size="sm" |
937
|
|
|
className="ml-2" |
938
|
|
|
onClick={handleNextPage(paginationProps)} |
939
|
|
|
disabled={lastIndex >= paginationProps.totalSize} |
940
|
|
|
> |
941
|
|
|
<FontAwesomeIcon icon="chevron-right" /> |
942
|
|
|
</Button> |
943
|
|
|
</Col> |
944
|
|
|
</Row> |
945
|
|
|
</Fragment> |
946
|
|
|
); |
947
|
|
|
}} |
948
|
|
|
</PaginationProvider> |
949
|
|
|
</CardBody> |
950
|
|
|
</Card> |
951
|
|
|
|
952
|
|
|
</Fragment> |
953
|
|
|
); |
954
|
|
|
}; |
955
|
|
|
|
956
|
|
|
export default withTranslation()(withRedirect(EquipmentFault)); |
957
|
|
|
|