mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
viewed prodyct
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Cart } from '@commerce/types/cart'
|
||||
import { ProductCard } from '@commerce/types/product'
|
||||
import { ProductCard, Product } from '@commerce/types/product'
|
||||
import { CartFragment, SearchResultFragment } from '../schema'
|
||||
|
||||
export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
|
||||
@@ -57,3 +57,18 @@ export function normalizeCart(order: CartFragment): Cart {
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeProductCard(product: Product): ProductCard {
|
||||
return {
|
||||
id: product.id,
|
||||
name: product.name,
|
||||
slug: product.slug,
|
||||
imageSrc: product.images[0].url,
|
||||
price: product.price,
|
||||
currencyCode: product.currencyCode,
|
||||
productVariantId: product.variants?.[0].id.toString(),
|
||||
productVariantName:product.variants?.[0].name,
|
||||
facetValueIds: product.facetValueIds,
|
||||
collectionIds: product.collectionIds,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user