mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
.vscode
assets
components
config
framework
bigcommerce
api
definitions
endpoints
fragments
operations
utils
concat-cookie.ts
errors.ts
fetch-graphql-api.ts
fetch-store-api.ts
fetch.ts
filter-edges.ts
get-cart-cookie.ts
get-customer-id.ts
parse-item.ts
set-product-locale-meta.ts
types.ts
index.ts
auth
cart
checkout
customer
lib
product
scripts
types
wishlist
.env.template
README.md
commerce.config.json
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
commerce
commercejs
commercelayer
kibocommerce
local
ordercloud
saleor
shopify
spree
swell
vendure
lib
pages
public
.editorconfig
.env.template
.eslintrc
.gitignore
.prettierignore
.prettierrc
README.md
codegen.bigcommerce.json
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package-lock.json
package.json
postcss.config.js
swell-js.d.ts
tailwind.config.js
tsconfig.json
* optionsSelections takes an array of options objs * use options array to match API expectations Co-authored-by: Ryan Ford <ryanford@users.noreply.github.com>
29 lines
726 B
TypeScript
29 lines
726 B
TypeScript
import type { WishlistItemBody } from '../../types/wishlist'
|
|
import type { CartItemBody, OptionSelections } from '../../types/cart'
|
|
|
|
type BCWishlistItemBody = {
|
|
product_id: number
|
|
variant_id: number
|
|
}
|
|
|
|
type BCCartItemBody = {
|
|
product_id: number
|
|
variant_id: number
|
|
quantity?: number
|
|
option_selections?: OptionSelections[]
|
|
}
|
|
|
|
export const parseWishlistItem = (
|
|
item: WishlistItemBody
|
|
): BCWishlistItemBody => ({
|
|
product_id: Number(item.productId),
|
|
variant_id: Number(item.variantId),
|
|
})
|
|
|
|
export const parseCartItem = (item: CartItemBody): BCCartItemBody => ({
|
|
quantity: item.quantity,
|
|
product_id: Number(item.productId),
|
|
variant_id: Number(item.variantId),
|
|
option_selections: item.optionSelections,
|
|
})
|