11"use client" ;
22
3- import { ReactNode , useCallback , useRef , useState } from "react" ;
43import Image from "next/image" ;
54import Link from "next/link" ;
65import { hardhat } from "viem/chains" ;
76import { useAccount } from "wagmi" ;
8- import { Bars3Icon } from "@heroicons/react/24/outline" ;
97import { FaucetButton , RainbowKitCustomConnectButton } from "~~/components/scaffold-eth" ;
10- import { useOutsideClick } from "~~/hooks/scaffold-eth" ;
118import { useFetchUserData } from "~~/hooks/useFetchUserData" ;
129import scaffoldConfig from "~~/scaffold.config" ;
1310
1411/**
1512 * Site header
1613 */
17- export const HeaderClient = ( { menuLinks } : { menuLinks : ReactNode } ) => {
14+ export const HeaderClient = ( ) => {
1815 const currentChain = scaffoldConfig . targetNetworks [ 0 ] ;
1916
20- const [ isDrawerOpen , setIsDrawerOpen ] = useState ( false ) ;
21- const burgerMenuRef = useRef < HTMLDivElement > ( null ) ;
22- useOutsideClick (
23- burgerMenuRef ,
24- useCallback ( ( ) => setIsDrawerOpen ( false ) , [ ] ) ,
25- ) ;
26-
2717 const { address : connectedAddress } = useAccount ( ) ;
2818
2919 const { userData } = useFetchUserData ( { address : connectedAddress } ) ;
3020
3121 const flagsCaptured = userData ?. challenges ?. items . length || 0 ;
3222
3323 return (
34- < div className = "py-4 px-4 flex justify-between lg:grid lg:grid-cols-3 items-center z-20 relative" >
35- < div className = "" >
36- < div className = "lg:hidden dropdown" ref = { burgerMenuRef } >
37- < label
38- tabIndex = { 0 }
39- className = "btn btn-ghost px-3"
40- onClick = { ( ) => {
41- setIsDrawerOpen ( prevIsOpenState => ! prevIsOpenState ) ;
42- } }
43- >
44- < Bars3Icon className = "w-6 h-6" />
45- </ label >
46- { isDrawerOpen && (
47- < ul
48- tabIndex = { 0 }
49- className = "menu menu-compact gap-1 dropdown-content mt-3 p-2 bg-base-100 rounded-md w-52 border border-secondary"
50- onClick = { ( ) => {
51- setIsDrawerOpen ( false ) ;
52- } }
24+ < >
25+ < div className = "py-4 px-4 flex justify-between lg:grid lg:grid-cols-3 items-center z-20 relative" >
26+ < div >
27+ < div className = "text-white text-sm font-pressStart" >
28+ < Link className = "flex items-center gap-4" href = "/" >
29+ < Image alt = "BuidlGuidl" className = "w-8" src = "/fortress-flag.svg" width = { 112 } height = { 128 } />
30+ < span className = "mt-2 hidden lg:inline" > BuidlGuidl CTF</ span >
31+ </ Link >
32+ </ div >
33+ </ div >
34+ < div className = "hidden lg:block text-center" >
35+ { connectedAddress && (
36+ < Link
37+ href = { `/profile/${ connectedAddress } ` }
38+ className = "text-white text-sm font-pressStart link-hover hover:text-primary"
5339 >
54- { menuLinks }
55- </ ul >
40+ My Flags: { flagsCaptured } /12
41+ </ Link >
5642 ) }
5743 </ div >
58- < div className = "hidden lg:block text-white text-sm font-pressStart " >
59- < Link className = "flex items-center gap-4" href = "/ ">
60- < Image alt = "BuidlGuidl" className = "w-8" src = "/fortress-flag.svg" width = { 112 } height = { 128 } />
61- < span className = "mt-2" > BuidlGuidl CTF </ span >
62- </ Link >
44+ < div className = "flex " >
45+ < div className = "ml-auto flex " >
46+ < RainbowKitCustomConnectButton />
47+ { ( currentChain ?. id as number ) === hardhat . id && < FaucetButton /> }
48+ </ div >
6349 </ div >
6450 </ div >
65- < div className = "hidden lg:block text-center" >
51+ < div className = "text-center lg:hidden " >
6652 { connectedAddress && (
6753 < Link
6854 href = { `/profile/${ connectedAddress } ` }
@@ -72,12 +58,6 @@ export const HeaderClient = ({ menuLinks }: { menuLinks: ReactNode }) => {
7258 </ Link >
7359 ) }
7460 </ div >
75- < div className = "flex" >
76- < div className = "ml-auto flex" >
77- < RainbowKitCustomConnectButton />
78- { ( currentChain ?. id as number ) === hardhat . id && < FaucetButton /> }
79- </ div >
80- </ div >
81- </ div >
61+ </ >
8262 ) ;
8363} ;
0 commit comments