diff --git a/app/(content)/(gaming)/games/[gameid]/page.tsx b/app/(content)/(gaming)/games/[gameid]/page.tsx index cfded75d474797deba9d4f224db42628a6c3ca83..de1a27a584417954589739a37913040f7bfbd5da 100644 --- a/app/(content)/(gaming)/games/[gameid]/page.tsx +++ b/app/(content)/(gaming)/games/[gameid]/page.tsx @@ -67,7 +67,7 @@ export default async function GameDetail({ params }: { params: { gameid: string className="object-cover rounded-lg" /> </Card> <div className="flex justify-start p-6"> - <AddGameDropdown fullUser={fullUser!} gameid={params.gameid} /> + {user && < AddGameDropdown fullUser={fullUser!} gameid={params.gameid} />} </div> </div> diff --git a/components/add-game-dropdown.tsx b/components/add-game-dropdown.tsx index 6a9fa57a3c08c73cd82a1e39d8dfd957029ab51e..6aeef46e0810b0aa6662e32a1ba211a93ff96def 100644 --- a/components/add-game-dropdown.tsx +++ b/components/add-game-dropdown.tsx @@ -11,6 +11,7 @@ import { Card } from "./ui/card" import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "./ui/select" export default function AddGameDropdown(props: { gameid: string, fullUser: User }) { + return ( <> <Select> @@ -19,7 +20,6 @@ export default function AddGameDropdown(props: { gameid: string, fullUser: User </SelectTrigger> <SelectContent> <SelectGroup> - <SelectLabel>Status</SelectLabel> <AddGameToPlanList user={props.fullUser!} gameId={props.gameid} /> <AddGameToFinishedList user={props.fullUser!} gameId={props.gameid} /> <AddGameToPlayingList user={props.fullUser!} gameId={props.gameid} /> diff --git a/components/add-game-to-finished-list.tsx b/components/add-game-to-finished-list.tsx index 6f8ec4fec6592b7d0ef72a7b9c7fb5e990d99822..947e103a61b5e228b1f5cbda8e9fb878069d088a 100644 --- a/components/add-game-to-finished-list.tsx +++ b/components/add-game-to-finished-list.tsx @@ -32,7 +32,6 @@ export default function AddGameToFinishedList(props: { gameId: string, user: Use formData.id = user.id formData.finishedGameList = props.user.finishedGameList.filter((id) => id !== gameId) - console.log(formData.finishedGameList) const response = await fetch('/api/users/gamelists', { method: 'PUT', body: JSON.stringify(formData) @@ -71,16 +70,16 @@ export default function AddGameToFinishedList(props: { gameId: string, user: Use if (!props.user.finishedGameList.includes(parseFloat(props.gameId))) { button = ( <form onSubmit={addGame}> - <Button type="submit" size="lg"> - Add Game To finished-playing-List + <Button type="submit" size="lg" variant="ghost"> + Finished </Button> </form> ) } else { button = ( <form onSubmit={removeGame}> - <Button type="submit" size="lg" variant={"secondary"}> - Remove Game From finished-playing-List + <Button type="submit" size="lg" variant="ghost"> + Remove Finished </Button> </form> ) diff --git a/components/add-game-to-plan-list.tsx b/components/add-game-to-plan-list.tsx index 9de2099cfc9a791adeeb582fa51f2951246130ea..a401599718721b9359550bca6442fff6182aa92f 100644 --- a/components/add-game-to-plan-list.tsx +++ b/components/add-game-to-plan-list.tsx @@ -32,7 +32,6 @@ export default function AddGameToPlanList(props: { gameId: string, user: User }) formData.id = user.id formData.planningGameList = props.user.planningGameList.filter((id) => id !== gameId) - console.log(formData.planningGameList) const response = await fetch('/api/users/gamelists', { method: 'PUT', body: JSON.stringify(formData) @@ -71,16 +70,16 @@ export default function AddGameToPlanList(props: { gameId: string, user: User }) if (!props.user.planningGameList.includes(parseFloat(props.gameId))) { button = ( <form onSubmit={addGame}> - <Button type="submit" size="lg"> - Add Game To Planning-to-play-List + <Button type="submit" size="lg" variant={"ghost"}> + Planning-to-play-List </Button> </form> ) } else { button = ( <form onSubmit={removeGame}> - <Button type="submit" size="lg" variant={"secondary"}> - Remove Game From Planning-to-play-List + <Button type="submit" size="lg" variant={"ghost"}> + Remove Planning-to-play </Button> </form> ) diff --git a/components/add-game-to-playing-list.tsx b/components/add-game-to-playing-list.tsx index 81232c6e72774bc9e86d07f90d7970f1fc070fd0..e47ba4d67609a40dd5ef1b721f4f188f06d71384 100644 --- a/components/add-game-to-playing-list.tsx +++ b/components/add-game-to-playing-list.tsx @@ -32,7 +32,6 @@ export default function AddGameToPlayingList(props: { gameId: string, user: User formData.id = user.id formData.playingGameList = props.user.playingGameList.filter((id) => id !== gameId) - console.log(formData.playingGameList) const response = await fetch('/api/users/gamelists', { method: 'PUT', body: JSON.stringify(formData) @@ -56,7 +55,7 @@ export default function AddGameToPlayingList(props: { gameId: string, user: User method: 'PUT', body: JSON.stringify(formData) }) - console.log("add game") + startTransition(() => { // Refresh the current route and fetch new data from the server without // losing client-side browser or React state. @@ -71,16 +70,16 @@ export default function AddGameToPlayingList(props: { gameId: string, user: User if (!props.user.playingGameList.includes(parseFloat(props.gameId))) { button = ( <form onSubmit={addGame}> - <Button type="submit" size="lg"> - Add Game To currently-playing-List + <Button type="submit" size="lg" variant={"ghost"}> + Currently Playing </Button> </form> ) } else { button = ( <form onSubmit={removeGame}> - <Button type="submit" size="lg" variant={"secondary"}> - Remove Game From currently-playing-List + <Button type="submit" size="lg" variant={"ghost"}> + Remove Currently Playing </Button> </form> ) diff --git a/components/addGameToFavList.tsx b/components/addGameToFavList.tsx index a2d8cf0772d0d853293911379cfe60f3316df185..9106e429f2c4f3c302e506409d1d775ed0b0ae82 100644 --- a/components/addGameToFavList.tsx +++ b/components/addGameToFavList.tsx @@ -53,7 +53,7 @@ export default function AddGameToFavList(props: { userGameList: Number[], gameId button = ( <form onSubmit={addGame}> <Button type="submit" size="lg"> - Add Game To Favorite List + Add To Favorites </Button> </form> ) @@ -61,7 +61,7 @@ export default function AddGameToFavList(props: { userGameList: Number[], gameId button = ( <form onSubmit={removeGame}> <Button type="submit" size="lg" variant={"secondary"}> - Remove Game From Favorite List + Remove From Favorites </Button> </form> ) diff --git a/components/profile/components/user-games.tsx b/components/profile/components/user-games.tsx index df8e8fe1467ec1c43ad8b3ed244e9e540927f4a8..ee1003c52f69f8226c4ca12643721fbba0135062 100644 --- a/components/profile/components/user-games.tsx +++ b/components/profile/components/user-games.tsx @@ -32,24 +32,39 @@ export const UserGames = async ({ username }: { username: string }) => { redirect('/home') } - let favoritegames = undefined + let favoritegames = undefined; let playingGames = undefined let finishedGames = undefined let planningGames = undefined - if (fullUser?.favGameList?.length !== 0 && fullUser?.favGameList?.length != undefined) { - favoritegames = await getFavoriteGames(fullUser?.favGameList!) - } - if (fullUser?.playingGameList?.length !== 0) { - playingGames = await getFavoriteGames(fullUser?.playingGameList!) - } - if (fullUser?.finishedGameList?.length !== 0) { - finishedGames = await getFavoriteGames(fullUser?.finishedGameList!) - } - if (fullUser?.planningGameList?.length !== 0) { - planningGames = await getFavoriteGames(fullUser?.planningGameList!) + // new Implementation + let allgames = fullUser.favGameList.concat(fullUser.playingGameList, fullUser.finishedGameList, fullUser.planningGameList); + let fetchedGames = undefined; + if (allgames.length !== 0) { + fetchedGames = await getFavoriteGames(allgames) + + favoritegames = fetchedGames.filter(game => fullUser.favGameList.includes(game.id)); + playingGames = fetchedGames.filter(game => fullUser.playingGameList.includes(game.id)); + finishedGames = fetchedGames.filter(game => fullUser.finishedGameList.includes(game.id)); + planningGames = fetchedGames.filter(game => fullUser.planningGameList.includes(game.id)); } + + // Old Implementation + + /* if (fullUser?.favGameList?.length !== 0 && fullUser?.favGameList?.length != undefined) { + favoritegames = await getFavoriteGames(fullUser?.favGameList!) + } + if (fullUser?.playingGameList?.length !== 0) { + playingGames = await getFavoriteGames(fullUser?.playingGameList!) + } + if (fullUser?.finishedGameList?.length !== 0) { + finishedGames = await getFavoriteGames(fullUser?.finishedGameList!) + } + if (fullUser?.planningGameList?.length !== 0) { + planningGames = await getFavoriteGames(fullUser?.planningGameList!) + } */ + return ( <div className="p-3 space-y-12"> <div>