squash: AdenMGB collection design & backend work

Update index.post.ts to implement saving collections functionality

Update index.get.ts to verify if collection exists and if user can access it

Update index.delete.ts to ask questions and not be so nonchalant

Update entry.post.ts

Update entry.delete.ts to do it better

Update index.vue to add functionality to the add to library button + fidgit with image

Update index.vue to also add add to library functionality, but no fidget :(

Update entry.post.ts to infact not remove it

Update index.ts

Update index.vue to manage collections from store page

Update index.ts to restrut for ahhhh

Update index.vue too add collection control to carosel

Update index.vue fix minor issue

Update index.vue to fix dropdown modal bug

Create library.vue for page layout

Create index.vue for library game details pane

Create index.vue for viewing collections pane

Create DeleteCollectionModal.vue component

Create CreateCollectionModal.vue component

Update AddLibraryButton.vue with dropdown :D

Update index.vue to use new components

Update index.vue for more components :O

Update entry.post.ts to not not return success, it'll figure it out

Update entry.delete.ts to not return...
This commit is contained in:
Aden Lindsay
2025-01-27 11:15:09 +10:30
committed by DecDuck
parent 892f64fe3a
commit eea8f82bf9
16 changed files with 1844 additions and 97 deletions

View File

@ -16,11 +16,26 @@ export default defineEventHandler(async (h3) => {
});
const body = await readBody(h3);
const gameId = body.id;
if (!gameId)
throw createError({ statusCode: 400, statusMessage: "Game ID required" });
await userLibraryManager.collectionRemove(id, gameId);
// Verify collection exists and user owns it
const collection = await userLibraryManager.fetchCollection(id);
if (!collection) {
throw createError({
statusCode: 404,
statusMessage: "Collection not found",
});
}
if (collection.userId !== userId) {
throw createError({
statusCode: 403,
statusMessage: "Not authorized to modify this collection",
});
}
const removed = await userLibraryManager.collectionRemove(gameId, id);
return {};
});

View File

@ -16,11 +16,26 @@ export default defineEventHandler(async (h3) => {
});
const body = await readBody(h3);
const gameId = body.id;
if (!gameId)
throw createError({ statusCode: 400, statusMessage: "Game ID required" });
await userLibraryManager.collectionAdd(id, gameId);
return {};
// Verify collection exists and user owns it
const collection = await userLibraryManager.fetchCollection(id);
if (!collection) {
throw createError({
statusCode: 404,
statusMessage: "Collection not found",
});
}
if (collection.userId !== userId) {
throw createError({
statusCode: 403,
statusMessage: "Not authorized to modify this collection",
});
}
await userLibraryManager.collectionAdd(gameId, id);
return { success: true };
});

View File

@ -15,6 +15,30 @@ export default defineEventHandler(async (h3) => {
statusMessage: "ID required in route params",
});
const collection = await userLibraryManager.deleteCollection(id);
return collection;
// Verify collection exists and user owns it
const collection = await userLibraryManager.fetchCollection(id);
if (!collection) {
throw createError({
statusCode: 404,
statusMessage: "Collection not found",
});
}
if (collection.userId !== userId) {
throw createError({
statusCode: 403,
statusMessage: "Not authorized to delete this collection",
});
}
// Don't allow deleting default collection
if (collection.isDefault) {
throw createError({
statusCode: 400,
statusMessage: "Cannot delete default collection",
});
}
await userLibraryManager.deleteCollection(id);
return { success: true };
});

View File

@ -15,6 +15,22 @@ export default defineEventHandler(async (h3) => {
statusMessage: "ID required in route params",
});
// Fetch specific collection
const collection = await userLibraryManager.fetchCollection(id);
if (!collection) {
throw createError({
statusCode: 404,
statusMessage: "Collection not found",
});
}
// Verify user owns this collection
if (collection.userId !== userId) {
throw createError({
statusCode: 403,
statusMessage: "Not authorized to access this collection",
});
}
return collection;
});

View File

@ -9,11 +9,22 @@ export default defineEventHandler(async (h3) => {
});
const body = await readBody(h3);
const gameId = body.id;
if (!gameId)
throw createError({ statusCode: 400, statusMessage: "Game ID required" });
await userLibraryManager.libraryRemove(gameId, userId);
// Get the default collection for this user
const collections = await userLibraryManager.fetchCollections(userId);
const defaultCollection = collections.find(c => c.isDefault);
if (!defaultCollection) {
throw createError({
statusCode: 404,
statusMessage: "Default collection not found",
});
}
// Add the game to the default collection
await userLibraryManager.collectionAdd(gameId, defaultCollection.id);
return {};
});

View File

@ -14,6 +14,7 @@ export default defineEventHandler(async (h3) => {
if (!name)
throw createError({ statusCode: 400, statusMessage: "Requires name" });
const collections = await userLibraryManager.fetchCollections(userId);
return collections;
// Create the collection using the manager
const newCollection = await userLibraryManager.collectionCreate(name, userId);
return newCollection;
});