Skip to content

Commit

Permalink
Merge pull request #551 from MeetDOD/issue-548
Browse files Browse the repository at this point in the history
Feat: Added/fetched user avatar in admin panel successfully issue 548
  • Loading branch information
VaibhavArora314 authored Aug 3, 2024
2 parents f6ec8d1 + 2de2282 commit 3ba5b99
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 6 deletions.
Binary file added admin/src/assets/avatars/avatar1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/src/assets/avatars/avatar2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/src/assets/avatars/avatar3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/src/assets/avatars/avatar4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/src/assets/avatars/avatar5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion admin/src/pages/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Comments = () => {
<td colSpan={4} className="px-8 py-4">
<div className="flex items-start space-x-4">
<div className="flex-shrink-0">
<img className="h-10 w-10 rounded-full" src={`https://ui-avatars.com/api/?name=${comment.user.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" />
<img className="h-10 w-10 rounded-full" src={comment.user?.avatar?.replace('/app', '/admin') || `https://ui-avatars.com/api/?name=${comment.user?.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" />
</div>
<div className="min-w-0 flex-1">
<p className="text-sm font-medium text-white">
Expand Down
2 changes: 1 addition & 1 deletion admin/src/pages/Favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Favorites = () => {
{favoritePosts.map(favorite => (
<tr key={favorite.id} className="text-xs md:text-sm text-center border-b bg-[#000435] border-sky-500 hover:bg-blue-950 hover:text-white">
<td className="pl-7">
<img className="h-10 w-10 rounded-full" src={`https://ui-avatars.com/api/?name=${favorite.user.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" />
<img className="h-10 w-10 rounded-full" src={favorite.user?.avatar?.replace('/app', '/admin') || `https://ui-avatars.com/api/?name=${favorite.user?.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" />
</td>
<td className="px-8 py-4 font-semibold">
<div className="flex flex-col items-start">
Expand Down
2 changes: 1 addition & 1 deletion admin/src/pages/Reactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Reactions = () => {
{reactions.map(reaction => (
<tr key={reaction.user.id + reaction.post.id + reaction.type} className="text-xs md:text-sm text-center border-b bg-[#000435] border-sky-500 hover:bg-blue-950 hover:text-white">
<td className="pl-7">
<img className="h-10 w-10 rounded-full" src={`https://ui-avatars.com/api/?name=${reaction.user?.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" />
<img className="h-10 w-10 rounded-full" src={reaction.user?.avatar?.replace('/app', '/admin') || `https://ui-avatars.com/api/?name=${reaction.user?.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" />
</td>
<td className="px-6 py-4 font-semibold">
<div className="flex flex-col items-start">
Expand Down
3 changes: 2 additions & 1 deletion admin/src/pages/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Users = () => {
});
setAllUsers(response.data.allUsers.reverse());
setLoading(false);
console.log(response.data.allUsers)
} catch (error) {
console.error("Error fetching users:", error);
setLoading(true);
Expand Down Expand Up @@ -108,7 +109,7 @@ const Users = () => {
<tbody>
{allUsers.map(user => (
<tr key={user.id} className="text-xs md:text-sm text-center border-b bg-[#000435] border-sky-500 hover:bg-blue-950 hover:text-white">
<td className="pl-7"><img className="h-10 w-10 rounded-full" src={`https://ui-avatars.com/api/?name=${user.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" /></td>
<td className="pl-7"><img className="h-10 w-10 rounded-full" src={user?.avatar?.replace('/app', '/admin') || `https://ui-avatars.com/api/?name=${user?.username}&background=0ea5e9&color=fff&rounded=true&bold=true`} alt="profile-pic" /></td>
<td className="px-8 py-4 font-semibold">
<div className="flex flex-col items-start">
<span className="font-bold">{user.username}</span>
Expand Down
1 change: 1 addition & 0 deletions admin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface IFavoritePost {
id: string;
username: string;
email: string;
avatar?:string;
};
post: {
id: string;
Expand Down
6 changes: 5 additions & 1 deletion backend/src/routes/admin/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const allUserForAdmin = async (req: Request, res:Response) => {
posts:true,
createdAt:true,
comments:true,
avatar:true,
following: {
select: {
id: true
Expand Down Expand Up @@ -167,6 +168,7 @@ export const getAdminPostsController = async (req: Request, res: Response) => {
select: {
username: true,
email: true,
avatar:true
},
},
},
Expand Down Expand Up @@ -486,6 +488,7 @@ export const getPostReactionsController = async (req: Request, res: Response) =>
id: true,
username: true,
email: true,
avatar:true
},
},
post: {
Expand Down Expand Up @@ -527,7 +530,8 @@ export const getFavoritesController = async (req: Request, res: Response) => {
select: {
id: true,
username: true,
email: true
email: true,
avatar:true
}
},
post: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/TestimonialSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const TestimonialSlider: React.FC = () => {
{testimonials.slice(currentIndex, currentIndex + slidesToShow).map((testimonial, index) => (
<div key={index} className="testimonial border border-blue-400 dark:border-gray-00 px-2 py-4 md:py-24 rounded-md mx-2 p-6 md:p-10 rounded-lg shadow-lg bg-white dark:bg-[#000435] text-[#000435] dark:text-white flex flex-col items-center justify-center min-w-[260px] md:min-w-[350px] lg:min-w-[400px]">
<img
src={testimonial.image}
src={testimonial.image|| `https://ui-avatars.com/api/?name=${testimonial.author}&background=0ea5e9&color=fff&rounded=true&bold=true`}
alt={`${testimonial.author}'s picture`}
className="w-24 h-24 md:w-32 md:h-32 rounded-full mb-6 border-4 p-1 border-[#a238ff] dark:border-white"
/>
Expand Down

0 comments on commit 3ba5b99

Please sign in to comment.