fix: don't show edit and delete buttons in mii list on profiles
This commit is contained in:
parent
101edfbc16
commit
2e9e4db6cb
2 changed files with 8 additions and 5 deletions
|
|
@ -42,7 +42,7 @@ export default async function ProfilePage({ params }: Props) {
|
||||||
<h1 className="text-4xl font-extrabold w-full break-words">{user?.name}</h1>
|
<h1 className="text-4xl font-extrabold w-full break-words">{user?.name}</h1>
|
||||||
<h2 className="text-lg font-semibold break-words">@{user?.username}</h2>
|
<h2 className="text-lg font-semibold break-words">@{user?.username}</h2>
|
||||||
|
|
||||||
<h4 className="mt-auto">
|
<h4 className="mt-auto text-sm">
|
||||||
Liked <span className="font-bold">{likedMiis}</span> Miis
|
Liked <span className="font-bold">{likedMiis}</span> Miis
|
||||||
</h4>
|
</h4>
|
||||||
<h4 className="text-sm" title={`${user?.createdAt.toLocaleTimeString("en-GB", { timeZone: "UTC" })} UTC`}>
|
<h4 className="text-sm" title={`${user?.createdAt.toLocaleTimeString("en-GB", { timeZone: "UTC" })} UTC`}>
|
||||||
|
|
@ -58,7 +58,7 @@ export default async function ProfilePage({ params }: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MiiList isLoggedIn={session?.user != null} userId={user?.id} />
|
<MiiList isLoggedIn={session?.user != null} userId={user?.id} sessionUserId={Number(session?.user.id ?? -1)} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ interface Props {
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
// Profiles
|
// Profiles
|
||||||
userId?: number;
|
userId?: number;
|
||||||
|
sessionUserId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ApiResponse {
|
interface ApiResponse {
|
||||||
|
|
@ -41,7 +42,7 @@ interface ApiResponse {
|
||||||
|
|
||||||
const fetcher = (url: string) => fetch(url).then((res) => res.json());
|
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 searchParams = useSearchParams();
|
||||||
const { data, error } = useSWR<ApiResponse>(`/api/mii/list?${searchParams.toString()}`, fetcher);
|
const { data, error } = useSWR<ApiResponse>(`/api/mii/list?${searchParams.toString()}`, fetcher);
|
||||||
|
|
||||||
|
|
@ -103,11 +104,13 @@ export default function MiiList({ isLoggedIn, userId }: Props) {
|
||||||
<div className="mt-auto grid grid-cols-2 items-center">
|
<div className="mt-auto grid grid-cols-2 items-center">
|
||||||
<LikeButton likes={mii.likes} miiId={mii.id} isLiked={mii.isLiked} isLoggedIn={isLoggedIn} abbreviate />
|
<LikeButton likes={mii.likes} miiId={mii.id} isLiked={mii.isLiked} isLoggedIn={isLoggedIn} abbreviate />
|
||||||
|
|
||||||
{!userId ? (
|
{!userId && (
|
||||||
<Link href={`/profile/${mii.user?.id}`} className="text-sm text-right overflow-hidden text-ellipsis">
|
<Link href={`/profile/${mii.user?.id}`} className="text-sm text-right overflow-hidden text-ellipsis">
|
||||||
@{mii.user?.username}
|
@{mii.user?.username}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
)}
|
||||||
|
|
||||||
|
{userId && sessionUserId == userId && (
|
||||||
<div className="flex gap-1 text-2xl justify-end text-zinc-400">
|
<div className="flex gap-1 text-2xl justify-end text-zinc-400">
|
||||||
<Link href={`/edit/${mii.id}`}>
|
<Link href={`/edit/${mii.id}`}>
|
||||||
<Icon icon="mdi:pencil" />
|
<Icon icon="mdi:pencil" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue