1- import React , { useContext , useEffect , useState , useRef } from 'react' ;
1+ import React , { useContext , useEffect , useState , useRef , forwardRef } from 'react' ;
22
33// MATERIAL UI METHODS
44import {
55 IconButton ,
6- Modal ,
6+ Modal ,
77 Card ,
88 CardHeader ,
99 CardContent ,
10- Button ,
11- Typography } from '@material-ui/core' ;
10+ Button ,
11+ Typography
12+ } from '@material-ui/core' ;
1213import { Theme , makeStyles } from '@material-ui/core/styles' ;
1314import { BaseCSSProperties } from '@material-ui/core/styles/withStyles' ;
1415
1516// MATERIAL UI ICONS
1617import MoreVertIcon from '@material-ui/icons/MoreVert' ;
1718import AddCircleOutlineTwoToneIcon from '@material-ui/icons/AddCircleOutlineTwoTone' ;
1819import DeleteForeverOutlinedIcon from '@material-ui/icons/DeleteForeverOutlined' ;
19- import ListIcon from '@material-ui/icons/List' ;
2020import HighlightOffIcon from '@material-ui/icons/HighlightOff' ;
21+ import ListIcon from '@material-ui/icons/List' ;
2122import SearchIcon from '@material-ui/icons/Search' ;
2223import DashboardIcon from '@material-ui/icons/Dashboard' ;
2324import NotificationsIcon from '@material-ui/icons/Notifications' ;
@@ -39,14 +40,13 @@ interface StyleProps {
3940} ;
4041type ClickEvent = React . MouseEvent < HTMLElement > ;
4142
42- const Occupied : React . FC = ( ) => {
43+ const Occupied : React . FC = React . memo ( function Occupied ( props ) {
4344 const { applications, getApplications, deleteApp } = useContext ( DashboardContext ) ;
4445 const [ open , setOpen ] = useState < boolean > ( false ) ;
4546 const [ addOpen , setAddOpen ] = useState < boolean > ( false ) ;
46-
4747 const [ index , setIndex ] = useState < number > ( 0 ) ;
4848 const [ app , setApp ] = useState < string > ( '' ) ;
49-
49+ const [ searchTerm , setSearchTerm ] = useState < string > ( 'Search...' ) ;
5050 // Dynamic refs
5151 const delRef = useRef < any > ( [ ] ) ;
5252
@@ -68,8 +68,8 @@ const Occupied: React.FC = () => {
6868 setOpen ( true ) ;
6969 }
7070 } ;
71+
7172 const useStyles = makeStyles < Theme , StyleProps > ( theme => ( {
72- // card: "+" button only
7373 paper : {
7474 height : 280 ,
7575 width : 280 ,
@@ -81,7 +81,7 @@ const Occupied: React.FC = () => {
8181 border : '0' ,
8282 boxShadow : '0 6px 6px 0 rgba(153, 153, 153, 0.14), 0 6px 6px -2px rgba(153, 153, 153, 0.2), 0 6px 8px 0 rgba(153, 153, 153, 0.12)' ,
8383 '&:hover, &.Mui-focusVisible' : {
84- backgroundColor : `#ccd8e1 ` ,
84+ backgroundColor : `#b5d3e9 ` ,
8585 color : '#ffffff' ,
8686 } ,
8787 } ,
@@ -97,7 +97,7 @@ const Occupied: React.FC = () => {
9797 color : '#eeeeee' ,
9898 borderRadius : '0' ,
9999 backgroundColor : 'transparent' ,
100- '&:hover' : {
100+ '&:hover' : {
101101 backgroundColor : 'none'
102102 }
103103 } ,
@@ -111,10 +111,7 @@ const Occupied: React.FC = () => {
111111 const classes = useStyles ( { } as StyleProps ) ;
112112
113113 return (
114-
115114 < div className = "entireArea" >
116- < div className = "sidebarArea" >
117- </ div >
118115 < div className = "dashboardArea" >
119116 < header className = "mainHeader" >
120117 < section className = "header" id = "leftHeader" >
@@ -124,16 +121,16 @@ const Occupied: React.FC = () => {
124121 < section className = "header" id = "rightHeader" >
125122 < form className = "form" >
126123 < label className = "inputContainer" >
127- < input className = "form" id = "textInput" value = { `Search` } type = "text" name = "search" />
124+ < input className = "form" id = "textInput" placeholder = { searchTerm } onChange = { e => setSearchTerm ( e . target . value ) } type = "text" name = "search" />
128125 < hr />
129126 </ label >
130127 < button className = "form" id = "submitBtn" type = "submit" >
131- < SearchIcon className = "icon" id = "searchIcon" />
128+ < SearchIcon className = "icon" id = "searchIcon" />
132129 </ button >
133130 </ form >
134- < DashboardIcon className = "sideIcon" id = "dashboardIcon" />
135- < NotificationsIcon className = "sideIcon" id = "notificationsIcon" />
136- < PersonIcon className = "sideIcon" id = "personIcon" />
131+ < DashboardIcon className = "sideIcon" id = "dashboardIcon" />
132+ < NotificationsIcon className = "sideIcon" id = "notificationsIcon" />
133+ < PersonIcon className = "sideIcon" id = "personIcon" />
137134 </ section >
138135 </ header >
139136
@@ -144,7 +141,7 @@ const Occupied: React.FC = () => {
144141 </ Button >
145142 </ div >
146143 { applications . map ( ( app : string [ ] , i : number | any | string | undefined ) => (
147- < div className = "card" id = { `card-${ i } ` } >
144+ < div className = "card" key = { `card- ${ i } ` } id = { `card-${ i } ` } >
148145 < Card
149146 key = { `card-${ i } ` }
150147 className = { classes . paper }
@@ -159,7 +156,7 @@ const Occupied: React.FC = () => {
159156 aria-label = "Delete"
160157 onClick = { event => confirmDelete ( event , app [ 0 ] , i ) }
161158 >
162- < HighlightOffIcon className = { classes . btnStyle } id = ' deleteIcon' />
159+ < HighlightOffIcon className = { classes . btnStyle } id = " deleteIcon" />
163160 </ IconButton >
164161 }
165162 > </ CardHeader >
@@ -173,12 +170,12 @@ const Occupied: React.FC = () => {
173170 < AddModal setOpen = { setAddOpen } />
174171 </ Modal >
175172 < Modal open = { open } onClose = { ( ) => setOpen ( false ) } >
176- < ServicesModal i = { index } app = { app } />
173+ < ServicesModal key = { `key- ${ index } ` } i = { index } app = { app } />
177174 </ Modal >
178175 </ div >
179176 </ div >
180177 </ div >
181178 ) ;
182- } ;
179+ } ) ;
183180
184181export default Occupied ;
0 commit comments