Skip to content

Commit ff4ae1c

Browse files
committed
Add: On click event on the ProfilePicturePreview image and render conditionally the delete button
1 parent f88ba1b commit ff4ae1c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/cards/ProfilePicturePreview/ProfilePicturePreview.jsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@ export const ProfilePicturePreview = ({
2020
imageFile,
2121
}) => {
2222
const imageSrc = imageFile ? imageFile : AMAZON_S3_BUCKET + "/" + image;
23+
const hasImage =
24+
!!imageFile ||
25+
(image && image !== "default" && image !== "default-sponsor");
26+
const showDeleteButton = hasImage && typeof handleDeleteClick === "function";
2327
return (
2428
<div className="profile-picture-preview-wrapper">
2529
<div className="profile-picture-preview">
26-
<Icon
27-
onClick={handleDeleteClick}
28-
name="circle-action-close-purple"
29-
size="md"
30+
{showDeleteButton && (
31+
<Icon
32+
onClick={handleDeleteClick}
33+
name="circle-action-close-purple"
34+
size="md"
35+
/>
36+
)}
37+
<img
38+
src={imageSrc}
39+
alt="profile-picture"
40+
onClick={handleChangeClick}
3041
/>
31-
<img src={imageSrc} alt="profile-picture" />
3242
<p onClick={handleChangeClick} className="small-text">
3343
{changePhotoText}
3444
</p>

src/components/cards/ProfilePicturePreview/profile-picture-preview.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
height: 8rem;
1919
border-radius: 50%;
2020
object-fit: cover;
21+
cursor: pointer;
2122
}
2223

2324
& p {

0 commit comments

Comments
 (0)