From 2e9e4db6cb96aa5719b98bcfa920a4f7e9fca480 Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Fri, 25 Apr 2025 21:08:04 +0100 Subject: [PATCH] fix: don't show edit and delete buttons in mii list on profiles --- src/app/profile/[slug]/page.tsx | 4 ++-- src/components/mii-list/index.tsx | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/profile/[slug]/page.tsx b/src/app/profile/[slug]/page.tsx index 61b4fa8..5614cab 100644 --- a/src/app/profile/[slug]/page.tsx +++ b/src/app/profile/[slug]/page.tsx @@ -42,7 +42,7 @@ export default async function ProfilePage({ params }: Props) {

{user?.name}

@{user?.username}

-

+

Liked {likedMiis} Miis

@@ -58,7 +58,7 @@ export default async function ProfilePage({ params }: Props) { - + ); } diff --git a/src/components/mii-list/index.tsx b/src/components/mii-list/index.tsx index 28bd2ba..1c379af 100644 --- a/src/components/mii-list/index.tsx +++ b/src/components/mii-list/index.tsx @@ -18,6 +18,7 @@ interface Props { isLoggedIn: boolean; // Profiles userId?: number; + sessionUserId?: number; } interface ApiResponse { @@ -41,7 +42,7 @@ interface ApiResponse { const fetcher = (url: string) => fetch(url).then((res) => res.json()); -export default function MiiList({ isLoggedIn, userId }: Props) { +export default function MiiList({ isLoggedIn, userId, sessionUserId }: Props) { const searchParams = useSearchParams(); const { data, error } = useSWR(`/api/mii/list?${searchParams.toString()}`, fetcher); @@ -103,11 +104,13 @@ export default function MiiList({ isLoggedIn, userId }: Props) {
- {!userId ? ( + {!userId && ( @{mii.user?.username} - ) : ( + )} + + {userId && sessionUserId == userId && (