Skip to content

Commit

Permalink
create menu profile b00tc4mp#407
Browse files Browse the repository at this point in the history
  • Loading branch information
berlem committed Apr 21, 2024
1 parent f63e373 commit 1b277f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
29 changes: 23 additions & 6 deletions staff/belen-ivars/project/app/src/components/TopProfileImage.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import Gravatar from 'react-gravatar'
import { Link } from '../library'
import { Button } from '../library'
import { useNavigate } from 'react-router-dom'
import { useState } from 'react'
import FavsButton from './FavsButton'
import LogoutButton from './LogoutButton'

export default function TopProfileImage({ name, email }) {

const [view, setView] = useState(null)
const [isOpen, setIsOpen] = useState(false)
const navigate = useNavigate()


function handleProfileClick(event) {
event.preventDefault()
const navigate = useNavigate()
navigate('/profile')

setIsOpen(!isOpen)

if (isOpen) {
setIsOpen(false)
}
}

return <Link className="link-profile" onClick={handleProfileClick}>
return <Button className="link-profile" onClick={handleProfileClick}>
<Gravatar email={email} /> {name}
</Link>

{isOpen && (
<div>
<FavsButton />
<LogoutButton />
</div>
)}
</Button>
}

5 changes: 2 additions & 3 deletions staff/belen-ivars/project/app/src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { Routes, Route, useNavigate, useLocation } from 'react-router-dom'
import logic from "../logic"
import { Button, Link, Container } from "../library"
import Profile from './Profile'
import FullHeader from "../components/FullHeader"
import Context from "../Context"
import NewRecipe from "../components/NewRecipeForm"
import { Recipes } from "../components"
import { Recipes, TopProfileImage } from "../components"
import Search from "../components/Search"


Expand Down Expand Up @@ -86,7 +85,7 @@ function Home(props) {
<header className="header">
<h1><Link className="link-header" onClick={handleHomeClick}>Basic Pantry</Link></h1>

<FullHeader email={email} name={name} />
<TopProfileImage email={email} name={name} />

</header>

Expand Down

0 comments on commit 1b277f6

Please sign in to comment.