feat(categories): implement category management with hierarchical structure and update product association
This commit is contained in:
@@ -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',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user