@@ -5,7 +5,7 @@ import { sinfoLogo } from "@/assets/images";
55import { useSession } from "next-auth/react" ;
66import { usePathname , useRouter } from "next/navigation" ;
77import { ArrowLeft , Menu , RefreshCcw } from "lucide-react" ;
8- import { useState } from "react" ;
8+ import { useMemo , useState } from "react" ;
99import Sidebar from "./Sidebar" ;
1010
1111export default function Toolbar ( ) {
@@ -15,47 +15,53 @@ export default function Toolbar() {
1515
1616 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
1717
18- const showMenu : boolean = currPath === "/home" || currPath === "/profile" ;
18+ const showMenu = useMemo (
19+ ( ) => currPath === "/home" || currPath === "/profile" ,
20+ [ currPath ] ,
21+ ) ;
1922
2023 return (
2124 < >
2225 < 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 }
3950 />
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 >
5965 </ div >
6066 </ >
6167 ) ;
0 commit comments