Skip to content
Snippets Groups Projects
Commit 80c80a03 authored by Caner's avatar Caner
Browse files

UserPage fix und link

parent c37fdc2e
No related branches found
No related tags found
1 merge request!32User page link
Pipeline #38813 passed
......@@ -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 (
......
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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment