diff --git a/nepalingo-web/src/components/UserAvatar.tsx b/nepalingo-web/src/components/UserAvatar.tsx index e7dda8d..8434ce2 100644 --- a/nepalingo-web/src/components/UserAvatar.tsx +++ b/nepalingo-web/src/components/UserAvatar.tsx @@ -1,17 +1,38 @@ -import React from "react"; +import React, { HTMLAttributes } from "react"; import { useAuth } from "@/hooks/Auth"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faPen } from "@fortawesome/free-solid-svg-icons"; -const UserAvatar: React.FC = () => { +interface UserAvatarProps extends HTMLAttributes { + showPenOnHover?: boolean; +} + +const UserAvatar: React.FC = ({ + onClick, + showPenOnHover = false, + ...props +}) => { const { user } = useAuth(); const username = user?.user_metadata?.username; const avatarUrl = `https://robohash.org/${username}.png?set=set4`; return ( - User Avatar +
+ User Avatar + {showPenOnHover && ( +
+ +
+ )} +
); }; diff --git a/nepalingo-web/src/components/header/UserProfile.tsx b/nepalingo-web/src/components/header/UserProfile.tsx index 546806a..83842f9 100644 --- a/nepalingo-web/src/components/header/UserProfile.tsx +++ b/nepalingo-web/src/components/header/UserProfile.tsx @@ -4,6 +4,7 @@ import { StreakContext } from "@/hooks/StreakContext"; import { getPhrase } from "@/components/header/StreakPhrase"; import { useAuth } from "@/hooks/Auth"; import fire from "@/assets/fire.svg"; +import { useNavigate } from "react-router-dom"; const UserProfile: React.FC = () => { const [isOpen, setIsOpen] = useState(false); @@ -11,6 +12,7 @@ const UserProfile: React.FC = () => { const { currentStreak, longestStreak } = useContext(StreakContext); const phrase = getPhrase(currentStreak); const dropdownRef = useRef(null); + const navigate = useNavigate(); const toggleMenu = () => { setIsOpen(!isOpen); @@ -25,6 +27,10 @@ const UserProfile: React.FC = () => { } }; + const handleAvatarClick = () => { + navigate("/edit-profile"); + }; + useEffect(() => { document.addEventListener("mousedown", handleClickOutside); return () => { @@ -47,7 +53,7 @@ const UserProfile: React.FC = () => {
- +
{user?.user_metadata?.username}