1
1
import { useEffect , useState } from "react"
2
- import { Container , Navbar } from "react-bootstrap"
2
+ import { Container , Navbar , Nav } from "react-bootstrap"
3
3
import Image from "react-bootstrap/Image"
4
- import { Role , useAuth } from "../auth"
4
+ import { Role , signOutAndRedirectToHome , useAuth } from "../auth"
5
5
import { NavLink } from "../Navlink"
6
6
import styles from "./ProfileLink.module.css"
7
7
@@ -25,6 +25,11 @@ const ProfileLink = ({
25
25
} ) => {
26
26
const { user } = useAuth ( )
27
27
const [ search , setSearch ] = useState ( "" )
28
+ const [ sticky , setSticky ] = useState ( false )
29
+ const [ isExpanded , setIsExpanded ] = useState ( false )
30
+
31
+ const toggleNav = ( ) => setIsExpanded ( ! isExpanded )
32
+ const closeNav = ( ) => setIsExpanded ( false )
28
33
29
34
useEffect ( ( ) => {
30
35
if ( user ?. uid ) {
@@ -33,22 +38,67 @@ const ProfileLink = ({
33
38
} , [ user ?. uid ] )
34
39
35
40
return (
36
- < Container className = { `py-0` } >
37
- < NavLink href = { "/profile" + search } className = "py-0" >
38
- < div style = { { display : "flex" , alignItems : "center" , padding : 0 } } >
39
- < Image
40
- className = { styles . profileLinkImage }
41
- src = "/profile-icon.svg"
42
- alt = "profile icon"
43
- />
44
- < Navbar expand = "lg" className = "p-0" >
45
- < Navbar . Collapse id = "topnav" >
46
- < Navbar . Brand > { greeting ( role , displayName ) } </ Navbar . Brand >
47
- </ Navbar . Collapse >
48
- </ Navbar >
49
- </ div >
50
- </ NavLink >
51
- </ Container >
41
+ < >
42
+ < Navbar
43
+ bg = "secondary"
44
+ variant = "dark"
45
+ sticky = { sticky ? "top" : undefined }
46
+ expand = { false }
47
+ expanded = { isExpanded }
48
+ className = "p-0" >
49
+ < Container className = { `py-0` } >
50
+ < div className = { styles . navbar_boxes_container } >
51
+ < Navbar . Brand className = "mx-2 p-0" onClick = { toggleNav } >
52
+ < Nav . Link className = "p-0" >
53
+ < Image
54
+ className = { styles . profileLinkImage }
55
+ src = "/profile-icon.svg"
56
+ alt = "profile icon" >
57
+ </ Image >
58
+ { greeting ( role , displayName ) }
59
+ </ Nav . Link >
60
+ </ Navbar . Brand >
61
+ </ div >
62
+ < Navbar . Collapse id = "topnav" >
63
+ < Nav className = "me-auto" >
64
+ < NavLink
65
+ className = { "navLink-primary" }
66
+ href = { "/profile" + search }
67
+ handleClick = { closeNav } >
68
+ View Profile
69
+ </ NavLink >
70
+ < NavLink
71
+ className = { "navLink-primary" }
72
+ href = "/editprofile"
73
+ handleClick = { closeNav } >
74
+ Edit Profile
75
+ </ NavLink >
76
+ < NavLink
77
+ className = { "navLink-primary" }
78
+ handleClick = { ( ) => {
79
+ closeNav ( )
80
+ void signOutAndRedirectToHome ( ) } } >
81
+ Sign Out
82
+ </ NavLink >
83
+ </ Nav >
84
+ </ Navbar . Collapse >
85
+ { /* <NavLink href={"/profile" + search} className="py-0">
86
+ <div style={{ display: "flex", alignItems: "center", padding: 0 }}>
87
+ <Image
88
+ className={styles.profileLinkImage}
89
+ src="/profile-icon.svg"
90
+ alt="profile icon"
91
+ />
92
+ <Navbar expand="lg" className="p-0">
93
+ <Navbar.Collapse id="topnav">
94
+ <Navbar.Brand>{greeting(role, displayName)}</Navbar.Brand>
95
+ </Navbar.Collapse>
96
+ </Navbar>
97
+ </div>
98
+ </NavLink> */ }
99
+ </ Container >
100
+ </ Navbar >
101
+ </ >
52
102
)
53
103
}
54
104
export default ProfileLink
0 commit comments