feat(medusa, admin-ui): increase tree depth + scope categories on store + allow categories relation in products API (#3450)

What:
- increase tree depth in react nestable
- scope categories on store queries
- allow categories relation in products API

RESOLVES CORE-1238
RESOLVES CORE-1237
RESOLVES CORE-1236
This commit is contained in:
Riqwan Thamir
2023-03-13 17:30:21 +00:00
committed by GitHub
parent 85640475e5
commit 2f42ed35d6
22 changed files with 720 additions and 432 deletions
+1
View File
@@ -10,3 +10,4 @@ export * from "./calculate-price-tax-amount"
export * from "./csv-cell-content-formatter"
export * from "./exception-formatter"
export * from "./db-aware-column"
export * from "./product-category"
@@ -0,0 +1,25 @@
import { FindOptionsWhere } from "typeorm"
import { ProductCategory } from "../../models"
import { isDefined } from "medusa-core-utils"
export const categoryMatchesScope = (
category: ProductCategory,
query: FindOptionsWhere<ProductCategory>
): boolean => {
return Object.keys(query ?? {}).every(key => category[key] === query[key])
}
export const fetchCategoryDescendantsIds = (
productCategory: ProductCategory,
query: FindOptionsWhere<ProductCategory>
) => {
let result = [productCategory.id]
;(productCategory.category_children || []).forEach((child) => {
if (categoryMatchesScope(child, query)) {
result = result.concat(fetchCategoryDescendantsIds(child, query))
}
})
return result
}