Skip to content

Commit

Permalink
Merge pull request #29 from FaithMosonik/main
Browse files Browse the repository at this point in the history
Add CustomAvatar component
  • Loading branch information
Javan-Odhiambo authored Jun 6, 2024
2 parents 8d89210 + 1a2ea26 commit 5171000
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/app/dashboard/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const ProfileHeader = () => {
return (
<Header
avatarUrl={profile?.profile_picture}
firstName={profile?.first_name}
lastName={profile?.last_name}
handleLogoutClick={handleLogout}
handleEditClick={() => {
router.push("/dashboard/my-profile/edit");
Expand Down
10 changes: 5 additions & 5 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ import {
import { Input } from "@/components/ui/input"
import SidebarNav from '@/components/sidebarNav'
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import CustomAvatar from './ui/custom-avatar'

interface headerProps {

avatarUrl?: string;
firstName?: string;
lastName?: string;
handleLogoutClick?: () => void;
handleEditClick?: () => void;

}

const Header = ({ avatarUrl ,handleLogoutClick, handleEditClick } : headerProps ) => {
const Header = ({ avatarUrl, firstName, lastName ,handleLogoutClick, handleEditClick } : headerProps ) => {
return (
<header className="flex h-14 items-center gap-4 border-b bg-muted/40 px-4 lg:h-[60px] lg:px-6">
<Sheet>
Expand Down Expand Up @@ -59,10 +62,7 @@ const Header = ({ avatarUrl ,handleLogoutClick, handleEditClick } : headerProps
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Avatar>
<AvatarImage src={avatarUrl} alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<CustomAvatar image_url={avatarUrl} first_name={firstName} last_name={lastName}></CustomAvatar>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
Expand Down
28 changes: 28 additions & 0 deletions src/components/ui/custom-avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from "react";
import { cn } from "@/lib/utils";
import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar";
import { get_fallback_name } from "@/lib/utils";

type CustomAvatarProps = {
className?: string;
image_url?: string;
first_name?: string;
last_name?: string;
};
const CustomAvatar = ({
className,
image_url,
first_name,
last_name,
}: CustomAvatarProps) => {
return (
<Avatar className={cn("h-12 w-12", className)}>
<AvatarImage src={image_url} />
<AvatarFallback className="p-2">
{get_fallback_name(first_name, last_name)}
</AvatarFallback>
</Avatar>
);
};

export default CustomAvatar;
6 changes: 2 additions & 4 deletions src/components/ui/projectcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
} from "@/redux/features/innovations/innovationsApiSlice";
import { extractIdFromUrl } from "@/utils/ExtractIdFromUrl";
import { useRouter } from "next/navigation";
import CustomAvatar from "./custom-avatar";


// * interface for project card props
Expand Down Expand Up @@ -188,10 +189,7 @@ const ProjectCard = ({
<Card className="max-w-[500px]">
<div className="p-0 mx-6 flex justify-between items-center">
<div className="flex items-center gap-2 mt-2">
<Avatar>
<AvatarImage src={author_avator_image_url} alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<CustomAvatar image_url={author_avator_image_url} first_name={author_first_name} last_name={author_last_name}></CustomAvatar>
<Link href="/dashboard">
{author_first_name} {author_last_name}
</Link>
Expand Down

0 comments on commit 5171000

Please sign in to comment.