Passed
Push — master ( 1f92a8...ce137d )
by Guangyu
04:45 queued 10s
created

src/components/MyEMS/FDD/SpaceFault.js   A

Complexity

Total Complexity 9
Complexity/F 0

Size

Lines of Code 809
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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