refactor(categories): change controller route from 'api/categories' to 'categories'

fix(products): update category fetch logic to ensure data is an array
refactor(products): simplify GET handler by integrating authentication directly
This commit is contained in:
Nils-Johan Gynther
2026-04-17 22:13:16 +02:00
parent 543059f405
commit adcfa97c06
3 changed files with 15 additions and 11 deletions
@@ -43,7 +43,9 @@ export default function EditProductForm({ product }: Props) {
if (isOpen && categoryTree.length === 0) {
fetch('/api/categories')
.then((r) => r.json())
.then((data: CategoryNode[]) => setCategoryTree(data))
.then((data: unknown) => {
if (Array.isArray(data)) setCategoryTree(data as CategoryNode[]);
})
.catch(() => {});
}
}, [isOpen]);