diff --git a/components/AddLibraryButton.vue b/components/AddLibraryButton.vue index e88516c..3978aba 100644 --- a/components/AddLibraryButton.vue +++ b/components/AddLibraryButton.vue @@ -37,7 +37,9 @@ > Collections -
+
diff --git a/components/CreateCollectionModal.vue b/components/CreateCollectionModal.vue index bb397a5..73e6569 100644 --- a/components/CreateCollectionModal.vue +++ b/components/CreateCollectionModal.vue @@ -48,6 +48,8 @@ import { ref } from "vue"; import { DialogTitle } from "@headlessui/vue"; import ModalTemplate from "~/drop-base/components/ModalTemplate.vue"; +import type { CollectionEntry, Game } from "@prisma/client"; +import type { SerializeObject } from "nitropack"; const props = defineProps<{ gameId?: string; @@ -77,10 +79,13 @@ async function createCollection() { // Add the game if provided if (props.gameId) { - await $fetch(`/api/v1/collection/${response.id}/entry`, { + const entry = await $fetch< + CollectionEntry & { game: SerializeObject } + >(`/api/v1/collection/${response.id}/entry`, { method: "POST", body: { id: props.gameId }, }); + response.entries.push(entry); } collections.value.push(response); diff --git a/pages/library/game/[id]/index.vue b/pages/library/game/[id]/index.vue index 794bff6..a2a20db 100644 --- a/pages/library/game/[id]/index.vue +++ b/pages/library/game/[id]/index.vue @@ -64,7 +64,7 @@
-
+
diff --git a/pages/library/index.vue b/pages/library/index.vue index a480a67..ccde1d9 100644 --- a/pages/library/index.vue +++ b/pages/library/index.vue @@ -19,7 +19,7 @@
diff --git a/server/api/v1/collection/[id]/entry.post.ts b/server/api/v1/collection/[id]/entry.post.ts index b869050..2356e43 100644 --- a/server/api/v1/collection/[id]/entry.post.ts +++ b/server/api/v1/collection/[id]/entry.post.ts @@ -20,6 +20,5 @@ export default defineEventHandler(async (h3) => { if (!gameId) throw createError({ statusCode: 400, statusMessage: "Game ID required" }); - await userLibraryManager.collectionAdd(gameId, id, userId); - return; + return await userLibraryManager.collectionAdd(gameId, id, userId); }); diff --git a/server/internal/userlibrary/index.ts b/server/internal/userlibrary/index.ts index eaaef9e..4bdb3ed 100644 --- a/server/internal/userlibrary/index.ts +++ b/server/internal/userlibrary/index.ts @@ -78,7 +78,7 @@ class UserLibraryManager { } async collectionAdd(gameId: string, collectionId: string, userId: string) { - await prisma.collectionEntry.upsert({ + return await prisma.collectionEntry.upsert({ where: { collectionId_gameId: { collectionId, @@ -93,6 +93,9 @@ class UserLibraryManager { gameId, }, update: {}, + include: { + game: true, + }, }); }