@@ -15,11 +15,12 @@ import {
15
15
Icon ,
16
16
} from '@chakra-ui/react' ;
17
17
import { FaCheck , FaXmark , FaSistrix , FaArrowsRotate , FaBars , FaAngleRight , FaAngleLeft } from "react-icons/fa6" ;
18
+ import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants" ;
18
19
19
20
import NavBarAdmin from "../common/NavBarAdmin" ;
20
21
import ServiceRequestAPIClient from "../../APIClients/ServiceRequestAPIClient" ;
21
22
22
- interface UserInfo {
23
+ interface PlatformSignupRequestsUser {
23
24
id : string ;
24
25
email : string ;
25
26
firstName : string ;
@@ -29,13 +30,27 @@ interface UserInfo {
29
30
}
30
31
31
32
const PlatformSignupRequests = ( ) : React . ReactElement => {
32
- const [ userInfo , setUserInfo ] = useState < UserInfo [ ] > ( [ ] ) ;
33
+ const [ platformSignupRequestUsers , setPlatformSignupRequestUsers ] = useState < PlatformSignupRequestsUser [ ] > ( [ ] ) ;
34
+ const [ userInfo , setUserInfo ] = useState < any > ( {
35
+ firstName : "" ,
36
+ lastName : "" ,
37
+ role : "" ,
38
+ } ) ;
33
39
34
40
useEffect ( ( ) => {
41
+ const userData = localStorage . getItem ( AUTHENTICATED_USER_KEY ) ;
42
+
43
+ if ( userData ) {
44
+ const parsedUserData = JSON . parse ( userData ) ;
45
+ console . log ( parsedUserData ) ; // Remove this later
46
+
47
+ setUserInfo ( parsedUserData ) ;
48
+ }
49
+
35
50
const fetchData = async ( ) => {
36
51
try {
37
52
const response = await ServiceRequestAPIClient . getPlatformSignups ( ) ;
38
- setUserInfo ( response ) ;
53
+ setPlatformSignupRequestUsers ( response ) ;
39
54
} catch ( error ) {
40
55
console . error ( "Error fetching platform signups:" , error ) ;
41
56
}
@@ -49,13 +64,13 @@ const PlatformSignupRequests = (): React.ReactElement => {
49
64
const itemsPerPage = 999 ;
50
65
51
66
useEffect ( ( ) => {
52
- setCheckedItems ( new Array ( userInfo . length ) . fill ( false ) ) ;
53
- } , [ userInfo ] ) ;
67
+ setCheckedItems ( new Array ( platformSignupRequestUsers . length ) . fill ( false ) ) ;
68
+ } , [ platformSignupRequestUsers ] ) ;
54
69
55
70
const handleSelectAllChange = ( ) => {
56
71
const newSelectAll = ! selectAll ;
57
72
setSelectAll ( newSelectAll ) ;
58
- setCheckedItems ( new Array ( userInfo . length ) . fill ( newSelectAll ) ) ;
73
+ setCheckedItems ( new Array ( platformSignupRequestUsers . length ) . fill ( newSelectAll ) ) ;
59
74
} ;
60
75
61
76
const handleCheckboxChange = ( index : number ) => {
@@ -99,14 +114,14 @@ const PlatformSignupRequests = (): React.ReactElement => {
99
114
setCurrentPage ( page ) ;
100
115
} ;
101
116
102
- const totalPages = Math . ceil ( userInfo . length / itemsPerPage ) ;
103
- const currentItems = userInfo . slice ( ( currentPage - 1 ) * itemsPerPage , currentPage * itemsPerPage ) ;
117
+ const totalPages = Math . ceil ( platformSignupRequestUsers . length / itemsPerPage ) ;
118
+ const currentItems = platformSignupRequestUsers . slice ( ( currentPage - 1 ) * itemsPerPage , currentPage * itemsPerPage ) ;
104
119
const itemCountStart = ( currentPage - 1 ) * itemsPerPage + 1 ;
105
- const itemCountEnd = Math . min ( currentPage * itemsPerPage , userInfo . length ) ;
120
+ const itemCountEnd = Math . min ( currentPage * itemsPerPage , platformSignupRequestUsers . length ) ;
106
121
107
122
return (
108
123
< Flex direction = "column" h = "100vh" ml = "20" mr = "20" >
109
- < NavBarAdmin />
124
+ < NavBarAdmin firstName = { userInfo . firstName } lastName = { userInfo . lastName } role = { userInfo . role } />
110
125
< Text mt = "10" fontSize = '2xl' > Manage Accounts</ Text >
111
126
112
127
< TableContainer mt = '5' border = '1px' borderColor = 'gray.200' borderRadius = '20' >
@@ -157,7 +172,7 @@ const PlatformSignupRequests = (): React.ReactElement => {
157
172
< Th >
158
173
< Flex justifyContent = "space-between" alignItems = "center" >
159
174
< Flex alignItems = "center" >
160
- < Text > { itemCountStart } -{ itemCountEnd } of { userInfo . length } </ Text >
175
+ < Text > { itemCountStart } -{ itemCountEnd } of { platformSignupRequestUsers . length } </ Text >
161
176
< IconButton
162
177
aria-label = "Previous Page"
163
178
size = "sm"
0 commit comments