1
- import React , { useState } from 'react' ;
1
+ import { useState } from 'react' ;
2
2
3
- import " ./PermissionChangeLogTable.css" ;
4
- import { formatDate , formatted_AM_PM_Time } from 'utils/formatDate' ;
3
+ import ' ./PermissionChangeLogTable.css' ;
4
+ import { formatDate , formattedAmPmTime } from 'utils/formatDate' ;
5
5
6
-
7
- const PermissionChangeLogTable = ( { changeLogs, darkMode } ) => {
6
+ function PermissionChangeLogTable ( { changeLogs, darkMode } ) {
8
7
const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
9
8
const itemsPerPage = 20 ;
10
9
const indexOfLastItem = currentPage * itemsPerPage ;
@@ -18,10 +17,15 @@ const PermissionChangeLogTable = ({ changeLogs, darkMode }) => {
18
17
19
18
return (
20
19
< >
21
- < table className = 'permission-change-log-table' style = { { borderCollapse : 'collapse' , width : '98%' , margin : "0 auto" } } >
20
+ < table
21
+ className = "permission-change-log-table"
22
+ style = { { borderCollapse : 'collapse' , width : '98%' , margin : '0 auto' } }
23
+ >
22
24
< thead >
23
25
< tr className = { darkMode ? 'table-row-dark' : 'table-row' } >
24
- < th className = { `permission-change-log-table--header${ addDark } ` } > Log Date and Time (PST)</ th >
26
+ < th className = { `permission-change-log-table--header${ addDark } ` } >
27
+ Log Date and Time (PST)
28
+ </ th >
25
29
< th className = { `permission-change-log-table--header${ addDark } ` } > Role Name</ th >
26
30
< th className = { `permission-change-log-table--header${ addDark } ` } > Permissions</ th >
27
31
< th className = { `permission-change-log-table--header${ addDark } ` } > Permissions Added</ th >
@@ -34,32 +38,47 @@ const PermissionChangeLogTable = ({ changeLogs, darkMode }) => {
34
38
{ currentItems . map ( log => (
35
39
< tr key = { log . _id } >
36
40
{ /* ... (same as before) */ }
37
- < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { `${ formatDate ( log . logDateTime ) } ${ formatted_AM_PM_Time ( log . logDateTime ) } ` } </ td >
41
+ < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { `${ formatDate (
42
+ log . logDateTime ,
43
+ ) } ${ formattedAmPmTime ( log . logDateTime ) } `} </ td >
38
44
< td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { log . roleName } </ td >
39
- < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { log . permissions . join ( ', ' ) } </ td >
40
- < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { log . permissionsAdded . join ( ', ' ) } </ td >
41
- < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { log . permissionsRemoved . join ( ', ' ) } </ td >
42
- < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { log . requestorRole } </ td >
43
- < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } > { log . requestorEmail } </ td >
45
+ < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } >
46
+ { log . permissions . join ( ', ' ) }
47
+ </ td >
48
+ < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } >
49
+ { log . permissionsAdded . join ( ', ' ) }
50
+ </ td >
51
+ < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } >
52
+ { log . permissionsRemoved . join ( ', ' ) }
53
+ </ td >
54
+ < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } >
55
+ { log . requestorRole }
56
+ </ td >
57
+ < td className = { `permission-change-log-table--cell ${ bgYinmnBlue } ` } >
58
+ { log . requestorEmail }
59
+ </ td >
44
60
</ tr >
45
61
) ) }
46
62
</ tbody >
47
63
</ table >
48
- < div className = "pagination" style = { { width : '98%' , margin : " 5px auto" } } >
64
+ < div className = "pagination" style = { { width : '98%' , margin : ' 5px auto' } } >
49
65
{ Array . from ( { length : Math . ceil ( changeLogs . length / itemsPerPage ) } ) . map ( ( _ , index ) => (
50
- < button
51
- key = { index }
52
- onClick = { ( ) => paginate ( index + 1 ) }
53
- className = 'permission-change-log-table--button'
66
+ < button
67
+ // eslint-disable-next-line react/no-array-index-key
68
+ key = { index }
69
+ type = "button"
70
+ onClick = { ( ) => paginate ( index + 1 ) }
71
+ className = "permission-change-log-table--button"
54
72
style = { {
55
73
backgroundColor : index + 1 === currentPage ? '#103a8d' : '#1d62f0' ,
56
- } } >
74
+ } }
75
+ >
57
76
{ index + 1 }
58
77
</ button >
59
78
) ) }
60
79
</ div >
61
80
</ >
62
81
) ;
63
- } ;
82
+ }
64
83
65
84
export default PermissionChangeLogTable ;
0 commit comments