Skip to content

Commit

Permalink
Added default profile pic for the uses (#1101)
Browse files Browse the repository at this point in the history
Co-authored-by: Shyam Tawli <[email protected]>
  • Loading branch information
Utsavladia and shyamtawli authored Sep 4, 2024
1 parent 6db98aa commit 31b27cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Profile/Profile.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React from 'react';
import React, { useState } from 'react';
import { FaGithub, FaLinkedin } from 'react-icons/fa';
import { FaXTwitter, FaLocationDot } from 'react-icons/fa6';
import defaultAvatar from './image.png';

function Profile({ data }) {
return <Card data={data} />;
}

function Card({ data }) {
const cardRef = React.useRef();
const [imageSrc, setImageSrc] = useState(data.avatar || defaultAvatar);
const handleImageError = () => {
setImageSrc(defaultAvatar); // Fallback to default image
};

const handleWheel = (event) => {
event.stopPropagation();
Expand All @@ -31,7 +36,7 @@ function Card({ data }) {
<div className="mb-6 h-auto rounded-lg bg-white p-4 shadow dark:bg-textPrimary">
<div className="relative flex gap-4">
<div className="h-24 w-24 flex-shrink-0">
<img src={data.avatar} className="h-full w-full rounded-full" alt="User logo" />
<img src={imageSrc} alt="User logo" className="h-full w-full rounded-full" onError={handleImageError} />
</div>
<div className="w-[55%] sm:w-[75%]">
<h3>
Expand Down
Binary file added src/components/Profile/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 31b27cb

Please sign in to comment.