aboutsummaryrefslogtreecommitdiff
path: root/src/routes/catalog/+page.server.ts
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-09-07 10:55:06 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-09-07 10:55:06 +0200
commit113415ce357a9cea1759d0452ebae6352f8fe36b (patch)
tree109d55552e7007ba1a8c2752692e85eeb0cc6168 /src/routes/catalog/+page.server.ts
parent8cd634e51b79200848068ef45bd3fb700758c394 (diff)
Split groceries domain out of the app root
Move the grocery list, catalog, and categories routes under /groceries/ so the app home can host the projects/routines overview next. Update nav to exact-path matching, login redirect default, and layout title.
Diffstat (limited to 'src/routes/catalog/+page.server.ts')
-rw-r--r--src/routes/catalog/+page.server.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/routes/catalog/+page.server.ts b/src/routes/catalog/+page.server.ts
deleted file mode 100644
index 22464dc..0000000
--- a/src/routes/catalog/+page.server.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { fail } from '@sveltejs/kit';
-import {
- loadAll,
- toggle,
- bulkUpdateGroceryCategory,
-} from '$lib/server/services/groceries';
-import {
- numericId,
- parseOptionalNumber,
-} from '$lib/server/services/validation';
-import type { EnrichedGrocery } from '$lib/server/services/groceries';
-import type { Category } from '$lib/server/services/types';
-import type { Actions, PageServerLoad } from './$types';
-
-export interface CatalogOutput {
- items: EnrichedGrocery[];
- categories: Category[];
-}
-
-export const load: PageServerLoad = async () => {
- return loadAll();
-};
-
-export const actions: Actions = {
- toggle: async ({ request }) => {
- const data = await request.formData();
- try {
- const id = numericId(data.get('id'));
- await toggle(id);
- } catch {
- return fail(400, { error: 'ID invalide' });
- }
- return { success: true };
- },
-
- bulkUpdateCategory: async ({ request }) => {
- const data = await request.formData();
- const ids = data.getAll('ids').map(numericId);
- const rawCategoryId = parseOptionalNumber(data.get('category_id'));
- const categoryId = rawCategoryId === -1 ? null : rawCategoryId;
-
- if (ids.length === 0) {
- return fail(400, { error: 'Aucun article sélectionné' });
- }
-
- await bulkUpdateGroceryCategory(ids, categoryId);
- return { success: true, type: 'bulkUpdate' as const };
- },
-};