@@ -8,6 +8,8 @@ const LeftContainer = ({ user, setCurrentBoard }: ContainerProps) => {
88 const [ creatingBoard , setCreatingBoard ] = useState < boolean > ( false ) ;
99 // creating state to store the list of board names
1010 const [ boardList , setBoardList ] = useState < BoardListItemState [ ] > ( [ ] ) ;
11+ //state for selected board
12+ const [ selectedBoard , setSelectedBoard ] = useState < string | null > ( null ) ;
1113 // make a request for all board naames, return an array containing strings of the board names
1214 useEffect ( ( ) => {
1315 const fetchBoardList = async ( ) => {
@@ -25,6 +27,7 @@ const LeftContainer = ({ user, setCurrentBoard }: ContainerProps) => {
2527 name : e . currentTarget . name ,
2628 id : e . currentTarget . id ,
2729 } ) ;
30+ setSelectedBoard ( e . currentTarget . id ) ;
2831 } ;
2932
3033 // function for creating a new board
@@ -34,28 +37,27 @@ const LeftContainer = ({ user, setCurrentBoard }: ContainerProps) => {
3437 } ;
3538
3639 // iterate through board names push buttons or components into array boardlist in state
37- const boardSelectors = [ ] ;
38- for ( let i = 0 ; i < boardList . length ; i ++ ) {
39- boardSelectors . push (
40- < button
41- className = 'board-selector'
42- onClick = { handleBoardSelect }
43- name = { boardList [ i ] . name }
44- id = { boardList [ i ] . id }
45- key = { i }
46- >
47- { boardList [ i ] . name }
48- </ button >
49- ) ;
50- }
40+ const boardSelectors = boardList . map ( ( board , index ) => (
41+ < button
42+ className = { `board-selector ${
43+ selectedBoard === board . id ? 'selected' : ''
44+ } `}
45+ onClick = { handleBoardSelect }
46+ name = { board . name }
47+ id = { board . id }
48+ key = { index }
49+ >
50+ { board . name }
51+ </ button >
52+ ) ) ;
5153
5254 return (
5355 < div className = 'left-container' >
5456 < h1 className = 'heading' > Hello, { user . name } </ h1 >
57+ < button className = 'new-board-btn' onClick = { handleCreateBoard } >
58+ Create New Board +
59+ </ button >
5560 < div className = 'boards-info' >
56- < button className = 'new-board-btn' onClick = { handleCreateBoard } >
57- Create New Board +
58- </ button >
5961 < div className = 'board-selectors' > { boardSelectors } </ div >
6062 </ div >
6163 { creatingBoard ? (
@@ -66,7 +68,7 @@ const LeftContainer = ({ user, setCurrentBoard }: ContainerProps) => {
6668 />
6769 ) : null }
6870 < footer >
69- < button className = 'settings-btn' > Settings </ button >
71+ < button className = 'setting-button' > Setting </ button >
7072 </ footer >
7173 </ div >
7274 ) ;
0 commit comments