mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Update types (#831)
* Update product types * Cart types progress, add zod & initial schema validator * Update normalize.ts * Update with-schema-parser.ts * Updated types, schemas & providers * Fix providers after schema parse errors * Fix paths * More provider fixes * Fix kibocommerce & commercejs * Add customer updated types & fixes * Add checkout & customer types * Import core types only from commerce * Update tsconfig.json * Convert hooks interfaces to types * Requested changes * Change to relative paths * Move Zod dependency
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { Product as SFCCProduct, Search } from 'commerce-sdk'
|
||||
import type {
|
||||
Product,
|
||||
ProductImage,
|
||||
ProductOption,
|
||||
ProductVariant,
|
||||
} from '@vercel/commerce/types/product'
|
||||
@@ -58,15 +57,16 @@ export function normalizeProduct(
|
||||
// TODO: use `name-ID` as a virtual slug (for search 1:1)
|
||||
slug: product.id, // use product ID as a slug
|
||||
name: product.name!,
|
||||
path: `/${product.id}`,
|
||||
description: product.longDescription!,
|
||||
price: {
|
||||
value: product.price!,
|
||||
currencyCode: product.currency,
|
||||
},
|
||||
images: product.imageGroups![0].images.map((image) => ({
|
||||
url: image.disBaseLink,
|
||||
altText: image.title,
|
||||
})) as ProductImage[],
|
||||
url: image.disBaseLink || image.link,
|
||||
alt: image.title || '',
|
||||
})),
|
||||
variants: normaliseVariants(product.variants),
|
||||
options: normaliseOptions(product.variationAttributes),
|
||||
}
|
||||
@@ -78,6 +78,7 @@ export function normalizeSearchProducts(
|
||||
return products.map((product) => ({
|
||||
id: product.productId,
|
||||
slug: product.productId, // use product ID as a slug
|
||||
path: `/${product.productId}`,
|
||||
name: product.productName!,
|
||||
description: '',
|
||||
price: {
|
||||
@@ -87,8 +88,8 @@ export function normalizeSearchProducts(
|
||||
images: [
|
||||
{
|
||||
url: product.image!.link,
|
||||
altText: product.productName,
|
||||
} as ProductImage,
|
||||
alt: product.productName,
|
||||
},
|
||||
],
|
||||
variants: normaliseVariants(product.variants),
|
||||
options: normaliseOptions(product.variationAttributes),
|
||||
|
Reference in New Issue
Block a user