@@ -15,11 +15,12 @@ import {
1515 Icon ,
1616} from '@chakra-ui/react' ;
1717import { FaCheck , FaXmark , FaSistrix , FaArrowsRotate , FaBars , FaAngleRight , FaAngleLeft } from "react-icons/fa6" ;
18+ import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants" ;
1819
1920import NavBarAdmin from "../common/NavBarAdmin" ;
2021import ServiceRequestAPIClient from "../../APIClients/ServiceRequestAPIClient" ;
2122
22- interface UserInfo {
23+ interface PlatformSignupRequestsUser {
2324 id : string ;
2425 email : string ;
2526 firstName : string ;
@@ -29,13 +30,27 @@ interface UserInfo {
2930}
3031
3132const 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+ } ) ;
3339
3440 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+
3550 const fetchData = async ( ) => {
3651 try {
3752 const response = await ServiceRequestAPIClient . getPlatformSignups ( ) ;
38- setUserInfo ( response ) ;
53+ setPlatformSignupRequestUsers ( response ) ;
3954 } catch ( error ) {
4055 console . error ( "Error fetching platform signups:" , error ) ;
4156 }
@@ -49,13 +64,13 @@ const PlatformSignupRequests = (): React.ReactElement => {
4964 const itemsPerPage = 999 ;
5065
5166 useEffect ( ( ) => {
52- setCheckedItems ( new Array ( userInfo . length ) . fill ( false ) ) ;
53- } , [ userInfo ] ) ;
67+ setCheckedItems ( new Array ( platformSignupRequestUsers . length ) . fill ( false ) ) ;
68+ } , [ platformSignupRequestUsers ] ) ;
5469
5570 const handleSelectAllChange = ( ) => {
5671 const newSelectAll = ! selectAll ;
5772 setSelectAll ( newSelectAll ) ;
58- setCheckedItems ( new Array ( userInfo . length ) . fill ( newSelectAll ) ) ;
73+ setCheckedItems ( new Array ( platformSignupRequestUsers . length ) . fill ( newSelectAll ) ) ;
5974 } ;
6075
6176 const handleCheckboxChange = ( index : number ) => {
@@ -99,14 +114,14 @@ const PlatformSignupRequests = (): React.ReactElement => {
99114 setCurrentPage ( page ) ;
100115 } ;
101116
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 ) ;
104119 const itemCountStart = ( currentPage - 1 ) * itemsPerPage + 1 ;
105- const itemCountEnd = Math . min ( currentPage * itemsPerPage , userInfo . length ) ;
120+ const itemCountEnd = Math . min ( currentPage * itemsPerPage , platformSignupRequestUsers . length ) ;
106121
107122 return (
108123 < Flex direction = "column" h = "100vh" ml = "20" mr = "20" >
109- < NavBarAdmin />
124+ < NavBarAdmin firstName = { userInfo . firstName } lastName = { userInfo . lastName } role = { userInfo . role } />
110125 < Text mt = "10" fontSize = '2xl' > Manage Accounts</ Text >
111126
112127 < TableContainer mt = '5' border = '1px' borderColor = 'gray.200' borderRadius = '20' >
@@ -157,7 +172,7 @@ const PlatformSignupRequests = (): React.ReactElement => {
157172 < Th >
158173 < Flex justifyContent = "space-between" alignItems = "center" >
159174 < Flex alignItems = "center" >
160- < Text > { itemCountStart } -{ itemCountEnd } of { userInfo . length } </ Text >
175+ < Text > { itemCountStart } -{ itemCountEnd } of { platformSignupRequestUsers . length } </ Text >
161176 < IconButton
162177 aria-label = "Previous Page"
163178 size = "sm"
0 commit comments