1- import { ContainerProps , BoardListItemState } from " ../types" ;
2- import { useEffect , useState } from " react" ;
3- import CreateBoardModal from " ../components/CreateBoardModal" ;
4- import " ../scss/leftContainer.scss" ;
1+ import { ContainerProps , BoardListItemState } from ' ../types' ;
2+ import { useEffect , useState } from ' react' ;
3+ import CreateBoardModal from ' ../components/CreateBoardModal' ;
4+ import ' ../scss/leftContainer.scss' ;
55
66const LeftContainer = ( { user, setCurrentBoard } : ContainerProps ) => {
77 // creating state to open board creating modal
88 const [ creatingBoard , setCreatingBoard ] = useState < boolean > ( false ) ;
99 // creating state to store the list of board names
1010 const [ boardList , setBoardList ] = useState < BoardListItemState [ ] > ( [ ] ) ;
1111 // make a request for all board naames, return an array containing strings of the board names
12- console . log ( user ) ;
1312 useEffect ( ( ) => {
1413 const fetchBoardList = async ( ) => {
1514 const reponse : Response = await fetch ( `/boards/${ user . id } ` ) ;
1615 const list = await reponse . json ( ) ;
1716 setBoardList ( list ) ;
18- console . log ( "boardList: " , boardList ) ;
1917 } ;
2018 fetchBoardList ( ) . catch ( console . error ) ;
2119 } , [ ] ) ;
2220
2321 // function for changing board when click selection button
2422 const handleBoardSelect = ( e : React . MouseEvent < HTMLButtonElement > ) => {
25- e . preventDefault ;
23+ e . preventDefault ( ) ;
2624 setCurrentBoard ( {
2725 name : e . currentTarget . name ,
2826 id : e . currentTarget . id ,
2927 } ) ;
3028 } ;
3129
3230 // function for creating a new board
33- const handleCreateBoard = ( e : React . MouseEvent < HTMLButtonElement > ) => {
34- e . preventDefault ;
31+ const handleCreateBoard = ( ) => {
3532 // create a pop up to create the new board
3633 setCreatingBoard ( true ) ;
3734 } ;
3835
3936 // iterate through board names push buttons or components into array boardlist in state
4037 const boardSelectors = [ ] ;
4138 for ( let i = 0 ; i < boardList . length ; i ++ ) {
42- console . log ( "boardList[i]: " , boardList [ i ] ) ;
4339 boardSelectors . push (
4440 < button
45- className = " board-selector"
41+ className = ' board-selector'
4642 onClick = { handleBoardSelect }
4743 name = { boardList [ i ] . name }
4844 id = { boardList [ i ] . id }
@@ -54,22 +50,24 @@ const LeftContainer = ({ user, setCurrentBoard }: ContainerProps) => {
5450 }
5551
5652 return (
57- < div className = " left-container" >
58- < div className = "boards-info" >
59- < h1 className = "heading" > { user . name } 's Boards </ h1 >
60- < button className = " new-board-btn" onClick = { handleCreateBoard } >
53+ < div className = ' left-container' >
54+ < h1 className = 'heading' > Hello, { user . name } </ h1 >
55+ < div className = 'boards-info' >
56+ < button className = ' new-board-btn' onClick = { handleCreateBoard } >
6157 Create New Board +
6258 </ button >
63- < div className = " board-selectors" > { boardSelectors } </ div >
59+ < div className = ' board-selectors' > { boardSelectors } </ div >
6460 </ div >
65- < button className = "settings-btn" > Settings</ button >
6661 { creatingBoard ? (
6762 < CreateBoardModal
6863 setCreatingBoard = { setCreatingBoard }
6964 setCurrentBoard = { setCurrentBoard }
7065 user = { user }
7166 />
7267 ) : null }
68+ < footer >
69+ < button className = 'settings-btn' > Settings</ button >
70+ </ footer >
7371 </ div >
7472 ) ;
7573} ;
0 commit comments