feat(api): update category fetch requests to include tree structure

This commit is contained in:
Nils-Johan Gynther
2026-04-19 19:38:49 +02:00
parent 43fb31d0b9
commit afe89439c1
3 changed files with 35 additions and 50 deletions
@@ -80,7 +80,7 @@ export default function AdminProductList() {
}, [refetchProducts]);
useEffect(() => {
fetch('/api/categories')
fetch('/api/categories?tree')
.then((r) => r.json())
.then((data) => { if (Array.isArray(data)) setCategoryTree(data); })
.catch(() => {});
@@ -55,7 +55,7 @@ export default function EditProductForm({ product, onSaved, onDeleted }: Props)
useEffect(() => {
if (isOpen && categoryTree.length === 0) {
fetch('/api/categories')
fetch('/api/categories?tree')
.then((r) => r.json())
.then((data: unknown) => {
if (Array.isArray(data)) setCategoryTree(data as CategoryNode[]);