feat(categories): implement category management with hierarchical structure and update product association

This commit is contained in:
Nils-Johan Gynther
2026-04-17 21:16:58 +02:00
parent a9e83544c5
commit cc8be88462
11 changed files with 286 additions and 42 deletions
+3
View File
@@ -11,6 +11,8 @@ export async function updateProduct(formData: FormData) {
const category = String(formData.get('category') || '').trim();
const subcategory = String(formData.get('subcategory') || '').trim();
const brand = String(formData.get('brand') || '').trim();
const categoryIdRaw = formData.get('categoryId');
const categoryId = categoryIdRaw !== '' && categoryIdRaw != null ? Number(categoryIdRaw) : null;
if (!name) throw new Error('Namn får inte vara tomt.');
if (name.length > 100) throw new Error('Namn får inte vara längre än 100 tecken.');
@@ -28,6 +30,7 @@ export async function updateProduct(formData: FormData) {
category: category || null,
subcategory: subcategory || null,
brand: brand || null,
categoryId,
}),
cache: 'no-store',
});