@@ -5,7 +5,7 @@ import { sinfoLogo } from "@/assets/images";
5
5
import { useSession } from "next-auth/react" ;
6
6
import { usePathname , useRouter } from "next/navigation" ;
7
7
import { ArrowLeft , Menu , RefreshCcw } from "lucide-react" ;
8
- import { useState } from "react" ;
8
+ import { useMemo , useState } from "react" ;
9
9
import Sidebar from "./Sidebar" ;
10
10
11
11
export default function Toolbar ( ) {
@@ -15,47 +15,53 @@ export default function Toolbar() {
15
15
16
16
const [ isExpanded , setIsExpanded ] = useState ( false ) ;
17
17
18
- const showMenu : boolean = currPath === "/home" || currPath === "/profile" ;
18
+ const showMenu = useMemo (
19
+ ( ) => currPath === "/home" || currPath === "/profile" ,
20
+ [ currPath ] ,
21
+ ) ;
19
22
20
23
return (
21
24
< >
22
25
< Sidebar show = { isExpanded } onClose = { ( ) => setIsExpanded ( false ) } />
23
- < div className = "bg-sinfo-primary container m-auto p-4 pb-2 flex flex-col gap-4" >
24
- < nav className = "flex flex-row items-center" >
25
- < div className = "w-1/6 flex justify-start items-center" >
26
- { showMenu ? (
27
- < Menu
28
- size = { 32 }
29
- className = "cursor-pointer"
30
- onClick = { ( ) => setIsExpanded ( true ) }
31
- />
32
- ) : (
33
- < ArrowLeft
34
- size = { 32 }
35
- className = "cursor-pointer"
36
- onClick = { ( ) => {
37
- router . back ( ) ;
38
- } }
26
+ < div className = "bg-sinfo-primary" >
27
+ < div className = "container m-auto p-4 pb-2 flex flex-col gap-4" >
28
+ < nav className = "flex flex-row items-center" >
29
+ < div className = "w-1/6 flex justify-start items-center" >
30
+ { showMenu ? (
31
+ < button onClick = { ( ) => setIsExpanded ( true ) } >
32
+ < Menu size = { 32 } className = "cursor-pointer" />
33
+ </ button >
34
+ ) : (
35
+ < button
36
+ onClick = { ( ) => {
37
+ router . back ( ) ;
38
+ } }
39
+ >
40
+ < ArrowLeft size = { 32 } className = "cursor-pointer" />
41
+ </ button >
42
+ ) }
43
+ </ div >
44
+ < div className = "flex-1" >
45
+ < Image
46
+ className = "w-32 mx-auto"
47
+ src = { sinfoLogo }
48
+ alt = "SINFO logo"
49
+ quality = { 100 }
39
50
/>
40
- ) }
41
- </ div >
42
- < div className = "flex-1" >
43
- < Image
44
- className = "w-32 mx-auto"
45
- src = { sinfoLogo }
46
- alt = "SINFO logo"
47
- quality = { 100 }
48
- />
49
- </ div >
50
- < div className = "w-1/6 flex justify-end items-center" >
51
- < RefreshCcw size = { 28 } onClick = { ( ) => window . location . reload ( ) } />
52
- </ div >
53
- </ nav >
54
- { currPath === "/home" && session ?. user ?. name && (
55
- < div className = "text-lg" >
56
- Welcome, < span className = "font-semibold" > { session . user . name } !</ span >
57
- </ div >
58
- ) }
51
+ </ div >
52
+ < div className = "w-1/6 flex justify-end items-center" >
53
+ < button onClick = { ( ) => window . location . reload ( ) } >
54
+ < RefreshCcw size = { 28 } />
55
+ </ button >
56
+ </ div >
57
+ </ nav >
58
+ { currPath === "/home" && session ?. user ?. name && (
59
+ < div className = "text-lg" >
60
+ Welcome,{ " " }
61
+ < span className = "font-semibold" > { session . user . name } !</ span >
62
+ </ div >
63
+ ) }
64
+ </ div >
59
65
</ div >
60
66
</ >
61
67
) ;
0 commit comments