feat(api): update category fetch requests to include tree structure
This commit is contained in:
@@ -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[]);
|
||||
|
||||
Reference in New Issue
Block a user