Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHE-53] Update Profiles Page To Display Profile Pics #60

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion client/src/components/ProfileThumb/ProfileThumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ const ProfileThumb = ({ profile }: ProfileThumbProps): JSX.Element => {
const dispatch = useAppDispatch();

return (
<div className="min-h-screen bg-gray-100 flex flex-col items-center justify-center">
<div className="bg-gray-100 flex flex-col items-center justify-center p-4 rounded-lg shadow-lg">
{profile.profilePhoto && (
<img
src={profile.profilePhoto}
alt="Profile"
className="rounded-full h-20 w-20 object-cover mb-4"
/>
)}
<h1 className="text-4xl font-extrabold mb-4">{profile.fullName}</h1>
<h2 className="text-4xl font-extrabold mb-4">{profile.personalBio}</h2>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`MainPage Component renders correctly 1`] = `
onClick={[Function]}
>
<div
className="min-h-screen bg-gray-100 flex flex-col items-center justify-center"
className="bg-gray-100 flex flex-col items-center justify-center p-4 rounded-lg shadow-lg"
>
<h1
className="text-4xl font-extrabold mb-4"
Expand All @@ -32,7 +32,7 @@ exports[`MainPage Component renders correctly 1`] = `
onClick={[Function]}
>
<div
className="min-h-screen bg-gray-100 flex flex-col items-center justify-center"
className="bg-gray-100 flex flex-col items-center justify-center p-4 rounded-lg shadow-lg"
>
<h1
className="text-4xl font-extrabold mb-4"
Expand Down
16 changes: 15 additions & 1 deletion server/controllers/profileController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,21 @@ const getAllProfiles = async (
message: { err: "There were no profiles to retrieve" },
});
} else {
return res.status(201).json(profiles);
const processedProfiles = await Promise.all(
profiles.map(async (profile) => {
if (profile.profilePhoto) {
const presignedUrl = s3.getSignedUrl("getObject", {
Bucket: process.env.BUCKET_NAME,
Key: profile.profilePhoto,
Expires: 60 * 5,
});
profile.profilePhoto = presignedUrl;
}
return profile.toObject();
})
);

return res.status(201).json(processedProfiles);
}
} catch (error) {
return next({
Expand Down
Loading