refactor: remove early return check when products list is undefined
This commit is contained in:
1 parent
d5ac0633f5
commit
230337aef9
1 file changed
+2
-5
@@ -929,9 +929,6 @@ export default class ProductModuleService<
|
|||||||
updatedCollections.map(async (collection, i) => {
|
updatedCollections.map(async (collection, i) => {
|
||||||
const input = normalizedInput.find((c) => c.id === collection.id)
|
const input = normalizedInput.find((c) => c.id === collection.id)
|
||||||
const productsToUpdate = (input as any)?.products
|
const productsToUpdate = (input as any)?.products
|
||||||
if (!productsToUpdate) {
|
|
||||||
return { ...collection, products: [] }
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.productService_.update(
|
await this.productService_.update(
|
||||||
{
|
{
|
||||||
@@ -941,7 +938,7 @@ export default class ProductModuleService<
|
|||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
if (productsToUpdate.length > 0) {
|
if (productsToUpdate?.length > 0) {
|
||||||
await this.productService_.update(
|
await this.productService_.update(
|
||||||
productsToUpdate.map((p) => ({
|
productsToUpdate.map((p) => ({
|
||||||
id: p.id,
|
id: p.id,
|
||||||
@@ -951,7 +948,7 @@ export default class ProductModuleService<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ...collection, products: productsToUpdate }
|
return { ...collection, products: productsToUpdate || [] }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user