diff --git a/app/(content)/followers/page.tsx b/app/(content)/followers/page.tsx index 7d8778f1536ea8bccdf82875f3b1ccb301ed563b..7fbb300f9278a7faf66defcc56a8048dc6fdbd81 100644 --- a/app/(content)/followers/page.tsx +++ b/app/(content)/followers/page.tsx @@ -12,7 +12,7 @@ export default async function Followers() { return ( <div> <h1>Followers Page WIP</h1> - <FollowersList userId={session.user?.id} /> + <FollowersList userId={parseFloat(session.user?.id)} /> </div> ) } \ No newline at end of file diff --git a/components/filter-sort-games.tsx b/components/filter-sort-games.tsx index b7a736df69ec55a3524050442231e546493f1793..caa9c363c3aeea948dca644e11642d38da75fc43 100644 --- a/components/filter-sort-games.tsx +++ b/components/filter-sort-games.tsx @@ -2,7 +2,7 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; -import { useLayoutEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { Icons } from "./icons"; import { Button } from "./ui/button"; import { Card } from "./ui/card"; @@ -25,8 +25,8 @@ export default function Sort() { category: selectedCategory ? `category=${selectedCategory}` : '', genre: selectedGenre ? `genre=${selectedGenre}` : '', platform: selectedPlatform ? `platform=${selectedPlatform}` : '', - sortMethod: selectedSortMethod == 'total_rating_count' ? '' : `sortby=${selectedSortMethod}`, - sortOrder: selectedSortOrder == 'desc' ? '' : `order=${selectedSortOrder}`, + sortMethod: selectedSortMethod ? `sortby=${selectedSortMethod}` : '', + sortOrder: selectedSortOrder ? `order=${selectedSortOrder}` : '', }; const queryParamString = Object.values(urlParams) @@ -36,11 +36,11 @@ export default function Sort() { const url = `${pathname}${queryParamString ? `${queryParamString}` : ''}`; - useLayoutEffect(() => { - if (queryParamString) { - router.replace(url); - } - }, [queryParamString, router, url]); + // useEffect(() => { + // if (queryParamString) { + router.replace(url); + // } + // }, [queryParamString, router, url]); function toggleSortOrder() { const newSortOrder = selectedSortOrder === 'desc' ? 'asc' : 'desc'; @@ -137,7 +137,7 @@ export default function Sort() { </SelectGroup> </SelectContent> </Select> - <Button variant="ghost" onClick={() => toggleSortOrder}> + <Button variant="ghost" onClick={() => toggleSortOrder()}> <Icons.arrowdown className={`h-4 w-4 transition-all transform ${selectedSortOrder === 'asc' ? 'rotate-180' : ''}`} /> </Button> </div> diff --git a/components/following-button.tsx b/components/following-button.tsx index af3f477154482518863ab563d5ebcb1fa11cf031..420ecdc016ea82d2f78da72783b66dee0ac07c28 100644 --- a/components/following-button.tsx +++ b/components/following-button.tsx @@ -1,49 +1,50 @@ "use client" -import { PrismaClient } from '@prisma/client'; +// import { PrismaClient } from '@prisma/client'; import { useState } from 'react'; import { Button } from './ui/button'; -const prisma = new PrismaClient(); +// Muss in die API route +// const prisma = new PrismaClient(); -async function getFollower(userId: number, followerId: number) { - const follower = await prisma.follows.findFirst({ - where: { - followerId: followerId, - followingId: userId, - }, - }); +// async function getFollower(userId: number, followerId: number) { +// const follower = await prisma.follows.findFirst({ +// where: { +// followerId: followerId, +// followingId: userId, +// }, +// }); - return follower; -} +// return follower; +// } export default function FollowButton({ userId, followerId }: { userId: number; followerId: number }) { const [isFollowing, setIsFollowing] = useState(false); const handleFollow = async () => { - const follower = await getFollower(userId, followerId); - - if (follower) { - // User is already following, so unfollow - await prisma.follows.delete({ - where: { - followerId_followingId: { - followerId: followerId, - followingId: userId, - }, - }, - }); - setIsFollowing(false); - } else { - // User is not following, so follow - await prisma.follows.create({ - data: { - followerId: followerId, - followingId: userId, - }, - }); - setIsFollowing(true); - } + // const follower = await getFollower(userId, followerId); + + // if (follower) { + // // User is already following, so unfollow + // await prisma.follows.delete({ + // where: { + // followerId_followingId: { + // followerId: followerId, + // followingId: userId, + // }, + // }, + // }); + // setIsFollowing(false); + // } else { + // // User is not following, so follow + // await prisma.follows.create({ + // data: { + // followerId: followerId, + // followingId: userId, + // }, + // }); + // setIsFollowing(true); + // } }; return ( diff --git a/components/following-users.tsx b/components/following-users.tsx index be7c652973df7a5f4d0e5bb4871cfb8b71184eee..44408c13acfcd0343a27854bd4a9b23de54c74ad 100644 --- a/components/following-users.tsx +++ b/components/following-users.tsx @@ -1,9 +1,10 @@ "use client" -import { PrismaClient } from '@prisma/client'; +// import { PrismaClient } from '@prisma/client'; import { useEffect, useState } from 'react'; -const prisma = new PrismaClient(); +// Muss in die API route +// const prisma = new PrismaClient(); interface Follower { id: number; @@ -16,21 +17,21 @@ export default function FollowersList({ userId }: { userId: number }) { useEffect(() => { async function fetchFollowers() { - const followersList = await prisma.follows.findMany({ - where: { - followingId: userId, - }, - include: { - follower: true, - }, - }); - - const filteredFollowers = followersList.map((follow) => { - const { id, name, email } = follow.follower; - return { id, name: name ?? "", email }; - }); - - setFollowers(filteredFollowers); + // const followersList = await prisma.follows.findMany({ + // where: { + // followingId: userId, + // }, + // include: { + // follower: true, + // }, + // }); + + // const filteredFollowers = followersList.map((follow: any) => { + // const { id, name, email } = follow.follower; + // return { id, name: name ?? "", email }; + // }); + + // setFollowers(filteredFollowers); } fetchFollowers();