diff --git a/app/(content)/(user)/[userid]/page.tsx b/app/(content)/(user)/[userid]/page.tsx index 2698ce45c3acb879ecf39e1f936b93d2bfa39c1a..35f635bb6b95e6f119fb7dd9de3c2778ac976d00 100644 --- a/app/(content)/(user)/[userid]/page.tsx +++ b/app/(content)/(user)/[userid]/page.tsx @@ -5,38 +5,43 @@ import { Skeleton } from "@/components/ui/skeleton" import { UserAvatar } from "@/components/user-avatar" import { db } from "@/lib/db" import { getFavoriteGames } from "@/lib/igdb" -import { getCurrentUser } from "@/lib/session" import { IGame } from "@/types/igdb-types" import { redirect } from "next/navigation" + export default async function User({ params }: { params: { userid: string } }) { - const user = await getCurrentUser() + + const user = await db.user.findFirst({ + where: { + username: params.userid + } + }) - if (user?.username !== params.userid) { + if(!user){ redirect('/') } + const fullUser = await db.user.findFirst({ where: { - id: user?.id + id: user.id } }) - let favoritegames = undefined let playingGames = undefined let finishedGames = undefined let planningGames = undefined - if (fullUser?.favGameList?.length !== 0) { + if (fullUser?.favGameList?.length !== 0 && fullUser?.favGameList?.length != undefined) { favoritegames = await getFavoriteGames(fullUser?.favGameList!) } - if (fullUser?.favGameList?.length !== 0) { + if (fullUser?.playingGameList?.length !== 0) { playingGames = await getFavoriteGames(fullUser?.playingGameList!) } - if (fullUser?.favGameList?.length !== 0) { + if (fullUser?.finishedGameList?.length !== 0) { finishedGames = await getFavoriteGames(fullUser?.finishedGameList!) } - if (fullUser?.favGameList?.length !== 0) { + if (fullUser?.planningGameList?.length !== 0) { planningGames = await getFavoriteGames(fullUser?.planningGameList!) } return ( diff --git a/components/gweets/components/gweet-author.tsx b/components/gweets/components/gweet-author.tsx index c0868040d8f261d973f94864b83999c99aa8edd0..632b8c84959f49c46042416504cf344c679caee0 100644 --- a/components/gweets/components/gweet-author.tsx +++ b/components/gweets/components/gweet-author.tsx @@ -1,15 +1,17 @@ import { UserAvatar } from "@/components/user-avatar"; import { IGweet } from "../types"; import { GweetOptions } from "./gweet-options"; +import Link from "next/link"; export const GweetAuthor = ({ gweet }: { gweet: IGweet }) => { return ( <div className="flex items-center"> + <Link href={`/${gweet.author.username}`}> <UserAvatar user={{ username: gweet.author.username, image: gweet.author.image }} className="h-10 w-10" /> - + </Link> <div className="flex flex-col ml-3"> <span className="font-bold">{gweet.author.name}</span> <span className="text-sky-500 text-sm">@{gweet.author.username}</span>