mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
ensure products have at least one variant
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { getConfig, SwellConfig } from '../api'
|
||||
import { normalizeProduct } from '../utils/normalize'
|
||||
import { Product } from '@commerce/types'
|
||||
import { SwellProduct } from '../types'
|
||||
|
||||
type Variables = {
|
||||
first?: number
|
||||
@@ -23,12 +24,10 @@ const getAllProducts = async (options: {
|
||||
limit: variables.first,
|
||||
},
|
||||
])
|
||||
const products = results.map((product) => {
|
||||
if (product.variants) {
|
||||
product.variants = product.variants.results
|
||||
}
|
||||
return normalizeProduct(product) ?? []
|
||||
})
|
||||
const products = results.map((product: SwellProduct) =>
|
||||
normalizeProduct(product)
|
||||
)
|
||||
|
||||
return {
|
||||
products,
|
||||
}
|
||||
|
Reference in New Issue
Block a user