forked from b00tc4mp/isdi-parttime-202309
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
29 changes: 23 additions & 6 deletions
29
staff/belen-ivars/project/app/src/components/TopProfileImage.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters