Skip to content

Commit

Permalink
Merge pull request #31 from Javan-Odhiambo/minor-fixes
Browse files Browse the repository at this point in the history
Minor fixes
Javan-Odhiambo authored Jun 7, 2024
2 parents 3661956 + 2900fac commit b3ef95d
Showing 10 changed files with 28 additions and 58 deletions.
2 changes: 2 additions & 0 deletions src/app/dashboard/bookmarks/page.tsx
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ const BookmarkPage = () => {
author_avator_image_url={
user.profile_picture || "/profile-svgrepo-com.svg"
}
author_email={user.email}
author_first_name={user.first_name}
author_last_name={user.last_name}
project_title={innovation.title}
@@ -30,6 +31,7 @@ const BookmarkPage = () => {
comments_count={innovation.comments_number}
is_liked={innovation.is_liked}
is_bookmarked={innovation.is_bookmarked}
status={innovation.status}
/>
);
})
2 changes: 1 addition & 1 deletion src/app/dashboard/innovation/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ const InnovationDetailPage = ({ params }: InnovationDetailPageProps) => {
<div className="flex items-center justify-between mt-5 px-4 ">
<div className="flex items-center gap-3">

<CustomAvatar image_url={innovation?.author.profile_picture} first_name={innovation?.author.first_name} last_name={innovation?.author.last_name}></CustomAvatar>
<CustomAvatar image_url={innovation?.author.profile_picture} first_name={innovation?.author.first_name} last_name={innovation?.author.last_name} email={innovation?.author.email}></CustomAvatar>
<div>
<p>{`${innovation?.author.first_name} ${innovation?.author.last_name}`}</p>
<p className="text-sm">{innovation?.author.email}</p>
52 changes: 2 additions & 50 deletions src/app/dashboard/innovation/drafts/page.tsx
Original file line number Diff line number Diff line change
@@ -33,55 +33,6 @@ const DraftsPage = () => {
}, []);
const totalPages = Math.ceil(draftsList?.count / ITEMS_PER_PAGE);

// author
// :
// { id: 2, email: 'javan@mail.com', first_name: '', last_name: '', username: '', … }
// comments_number
// :
// 0
// created_at
// :
// "2024-05-31T08:21:49.783012Z"
// dashboard_definitions
// :
// "http://localhost:8000/media/dashboard_definitions/Useful_links.png"
// dashboard_id
// :
// "undefined"
// dashboard_image
// :
// "http://localhost:8000/media/dashboards/IEEE_voles.png"
// dashboard_link
// :
// "https://blog.logrocket.com/react-hook-form-complete-guide/"
// dashboard_type
// :
// "M"
// description
// :
// "Helloddfdfadf"
// is_bookmarked
// :
// false
// is_liked
// :
// false
// likes_number
// :
// 0
// status
// :
// "D"
// title
// :
// "Another test"
// updated_at
// :
// "2024-05-31T08:21:49.783063Z"
// url
// :
// "http://localhost:8000/api/innovations/2/"

return (
<main>
<section className="flex flex-wrap mx-auto gap-4 p-4">
@@ -99,9 +50,10 @@ const DraftsPage = () => {
}
author_first_name={innovation.author.first_name}
author_last_name={innovation.author.last_name}
author_email={innovation.author.email}
project_title={innovation.title}
project_description={innovation.description}
dashboard_banner_image_url={innovation.banner_image}
dashboard_image_url={innovation.dashboard_image}
likes_count={innovation.likes_number}
comments_count={innovation.comments_number}
is_liked={innovation.is_liked}
2 changes: 2 additions & 0 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -69,13 +69,15 @@ const Home = () => {
author_avator_image_url={innovation.author.profile_picture}
author_first_name={innovation.author.first_name}
author_last_name={innovation.author.last_name}
author_email={innovation.author.email}
project_title={innovation.title}
project_description={innovation.description}
dashboard_image_url={innovation.dashboard_image}
likes_count={innovation.likes_number}
comments_count={innovation.comments_number}
is_liked={innovation.is_liked}
is_bookmarked={innovation.is_bookmarked}
status={innovation.status}
/>
);
})}
2 changes: 2 additions & 0 deletions src/components/SearchComponent.tsx
Original file line number Diff line number Diff line change
@@ -90,13 +90,15 @@ function SearchComponent({
author_avator_image_url={innovation.author.profile_picture}
author_first_name={innovation.author.first_name}
author_last_name={innovation.author.last_name}
author_email={innovation.author.email}
project_title={innovation.title}
project_description={innovation.description}
dashboard_image_url={innovation.dashboard_image}
likes_count={innovation.likes_number}
comments_count={innovation.comments_number}
is_liked={innovation.is_liked}
is_bookmarked={innovation.is_bookmarked}
status={innovation.status}
/>
)
)}
11 changes: 9 additions & 2 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -19,18 +19,20 @@ 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'
import { get_fallback_name } from '@/lib/utils'

interface headerProps {

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

}

const Header = ({ avatarUrl, firstName, lastName ,handleLogoutClick, handleEditClick } : headerProps ) => {
const Header = ({ avatarUrl, firstName, lastName, email, 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>
@@ -62,7 +64,12 @@ const Header = ({ avatarUrl, firstName, lastName ,handleLogoutClick, handleEditC
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<CustomAvatar image_url={avatarUrl} first_name={firstName} last_name={lastName}></CustomAvatar>
<Avatar className="h-10 w-10">
<AvatarImage src={avatarUrl} />
<AvatarFallback className="p-2">
{get_fallback_name(firstName, lastName, email)}
</AvatarFallback>
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
4 changes: 3 additions & 1 deletion src/components/ui/custom-avatar.tsx
Original file line number Diff line number Diff line change
@@ -8,18 +8,20 @@ type CustomAvatarProps = {
image_url?: string;
first_name?: string;
last_name?: string;
email?: string;
};
const CustomAvatar = ({
className,
image_url,
first_name,
last_name,
email,
}: 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)}
{get_fallback_name(first_name, last_name, email)}
</AvatarFallback>
</Avatar>
);
4 changes: 3 additions & 1 deletion src/components/ui/projectcard.tsx
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ interface CardProps {
author_avator_image_url?: string;
author_first_name?: string;
author_last_name?: string;
author_email?: string;
project_title: string;
project_description: string;
dashboard_image_url: string;
@@ -92,6 +93,7 @@ const ProjectCard = ({
author_avator_image_url,
author_first_name,
author_last_name,
author_email,
project_title,
project_description,
dashboard_image_url,
@@ -189,7 +191,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">
<CustomAvatar image_url={author_avator_image_url} first_name={author_first_name} last_name={author_last_name}></CustomAvatar>
<CustomAvatar email={author_email} 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>
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ interface TInnovation {
updated_at: string;
is_liked: boolean;
is_bookmarked: boolean;
status: string;
status: "D" | "P";
dashboard_type: string;
embed_id: string;
// category: string;
5 changes: 3 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}

export function get_fallback_name(first_name: string | undefined, last_name: string | undefined) {
return `${first_name && first_name[0].toUpperCase()} ${last_name && last_name[0].toUpperCase()}`
export function get_fallback_name(first_name: string | undefined, last_name: string | undefined, email: string | undefined) {
if (!first_name && !last_name) return email && (email[0] + email[1]).toUpperCase()
return `${first_name && first_name[0].toUpperCase()}${last_name && last_name[0].toUpperCase()}`
}

0 comments on commit b3ef95d

Please sign in to comment.